I downloaded apache2.2.22 src from http://httpd.apache.org/download.cgi and made the installation. The installation works fine. But the problem arises when I try adding vhosts. I added 2 virtual hosts
1. localhost
2. someother.localhost
Both point to different document roots, but resolve to the doc root of the first virtualhost.
hereis my vhost file,
NameVirtualHost *:80
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/webserver/htdocs" ServerName localhost ErrorLog "logs/localhost-error_log" CustomLog "logs/localhost-access_log" common </VirtualHost> <Directory /home/sourabhn/somepath> Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/home/sourabhn/somepath" ServerName someother.localhost ErrorLog "logs/someother-localhost-error_log" CustomLog "logs/someother-localhost-access_log" common </VirtualHost>
I have made the appropriate entry in the hosts file. I am running a Ubuntu 11.10 machine. Please get back with your valuable suggestions
Right away I noticed a difference between your file and the one I cobbled together from net tutorials like this from bobpeers. I’ve added within the virtual host block the
<Directory>block.I’m working on Drupal and just so I can get a name resolved to the Drupal directory, it will take care of the rest. In the Drupal install I have several projects each with their own domain name set up in one Drupal installtion. Below is the example of a Drupal site named hello.local, and another of my Drupal sites could be cheese.local. Both pointing to the same Directory.
Right now its working save for the commented line ServerAlias. Which brings up another point I learned about setting up vHosts. The /etc/hosts file is important to get set up properly.
In the example by bobpeers you’ll see their hosts entry example,
I would expect the reverse name
live.bobpeers.localto be a clearer example of a server name. And this is the thing–I find there is inconsistency in examples. Some examples simply do not use key terms like.localor follow the generic signaturesub-domain.domaon.com. Copying one persons non-normal example you may think the above ServerName references two virtual hosts, live.local and dev.local. For all I know, maybe they do!One more thing about vHosts. The man page shows this,
What works for my localhost sandbox is this,
Which seems correct since name based is supposed to sort it all out, and not this 192.168.1.x IP Mask nonsense. (^_^)