Go Back   CodingForums.com > :: Client side development > General web building

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-12-2007, 02:44 AM   PM User | #1
tylerjca
Regular Coder

 
tylerjca's Avatar
 
Join Date: Dec 2002
Location: Canada
Posts: 161
Thanks: 1
Thanked 0 Times in 0 Posts
tylerjca is an unknown quantity at this point
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
tylerjca is offline   Reply With Quote
Old 06-12-2007, 06:58 AM   PM User | #2
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||

Last edited by _Aerospace_Eng_; 06-12-2007 at 07:18 AM..
_Aerospace_Eng_ is offline   Reply With Quote
Old 06-12-2007, 03:20 PM   PM User | #3
tylerjca
Regular Coder

 
tylerjca's Avatar
 
Join Date: Dec 2002
Location: Canada
Posts: 161
Thanks: 1
Thanked 0 Times in 0 Posts
tylerjca is an unknown quantity at this point
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!
tylerjca is offline   Reply With Quote
Old 06-12-2007, 06:58 PM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Old 06-13-2007, 12:54 AM   PM User | #5
tylerjca
Regular Coder

 
tylerjca's Avatar
 
Join Date: Dec 2002
Location: Canada
Posts: 161
Thanks: 1
Thanked 0 Times in 0 Posts
tylerjca is an unknown quantity at this point
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_!
tylerjca is offline   Reply With Quote
Old 06-13-2007, 05:29 AM   PM User | #6
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
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!||||
_Aerospace_Eng_ is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:33 PM.


Advertisement
Log in to turn off these ads.