Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: Apache includes problem - ignoring server name |
|
Author |
|
nikitakv
Joined: 09 Dec 2009 Posts: 2
|
Posted: Wed 09 Dec '09 19:53 Post subject: Apache includes problem - ignoring server name |
|
|
Hi,
I have two sites. I have specified the paths/directory mapping in respective configuration files using VirtualHost(s).
I appended those files with includes to httpd.conf.
Everything works fine - the sites load, I set up PHP correctly, etc. Here's the problem: I include 2 configs (currently and maybe more later,) each one has a separate:
ServerName, Directory, etc.
In ServerName I specify a url that I would use to access the sites locally.
I'm doing this in windows by the way. I added the urls to the appropriate hosts file (C:\WINDOWS\system32\drivers\etc\hosts)
But here is what happens: when I type in the two separate urls they point to a SINGLE site, depending on which config file is included in the httpd.conf first.
So if I have:
fu.loc = site 1
bar.loc = site 2
(urls pointing to a local directory)
and the conf file for bar.loc is included before fu.loc, like such:
include conf/vhosts.d/bar.conf
include conf/vhosts.d/fu.conf
If i go to the browser and type in: fu.loc, it will pint to bar.loc, same thing with bar. If I change the order of the includes in the httpd.conf to:
include conf/vhosts.d/fu.conf
include conf/vhosts.d/bar.conf
both adresses will serve from site fu.
Any ideas of what might be causing this? I've looked through both configs and there is no issue with anything obvious. Lots of other people have this working, but due to differences in installation/set up of appache, I cannot seem to figure out what could cause this or how to fix it.
I'm using version Apache HTTP 2.0.63.
Any advice, including how to possibly trouble shoot this scenario would be helpful.
Please and thank you,
Nik |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
|
Back to top |
|
nikitakv
Joined: 09 Dec 2009 Posts: 2
|
Posted: Thu 10 Dec '09 18:45 Post subject: |
|
|
Thanks glsmith, solved the problem in 2 seconds after reading your posts.
Just to re-iterate the solution, in case someone else stumbles upon this:
For name-based hosting, using VirtualServer in Apache, the FIRST delcaration of <VirtualHost> has to point to DocumentRoot. So in my case for local sites:
#first (default) virtual host
<VirtualHost *:80>
DocumentRoot "C:/server/apache/Apache2/htdocs"
ServerName root.loc
</VirtualHost>
include conf/vhosts.d/fu.conf
include conf/vhosts.d/bar.conf
Where fu.conf and bar.conf would be 2 separate configuration files (in vhosts.d folder in conf) with their own VirtualHost directives and their own DocumentRoot, ServerName, permissions, etc. |
|
Back to top |
|
|
|
|
|
|