Apache, Ubuntu, CentOS: Virtual Host Configuration

What is Virtual Hosting?

Virtual Hosting is a technique by which web servers can serve more than one domain name on the same server. It can also be a variation of serving different sites on the same IP but on different ports.

If Ubuntu, you may need to edit
i) /etc/hosts

ii) /etc/apache2/conf.d/vhosts.conf (or /etc/apache2/sites-available/default) depending on how you have configured the virtual host environment

If CentOS, you may need to edit

i) /etc/hosts

ii) /etc/httpd/conf/httpd.conf

For listening to different ports Listen directive should be added to /etc/httpd/conf/httpd.conf file


http://httpd.apache.org/docs/2.0/vhosts/examples.html (Apache’s virtual host configuration documentation)


http://apptools.com/phptools/virtualhost.php (For configuring Apache server on Windows)


Written by kurinchilamp

Website: http://

Leave a Reply

Your email address will not be published. Required fields are marked *