Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder tylerjca's Avatar
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts

    VirtualHost Problems.. what am I don't wrong?

    Hi, I'm trying to set up Virtual Hosts on my local server (Not public).

    I am having problems though. I've done this before and had it work prefectly, but I don't remember how I got it to work last time.. but here's my problem..

    In the httpd.conf file, I have added the <VirtualHost> tags for 2 separate sites. But only the "default" (*:80) one works.. BTW, I'm on a Windows system.

    Code:
    NameVirtualHost *:80
     
    <VirtualHost server1:80>
         ServerAdmin tyler@localhost
         DocumentRoot 'C:/Program Files/xampp/htdocs/tyler'
         ServerName server
    </VirtualHost>
     
    <VirtualHost *:80>
         ServerAdmin admin@localhost
         DocumentRoot 'C:/Program Files/xampp/htdocs'
         ServerName server
    </VirtualHost>
    It's server1 that won't work for me. Please tell me what I've done wrong, or any possible things I've missed!

    Edit: also, i know that the directorie are correct because when i change the DocumentRoot in *:80 to 'C:/Program Files/xampp/htdocs/tyler' it works as expected, but not for the expected VirtualHost


    Thanks,
    Tyler
    Last edited by tylerjca; 06-12-2007 at 02:57 AM. Reason: added a detail

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Maybe this will help you
    http://www.thewatchmakerproject.com/...o-work-offline

    I changed my NameVirtualHost from *:80 to 127.0.0.1
    Code:
    NaveVirtualHost 127.0.0.1
    Then I used this to set up my new virtual host
    Code:
    <VirtualHost 127.0.0.1>
    	ServerName mysite.localhost
    	DocumentRoot "D:\Program Files\xampp\htdocs\somefolder"
    </VirtualHost>
    Seems like you may have your slashes backwards. Remember to edit the host file under C:\WINDOWS\System32\drivers\etc

    After making the changes you will have to restart apache if it was running when you made the changes.
    Last edited by _Aerospace_Eng_; 06-12-2007 at 07:18 AM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder tylerjca's Avatar
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the reply Great resource.
    And it seemed like my slashes were in fact backwards. Thanks

    Now, problem is, it only seems to want me to have 2 virtual hosts.. The 'default' *:80 one works fine, and so does tyler.server.
    And then there is another test folder, msgs.server. This one seems to be recognized, but it directs to the same DocumentRoot as tyler.server.. here's my httpd.conf snippet:
    Code:
    NameVirtualHost *:80
     
    <VirtualHost 127.0.0.1>
        ServerName tyler.server
        DocumentRoot 'C:\program files\xampp\htdocs\tyler'
    </VirtualHost>
     
    <VirtualHost 127.0.0.1>
        ServerName msgs.server
        DocumentRoot 'C:\program files\xampp\htdocs\emessages\msgs'
    </VirtualHost>
     
    <VirtualHost *:80>
        ServerName localhost
        DocumentRoot 'C:\Program Files\xampp\htdocs\'
    </VirtualHost>
    Is there a limit on the number of VirtualHosts you can have? If so, I doubt it's only 2!

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    No I setup 3 of them. Reread my post. Check out what I did to the NameVirtualHost. I changed instances of *:80 to 127.0.0.1
    Again make sure you edit your hosts file.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    Regular Coder tylerjca's Avatar
    Join Date
    Dec 2002
    Location
    Canada
    Posts
    162
    Thanks
    1
    Thanked 0 Times in 0 Posts
    okay, i'm an idiot.. I got it working.. i was trying different combinations of 127.0.0.1 and *:80 and etc.. and I had the hosts file set for:
    127.0.0.1 server
    but I guess it needed to have each name registered .. so i now have
    Code:
    127.0.0.1    server
    127.0.0.1    tyler
    127.0.0.1    messages
    And in httpd.conf:
    Code:
    NameVirtualHost 127.0.0.1
     
    <VirtualHost 127.0.0.1>
    ServerName messages
    DocumentRoot 'C:\program files\xampp\htdocs\emessages\msgs'
    </VirtualHost>
     
    <VirtualHost 127.0.0.1>
    ServerName tyler
    DocumentRoot 'C:\program files\xampp\htdocs\tyler'
    </VirtualHost>
     
    <VirtualHost 127.0.0.1>
    ServerName localhost
    DocumentRoot 'C:\Program Files\xampp\htdocs\forum'
    </VirtualHost>
    
    So everything seems to be working now. Thanks for your help, _Aerospace_Eng_!

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You can also do this with your hosts file
    Code:
    127.0.0.1    server, tyler, messages
    which is the equivalent of
    Code:
    127.0.0.1    server
    127.0.0.1    tyler
    127.0.0.1    messages
    Though it appears you replaced localhost with server. I think that should be set to localhost.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •