I am rapidly coming to the conclusion that this is not feasible, although for some reason, people - most likely who have not implemented the 'advice' they give, seem to think this is possible.
The scenario is quite straightforward. I am developing symfony websites on my local dev machine, running Ubuntu 10.0.4 LTS. I want to be able to run and test multiple sites locally.
Assuming I have the following sites:
- site1.localhost
- site2.localhost
- site3.localhost
Following the documentation here, here and here (none of which work for me), I have done the following:
A. I modified my /etc/hosts file with the first entry to be:
127.0.0.1 site1.localhost site2.localhost hpdtp-ubuntu910 localhost php.localhost
B. I modified my /etc/apache2/ports.conf file (first lines) as follows:
NameVirtualHost localhost:80 Listen 80
C. I have created configuration sites for each of the websites (site1.localhost and site2.localhost). Each configuration is a separate file in /etc/apache2/sites-available
One such configuration file (for site1.localhost) in /etc/apache2/sites-available/site1 looks like this:
<VirtualHost localhost:80>
ServerName site1.localhost
DocumentRoot "/home/morpheous/work/webdev/frameworks/symfony/sites/site1/web"
DirectoryIndex index.php
<Directory "/home/morpheous/work/webdev/frameworks/symfony/sites/site1/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /lib/vendor/symfony/symfony-1.3.6/data/web/sf
<Directory "/lib/vendor/symfony/symfony-1.3.6/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
D. I have disabled the default apache site by using (it kept showing up instead)
E. Since I can't enable all the sites I enable to work (like the documentation links above purport), I have settled for enabling one site at a time, so that Apache dosen't get its confused as to which site to run. When I need to run another site, I disable the current one and enable the one I want to. This is (obviously?) far from ideal - but even this setup is not working - for the reasons listed below.
i). When I restart Apache, I get the following warning:
- Reloading web server config apache2 [Sun Jul 18 10:32:23 2010] [warn] NameVirtualHost localhost:80 has no VirtualHosts
ii). when I navigate to http://site1.localhost I get the following error message in FF:
Oops! This link appears to be broken
iii). My apache related errors are appearing in /var/log/apachche2/other_vosts.log
morpheous@hpdtp-ubuntu910:~$ tail /var/log/apache2/other_vhosts_access.log
site1.localhost:80 127.0.0.1 - - [18/Jul/2010:10:08:38 +0100] "GET / HTTP/1.1" 404 506 "-" "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.6) Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6 GTB7.1"
site1.localhost:80 127.0.0.1 - - [18/Jul/2010:10:09:30 +0100] "GET / HTTP/1.1" 404 506 "-" "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.6) Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6 GTB7.1"
site1.localhost:80 127.0.0.1 - - [18/Jul/2010:10:09:31 +0100] "GET /favicon.ico HTTP/1.1" 404 505 "-" "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.6) Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6 GTB7.1"
site1.localhost:80 127.0.0.1 - - [18/Jul/2010:10:09:36 +0100] "GET /favicon.ico HTTP/1.1" 404 505 "-" "Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.2.6) Gecko/20100628 Ubuntu/10.04 (lucid) Firefox/3.6.6 GTB7.1"
My questions are:
Can Apache be setup to handle multiple virtual hosts on localhost? Afterall, all examples I have seen so far involve setting Apache with public facing ip addresses
If Apache can indeed handle multiple sites on localhost, which of the steps above am I doing incorrectly?. AFAICT, I have followed the documentation to the letter.