Server

a computer provides services or resources

What is a server?

A computer that provides services or resources. The programs on that computer makes them servers, jusk like your laptop could be a DB server if you install MySQL and let other computers access into.

Apache Web Server

Install
# install apache
yum install httpd

# start apache web server service
service httpd start
service httpd status
Logs
# view access & error logs
cat /var/log/httpd/access_log
cat /var/log/httpd/error_log
Port
  • the default port is 80

Config file: httpd.conf

httpd.conf is a config file used by Apache web server to control how the server responds to incomming requests. The file specifies things like which ports the server should listen on, where the web applications are located, which modules are loaded, and how security should be enforced.

After configuration, remmember restart httpd service to make it work.

Apache config file

# view configuration file
vim /etc/httpd/conf/httpd.conf

Document root

DocumentRoot in httpd.conf specify where to look at first.

DocumentRoot "/var/www/html"

Host

/etc/hosts
# multiple domains point to the same IP address
127.0.0.1 localhost
127.0.0.1 www.example.com
127.0.0.1 www.oranges.com

Virtual host

Multiple web site can be hosted in the same server if you configure virutal hosts in httpd.conf

<VirutalHost *:80>
    ServerName www.organces.com
    DocumentRoot /var/www/oranges
</VirutalHost>

Include another conf file

Include conf/houses.conf

Nginx web server

# install Nginx
sudo apt-get install -y nginx

# confirm Nginx is running
ps auwx | grep nginx

Commands

# check server timezone
# EST
date +%Z
timedatectl

# change timezone to America/New_York
sudo timedatectl set-timezone America/New_York

# update OS
sudo apt-get update

Last updated