Ubuntu – How to Define Virtual Host Settings on Ubuntu

Ubuntuvirtualhost

I use Ubuntu 10.10 on my laptop.

I added the following to /etc/apache2/httpd.conf

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www/square/public"
ServerName square.localhost
</VirtualHost>

And restarted the apache.

I go to http://square.localhost/ and it gives an error telling server not found.

Could anyone tell me how to define virtual host settings on Ubuntu please?

Thanks in advance.

Best Answer

You should not modify the httpd.conf file, but add a new conf file inside /etc/apache2/sites-available/

This tutorials should clarify you how it works:

http://www.debuntu.org/2006/02/22/7-virtual-hosting-using-apache-2

http://brucewampler.wordpress.com/2009/02/28/adding-virtual-hosts-to-ubuntu-apache/

Related Topic