Tuesday, June 24, 2014

How to Configure Name Based Web Server in Linux

5:23 PM

Red Hat® Certified Engineer (RHCE®) is a Red Hat Certified System Administrator (RHCSA) who possesses additional skills, knowledge, and abilities required of a senior system administrator responsible for Red Hat Enterprise Linux® systems.

An RHCE is capable of:

    Configuring static routes, packet filtering, and network address translation.
    Setting kernel runtime parameters.
    Configuring an Internet Small Computer System Interface (iSCSI) initiator.
    Producing and delivering reports on system utilization.
    Using shell scripting to automate system maintenance tasks.
    Configuring system logging, including remote logging.
    Configuring a system to provide networking services, including HTTP/HTTPS, File Transfer        Protocol(FTP), network file system (NFS), server message block (SMB), Simple Mail Transfer Protocol (SMTP), secure shell (SSH) and Network Time Protocol (NTP).



How to create multiple virtual host using name based virtual host.

First install web server in system

root@linuxstorage:~#yum install https* -y

configure the httpd configuration file   



root@linuxstorage:~# vi /etc/httpd/conf/httpd.conf

to enable Name Based virtual host change line by removing symbol in front of line

 #NameVirtualHost *:80
     to

 NameVirtualHost xx.xx.xx.xx(Domain ip ):80

 copy last 7 line of sample and paste it below, then edit it as given below

#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>


change like this

<VirtualHost xx.xx.xx.xx:80>
    ServerAdmin webmaster@linuxstorages.com
    DocumentRoot /var/www/html/sample1
    ServerName sample1.com
    ErrorLog logs/
sample1.com-error_log
    CustomLog logs/
sample1.com-access_log common
</VirtualHost>

 <VirtualHost xx.xx.xx.xx:80>
    ServerAdmin webmaster@linuxstorages.com
    DocumentRoot /var/www/html/sample2
    ServerName sample2.com
    ErrorLog logs/
sample2.com-error_log
    CustomLog logs/
sample2.com-access_log common
</VirtualHost>



:wq!

Both sample1.com and sample2.com domains will have same ip address. Like this we can create more sites using single ip address with help of name based virtual host.

Both virtual host have different document root.

Now we can move file to particular document root. 



    root@linuxstorage:~#cd  /var/www/html/sample1

    root@linuxstorage:~#vi index.html

    test1

    :wq!

    root@linuxstorage:~#cd  /var/www/html/sample2

    root@linuxstorage:~#vi index.html

    test2

    :wq!



root@linuxstorage:~#httpd -s

check the configuration status with help of above command and now restart the web server service



root@linuxstorage:~#service httpd restart

check the domain names in URL or elinks command.


    root@linuxstorage:~#elinks http://sample1.com
    test1

    or

    root@linuxstorage:~#elinks http://sample2.com
    test2

Written by

0 comments :

Post a Comment

 

© 2014 Linux Storages | Updated . All rights resevered. Designed by Templateism