This article gives you the basic configuration of how to host multiple web sites within a single apache web server. Recent survey reports say that almost 65% of internet websites are hosted on apache web servers only. The recent version of apache web servers provides improved multiple options like both name and IP virtual hosting, supports large number of different development modules, enabled logging, graphic tool for configuration, etc. This article explains about setting up virtual host in a Linux server.
1. Installing the package:
Check for existence
#rpm –qa | grep httpd
Else install using rpm or yum.
2. Service daemon - httpd
#chkconfig –level 345 on httpd
#service httpd restart
#/etc/init.d/httpd restart
#apachectl restart
3. Edit /etc/httpd/conf/httpd.conf:
Port for which this Web server should listen and respond
Listen 80
User/group to run httpd daemon
User nobody
Group nobody
Pass the real server name in the /etc/hosts file top:
ServerName webserver
Assign virtual host IP (may be public/private)
NameVirtualHost 200.200.200.200
Enter the virtual host details:
This is the core area for setting up your web page. Virtualhost parameter should be passed with your assigned IP and port number can also be added followed with semi colon. ServerAdmin parameter sends the mail in case of errors (don’t worry for the existence). Documentroot is the place from which the site flourishes; make sure the path is correct and also set permission as 755 recursively to the designated user. For testing create index.html inside the document with some meaningful message. Servername is the URL used for calling your website and just an DNS pointed namespace. Serveralias for short name and subdomain names. Four type of log format is available in the same httpd.conf file, choose any one as you wish (not mandatory). Errorlog and transferlog parameter specifies the path for storing the website logs(make sure the path is valid).
ServerAdmin root@loguinfo.com
DocumentRoot /www/loguinfo.com
ServerName www.loguinfo.com
ServerAlias loguinfo.com *.loguinfo.com
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
ErrorLog /misc/wwwlogs/loguinfo_error.log
TransferLog /misc/wwwlogs/loguinfo_access.log
ServerAdmin root@loguworld.com
DocumentRoot /www/loguworld.com
ServerName www.loguworld.com
ServerAlias loguworld.com *.loguworld.com
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
ErrorLog /misc/wwwlogs/loguworld_error.log
TransferLog /misc/wwwlogs/loguworld_access.log
4. Name resolution
Local name resolve: Edit /etc/hosts
127.0.0.1 webserver localhost.localdomain localhost
200.200.200.200 www.loguinfo.com
200.200.200.200 www.loguworld.com
For resolving the namespace in open, add the DNS entry as below
IP ADDR:200.200.200.200 - Namespace:www.loguinfo.com
IP ADDR:200.200.200.200 - Namespace:www.loguworld.com
5. Restart the dependent service and reboot the system
Ok…In server, open your browser try www.loguinfo.com and www.loguworld.com , if it result with the correct index.html content respectively ………. Cheers… you have hosted a website… good job…
Logu
logu_microsoft@hotmail.com
9841499143