Virtual Host

Discussion in 'Apache' started by rjbathgate, Aug 16, 2010.

  1. #1
    Hi,

    Running apache on EasyPHP local environment.

    I added a Virtual Host to my httpd file in format:

    
      NameVirtualHost *:80
    
        <VirtualHost *:80>
        ServerName myvirtualhost
        DocumentRoot "${path}/www/xxxxx/xxxxx/"
        </VirtualHost>
    
    Code (markup):
    So, "myvirtualhost" should to go /www/xxxxx/xxxxx

    However, this also affects "localhost" which goes to the same place.

    Without the above added, localhost goes to /www/ which it should.

    Doing this:
    
     <VirtualHost *:80>
       ServerName localhost
       DocumentRoot "${path}/www/"
      </VirtualHost>
    
      <VirtualHost *:80>
        ServerName myvirtualhost
        DocumentRoot "${path}/www/xxxxx/xxxxx/"
      </VirtualHost>
    
    Code (markup):
    makes both localhost and myvirtualhost go to /www/, as it's just taking the first virtual host for all.

    My hosts file looks like:

    
    127.0.0.1       localhost
    127.0.0.1      virtualhost
    
    Code (markup):
    What am i doing wrong?!

    Thanks in advance
    Rob
     
    rjbathgate, Aug 16, 2010 IP
  2. agag2

    agag2 Peon

    Messages:
    210
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try reversing the last code maybe?
     
    agag2, Aug 16, 2010 IP
  3. rjbathgate

    rjbathgate Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply

    No luck, the order of hosts doesn't do anything.

    The order of httpd - it simoply takes the first virtual host only, ignoring the second, so if localhost is first, /www/ is target for all virtualhosts. If myvirtualhost is first, /www/xxxxx/xxxx/ is target for all

    Cheers
     
    rjbathgate, Aug 16, 2010 IP
  4. rjbathgate

    rjbathgate Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hey,

    Still having the same problems, and having to change httpd file everytime I want to work on a different 'folder'

    Any ieas?

    Thanks
     
    rjbathgate, Aug 18, 2010 IP