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

I am trying to configure vhosts for my local development machine, I did it before, but somehow, I am having problems now.

I am trying to have 2 vhosts

http://tickle -> D:\Projects\LearnZendTest\public
http://localhost -> D:\Websites

My vhosts config looks like

<VirtualHost *:80>
    DocumentRoot "D:/Projects/LearnZendTest/public"
    ServerName learnzendtest
    <Directory "D:/Projects/LearnZendTest/public">
        AllowOverride All
        Options All
        Order allow,deny
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "D:/Websites"
    ServerName localhost
    <Directory "D:/Websites">
        AllowOverride All
        Options All
        Order allow,deny
        Allow from 127.0.0.1
    </Directory>
</VirtualHost>

I notice apache only takes into consideration the 1st entry. If I have the entry for localhost 1st, even when I goto http://tickle, I will get to D:\Websites. How can I fix this?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

I do not see a ServerName or ServerAlias with value tickle. With these settings, I expect D:/Projects/LearnZendTest/public to be served.

Above your <VirtualHost> blocks, you should have the following as well:

NameVirtualHost *:80

This enables name-based virtual hosting (multiple VirtualHost with the same IP, distinguished by ServerName or ServerAlias. if you want Apache to server D:/Websites/ for http://tickle/, you should modify ServerName localhost to ServerName tickle or add ServerAlias tickle (below ServerName will be fine). Finally, a change in the hosts file is necessary for your browser mapping http://tickle/ to 127.0.0.1. Edit C:\Windows\System32\drivers\etc\hosts with notepad (Administrator permissions is required). Add:

127.0.0.1 tickle

Links:

share|improve this answer
    
thanks, tickle was a typo, I just didn't put in the the code snipplet. But the main part I was missing was NameVirtualHost *:80 –  Jiew Meng Dec 16 '10 at 2:27
add comment

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.