How To Setup Multiple Virtual Hosts In Apache
In order to maximize resource utilization, one physical server hardware is usually configured to support multiple instances at one time.
In the case of web server, it’s not uncommon that most web hosting service providers are serving multiple domains in one super Linux machine. Statistically, majority of these Linux boxes are running Apache (the most popular web server)!
How To configure Apache virtual host feature to support multiple domains in one physical Linux hardware?
This guide is tested successfully on my Red Hat Enterprise Linux 4 and Apache version 2 (httpd-2.0.52-9.ent).

How To configure Apache virtual host feature to support multiple domains in one physical Linux hardware?
- Edit the Apache server configuration file, i.e.
vi /etc/httpd/conf/httpd.conf
- Locate the NameVirtualHost and <VirtualHost> directives. By default, these directives are remarked or commented during installation.
- Suppose that the NameVirtualHost and <VirtualHost> directives are commented (that is why you’re here), append the following block of codes at the bottom of httpd.conf file
NameVirtualHost 192.168.10.20:80 <VirtualHost 192.168.10.20:80> DocumentRoot /var/www/html/walkernewsdotnet ServerName www.walkernerws.net </VirtualHost> <VirtualHost 192.168.10.20:80> DocumentRoot /var/www/html/exampledotcom ServerName www.example.com </VirtualHost>
Where
- 192.168.10.20 is the Linux server IP address
- DocumentRoot is the directory that keep the domain web pages
- ServerName is the domain name
- Now, restart the Apache web server to make changes become effective,
service httpd restart
- Edit the DNS server to resolve both www.walkernews.net and www.example.com to one IP address, i.e. 192.168.10.20 in this guide.
Alternative, you can edit the/etc/hostsfile to maintain the domain name to IP mapping information.
For Windows Vista and alike, the hosts file can be located at
%windir%\System32\drivers\etc\
- Finally, open your favourite web browser and enter the URL address to browse either www.walkernews.net or www.example.com.
This guide is tested successfully on my Red Hat Enterprise Linux 4 and Apache version 2 (httpd-2.0.52-9.ent).
Custom Search







2010 •