Welcome to WebmasterWorld Guest from 18.208.159.25

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

Setting up a virtual host

Windows XP, Apache virtualhost

     
7:52 pm on Dec 1, 2003 (gmt 0)

Senior Member from ES 

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 11, 2003
posts:1381
votes: 0


Like many before me(?), I am trying and failing to get my local server set up to work with virtualhost.

I've tried many different things, so it's hard to say where I am, so I'll lay out my situation and hopefully that helps...

  1. I'm trying to get the server at localhost
  2. I've set my hosts file to resolve www.mytestsite.com to the localhost
  3. When I set:
    <VirtualHost *> 
    ServerName www.mytestsite.com
    DocumentRoot "/path/to/my/test/site"
    </VirtualHost>

    The server gives me a 404.

Any ideas?

8:04 pm on Dec 1, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 25, 2002
posts:776
votes: 0


you also need to edit your hosts file:

in c:/windows/systems32/drivers/etc/hosts

add a line
127.0.0.1 www.mytestsite.com

Also I repeat the ServerName instead of an *

<VirtualHost www.mytestsite.com>
ServerName www.mytestsite.com DocumentRoot "/path/to/my/test/site"
</VirtualHost>

don't know if that matters, but definately need to change the hosts file.

10:22 pm on Dec 1, 2003 (gmt 0)

Senior Member from ES 

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 11, 2003
posts:1381
votes: 0


figment88,

Thanks for the advice. I did have my hosts file set properly, and setting it up the way you have it it still doesn't seem to work.

I'm stumped.

10:47 pm on Dec 1, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 25, 2002
posts:776
votes: 0


Sorry it didn't help. I tried to give you the quick answer, hopefully, someone more knowledgeable will help.

couple of additional points:
1) changes to httpd.conf only take effect when apache is restarted

2) you might have a problem with your NameVirtualHost directive. In the example file they have
#NameVirtualHost *

just uncommenting it doesn't seem to work but I have
NameVirtualHost localhost

which does work,

10:59 pm on Dec 1, 2003 (gmt 0)

Senior Member from ES 

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 11, 2003
posts:1381
votes: 0


Thanks figment88,

I appreciate the help. I've read quite a few tutorials today and they have me doing this and that and some other things, and I really can't say if I've tried all possible combos. I have tried what I thought made sense to me!

Anyway, off to try the NameVirtualHost thing...



Hmm.. No luck, I tried a few combos.
7:31 pm on Dec 2, 2003 (gmt 0)

Senior Member from ES 

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 11, 2003
posts:1381
votes: 0


If someone out there has Apache virtual hosting running on WinXP, I'd love to hear the details.

Still no glory over here, and I'm wondering if it may be something other than how I set up the 'virtual host' part of the httpd.conf file... If I can set up what works for someone else, just maybe I'd be able to debug the other bits!

1:09 am on Dec 3, 2003 (gmt 0)

Senior Member from ES 

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 11, 2003
posts:1381
votes: 0


Okay, problem solved!

Some great advice found on page 4 (30 results per page*4 = 120 results in) in Google.

Check out the error logs and see why apache is failing. So simple.

I would imagine that this is a common procedure, and I can even remember a time in the past when jdMorgan gave me that same advice for another problem.

Time to go play!

fwiw - my problem turned out to be the document root - one of the components in the path had a %20 in place for a space, and that seemed to be what was causing Apache to choke...

1:43 am on Dec 3, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Oct 6, 2003
posts:264
votes: 0


I was only recently playing around with it & reading very much on apache.
So I've got this working on my 98 system, should be problem on a XP , got it to work even in the live server. Most imporatantly is the folder path that you have to get it right. So here's my example:
<VirtualHost 127.0.0.2>
<Directory "C:\Apache\htdocs\abc">
Options Indexes FollowSymLinks Includes
AllowOverride All
ScriptAlias /cgi-bin/ "C:\Apache\htdocs\abc\cgi-bin"
ServerName 127.0.0.2
DocumentRoot "C:\Apache\htdocs\abc"
CustomLog logs/abc_log.log combined
CustomLog logs/abcagent_log.log agent
ErrorLog logs/abcerror_log.log
</VirtualHost>

Notice that you can set 127.0.0.2 as your second host rather than the default .0.1. you can subsequently add 127.0.0.3 as your the other virtual host.
You can't add a domain name into the server name unless you've got a dns pointed to it & your connected live,so for local testing it's best you use a localhost IP.
The directory/root document has to be the same.
OPtions - are for mod testing, which will apply if u plan to use .htaccess.

You can also name your logs accordingly to the domain specified. It's your choice of agent logs, combined which is best & error logs which is a must to see your wrongs.

Other than that I've also added the cgi-bin script alias so that if you create a cgi-bin folder in that particular site/abc & place perl scripts in it - it will work.
Hope that helps.

That's as far as I've gone.

2:04 am on Dec 3, 2003 (gmt 0)

Senior Member from ES 

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 11, 2003
posts:1381
votes: 0


Thanks operafan,

I'll have a closer look at that after some sleep!

In the meantime, here's what I've got set:


NameVirtualHost *

<VirtualHost 127.0.0.2>
ServerName www.testsite.com
DocumentRoot "D:/path/to/my/web/site/"
</VirtualHost>

I have set my HOSTS file accordingly.

Also, .htaccess is working as I have 'options' etc. set elsewhere in the .conf file...

2:15 am on Dec 3, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Oct 6, 2003
posts:264
votes: 0


You dont have to have that namevirtualhost * included is ok.
Yes the options within the virtualhost are not necessary too if you have it set it the main conf file for all directory under the website folder.
Yes and sleep helps, & I found that using Editplus really helps in editing conf files or any other unix files for that matter if you are working on a windows desktop.