logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: VirtualHost
Author
SteveS



Joined: 22 Sep 2009
Posts: 5
Location: Denver

PostPosted: Tue 22 Sep '09 16:49    Post subject: VirtualHost Reply with quote

I setup a Win-XP computer with WAMP Server 2.0, which has Apache 2.2.11. Using ApacheConf Lite, I tried to set up a VirtualHost so that multiple URL's could be hosted on the same server with a single IP -- without success. An edited .conf file is copied below:
===================================
ServerName www.mainsitename.net:80
ServerAdmin admin@localhost
DocumentRoot "c:/wamp/www/"
NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.mysite1.com
DirectoryIndex index.html
DocumentRoot "C:/localdir1"
</VirtualHost>
<VirtualHost *:80>
ServerName www.mainsitename.net
DocumentRoot "C:/wamp/www"
</VirtualHost>
<VirtualHost *:80>
ServerName www.mysite2.com
DocumentRoot "C:/localdir2"
</VirtualHost>
========================
No matter what URL is referenced, everything goes to the "mainsite".
I've poured through textbooks and online documentation, and I seem to be missing something imperative. Can anyone help? Thanks!

Steve
Back to top
SteveS



Joined: 22 Sep 2009
Posts: 5
Location: Denver

PostPosted: Tue 22 Sep '09 19:32    Post subject: security Reply with quote

It appears the problem was that ApacheConf Lite was not modifying the correct httpd.conf file, so nothing I was doing with the conf file was changing anything.

I've corrected that, but now whenever I add a VirtualHost to httpd.conf, I get a security error accessing anything (error 403, the website requires you to login). If I don't have any VirtualHost groups, the site works OK.

I presume this is related to WinXP security and that I need to provide access to the appropriate folder(s), but what login does Apache use? I tried Anonymous, and several others, but nothing makes any difference.

If the following is in the httpd.conf file, it fails. If I delete or comment-out the following, the site works, but of course without a virtual host.

<VirtualHost *:80>
ServerName www.mysite.com
DocumentRoot "c:/wamp/mysitedir"
</VirtualHost>

Thanks, anyone who has the patience to read this and patience with a newbie.

S
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Tue 22 Sep '09 22:59    Post subject: Re: security Reply with quote

SteveS wrote:
I presume this is related to WinXP security and that I need to provide access to the appropriate folder(s)


No to the first part and yes to the second. Unless you're document roots are in My Documents or you've taken the time and steps to "jail" Apache, the chances of XP causing the problem are slim.

SteveS wrote:
===================================
ServerName www.mainsitename.net:80
ServerAdmin admin@localhost
DocumentRoot "c:/wamp/www/"
NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.mysite1.com
DirectoryIndex index.html
DocumentRoot "C:/localdir1"
</VirtualHost>
<VirtualHost *:80>
ServerName www.mainsitename.net
DocumentRoot "C:/wamp/www"
</VirtualHost>
<VirtualHost *:80>
ServerName www.mysite2.com
DocumentRoot "C:/localdir2"
</VirtualHost>


ok, anything outside of a <VirtualHost> container is global, anything inside is per that single host. Your close, but not quite there.

per: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
Quote:
Main host goes away

If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.


e.g. move the one you've got 2nd in this list to the first one since it matches the main (global) host.

Try following the <Directory> directives for said main host to create ones for the other virtual hostnames. Get it right and the 403 errors will go away. Also read the Apache Docs on each of the directives used, it may clear some things up for you.

http://httpd.apache.org/docs/2.2/mod/directives.html
Back to top
SteveS



Joined: 22 Sep 2009
Posts: 5
Location: Denver

PostPosted: Wed 23 Sep '09 18:38    Post subject: Thanks Reply with quote

*sigh*... I never noticed the word "first". That seems to be it. Works now.
Back to top


Reply to topic   Topic: VirtualHost View previous topic :: View next topic
Post new topic   Forum Index -> Apache