Monday, July 25, 2016

Virtual hosting - Web server Apache

Virtual hosting

1. make directory /home/site1/www
[root@base ~]# mkdir -p /home/site1/www

2. create the web page:-
[root@base ~]# cd /home/site1/www/
[root@base www]# vim index.html
this is site1
wq! Save and exit

3. Navigate to conf.d or httpd.conf file
[root@base ~]# cd /etc/httpd/conf.d/
[root@base ~]# vim site1.conf
<VirtualHost 192.168.4.106:80>
ServerAdmin root@site1.example.com
DocumentRoot /home/site1/www
DirectoryIndex index.html
Options Indexes FollowSymLinks
ServerName site1.example.com
ErrorLog logs/site1.example.com-error_log
CustomLog logs/site1.example.com-access_log common
</VirtualHost>

4. check /etc/hosts
[root@base ~]# vim /etc/hosts
192.168.4.106 base
192.168.4.106 site1.example.com

5. Restart the apache server
[root@base ~]# /etc/init.d/httpd restart;chkconfig httpd on

6. Now test your site by hitting
http://site1.example.com




No comments:

Post a Comment