Tuesday, June 21, 2011

configure multiple virtual host on apache server on fedora

A few note to myself the necessary steps to configure virtual hosts on apache server running Fedora:

- first need to get DNS mapping correct first. Test ping machines/hosts to verify dns working correctly.
- configuration file = /etc/httpd/conf/httpd.conf
- check that this is the correct configuration file that control the apache server by redirect default web page to a test page and make sure it is displayed correctly. It may be necessary to use different browsers on different computers to access the web server to verify that the server is working properly. Sometimes, I find using the same browser in one machine like firefox seems to cache data and create wrong illusion that the server is always available even when I shutdown the web server.

- modify configuration file to uncomment and enable NameVirtualServer line

- virtual host means using 1 instance of apache server to server multiple web domains/hosts.

- sample configuration for one virtual host:


ServerName www.test.com
DocumentRoot /var/www/


Once >=1 virtual host is configured and used, then every host is considered a virtual host and must have its own configuration as the segment of code above.

- finally restart the web server as below:
#> /sbin/service httpd restart

Done ;)