Module – 13 Linux Webserver Configuration – HTTP/Apache

What is HTTP/Apache?

The Apache HTTP server is a software (or program) that runs in the background under an appropriate operating system,

which supports multi-tasking and provides services to other applications that connect to it, such as client web browsers.apache

It was first developed to work with Linux/Unix operating systems, but was later adapted to work under other systems, including Windows and Mac.

The Apache binary running under UNIX is called HTTPd (short for HTTP daemon)

 

Step:1 Install HTTP server package
 # yum install –y http*
Step:2 Verify the HTTP Packages:
 # rpm -qa -c httpd
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/logrotate.d/httpd
/etc/sysconfig/htcacheclean
/etc/sysconfig/httpd.....
/var/www/error/include/top.html

Step:3 Start the HTTP server
  # service httpd start
Step:4 Verify the HTTP server
  # service httpd status
Step:5 Check for TCP port 80 on listen state
  # netstat -an | grep 80
    tcp4       0      0  *.80                  *.*                    LISTEN     
Step:6 Enable to Auto-start during server reboot
  # chkconfig <httpd> on
Step:7 Now go to browser and hit your ex: IP http://192.168.1.1  (Note: Try your server IP)
   If you see the below page, it means your web-server is working :-)
  Rhel6_apache_test_page
Step:8 Let us customize your webserver 
  # cd /var/www/html
  # touch index.html
  # vi index.html
        <h1>
         This is my first RHEL webserver, Hello World !!
        </h1>
   :wq!

Step:9 restart the HTTP server
  # service <httpd> restart

Again, go to browser and hit your ex: IP http://192.168.1.1  & you should see your custom page.


Let us see what is HTTP/Apache Virtual Host?

The term Virtual Host refers to the practice of maintaining more than one web site on onevirutalhost Apache machine or server.

The NameVirtualHost directive is a required directive if you want to configure name-based virtual hosts.

With the NameVirtualHost directive you specify the IP address on which the server will receive requests for the name-based virtual hosts.

This will usually be the address to which your name-based virtual host names resolve.

 

cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_orig

# Use name-based virtual hosting.

NameVirtualHost *:80                                             ------------> uncomment this line

### add the following lines for 2 instance

<VirtualHost *:80>
   ServerAdmin webmaster@host01.example.com
   DocumentRoot /var/www/html
   ServerName host01.example.com
   ServerAlias host01
   ErrorLog logs/host01.example.com-error_log
   CustomLog logs/host01.example.com-access_log common
</VirtualHost>

<VirtualHost *:80>
   ServerAdmin webmaster@host02.example.com
   DocumentRoot /www/html
   ServerName host02.xample.com
   Serveralias host02
   ErrorLog logs/host02.example.com-error_log
   CustomLog logs/host02.example.com-access_log common
</VirtualHost>

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>