Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to setup my dev machine with virtual hosts so I can access my development projects with a simple url, like http:// project.dev/ rather that a whole http:// 127.0.0.1/dev/path/to/root/of/project/ type of url.

Now, I'm aware there are many tutorials and questions already answered about this, but after trying many of them, I feel like I'm running in circles here.

The problem is simple: after setting up my hosts file and my virtual hosts, any attempt to access a virtual hosts irremediably displays the content of my server DocumentRoot.

my hosts file:

127.0.0.1       localhost
127.0.0.1       mydomain.dev
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0     localhost

my httpd-vhosts.conf

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /Users/pilot/Sites/
</Virtualhost>

<VirtualHost *:80>
    ServerName mydomain.dev
    DocumentRoot /Users/pilot/Sites/devel/vytamin/dev/
</VirtualHost>

I precise that the httpd-vhosts.conf file IS loaded in my httpd.conf and I do get a warning if I point the virtual host document root to a wrong folder.

I made a try setting the localhost virtual host to the following, without any success.

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /Users/pilot/Sites/devel
</Virtualhost>

The following URLS all display the DocumentRoot of my server defined in my httpd.conf file, and seem to ignore the DocumentRoot defined in my VirtualHosts.

http:// 127.0.0.1/
http:// localhost/
http:// mydomain.dev/

I'm running Apache2.2 on Mac OSX 10.5 Leopard, but not the one shipped with mac os. I compiled my own under /usr/local/apache2 and web sharing IS disabled

I can't see anything wrong with my set up so I hope the community will! Thanks for your help!

share|improve this question

3 Answers 3

up vote 0 down vote accepted

This may sound simplistic, but did you restart Apache after making these changes?

Edit: Also, is it mydomain or mydomain.dev? You seem to switch back and forth between the two.

share|improve this answer
    
Hi, Yes I obviously restarted apache and cleared cache in the different browsers I tested, I know this could be an issue as well. I edited the 'mydomain' issue, it is indeed 'mydomain.dev' , it was a typo. Cheers –  ekynoxe Sep 21 '09 at 14:56
    
This one deserves an up, since it is the correct answer. –  user1797 Sep 21 '09 at 18:24
    
Thanks R. Bemrose to point me in the right direction ;) It was indeed linked to the restarting of Apache... –  ekynoxe Sep 23 '09 at 10:24

Ok, I found the problem!

The configuration above is perfectly fine, it was just that my apache was not restarting properly. Neither apache_ctl graceful or apache_ctl restart was terminating all httpd processes I have running, therefore failing to reload properly the changes in my configuration files. Once I killed the remaining processes and really restarted apache, it worked...

Solved, but I feel dumb to have found that!

Now I have a daemon situation to solve!

share|improve this answer

Have you verified that the apache NameVirtualHost directive is set correctly (and not commented out)? That step is necessary for any name-based vhosts to function correctly.

Here is some more info on the topic.

share|improve this answer
    
Ah, sorry I forgot to post it in the question, yes it is setup like this: NameVirtualHost *:80 I edited the question as well. Thanks –  ekynoxe Sep 21 '09 at 14:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.