Author |
|
dereko
Joined: 14 Jul 2010 Posts: 4 Location: Ireland
|
Posted: Wed 14 Jul '10 18:43 Post subject: Apache 2.2 on Windows Server multiple sites one IP |
|
|
I'm fairly familiar with the workings of apache on Linux.
Enviroment: Hosted VPS (full access)
Windows Server 2003 Datacentre x64 edition, Apache 2.2
I have 2 straight forward websites I want to host.
example1.com and example2.org
This server was originally set up by someone else and example1.com works as expected.
So my task is to add example2.org to the server.
I create a basic index.html test page in C:\www\example2
add a virtual host record to httpd-vhosts.conf
and for test purposes add a 127.0.0.1 example2.org to my hosts file so I can test locally.
This all worked as expected and I can view example2.org which shows my test html file.
The problem is... when the DNS propagated it shows the example1.com site when I go to example2.org from anywhere but the local windows server.
I'm completely baffled as to why this is happening? Any ideas?
At what point does apache read in outside connections differently to local ones?
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example2.org
ServerAlias example2.org
ServerAdmin info@example2.org
DocumentRoot "C:/www/example2"
<Directory "C:/www/example2">
Order Deny,Allow
Allow from all
</Directory>
ErrorLog "logs/example2-error.log"
CustomLog "logs/example2-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerName www.example1.com
ServerAlias www.example1.com
ServerAdmin info@example1.com
DocumentRoot "C:/www/example1"
<Directory "C:/www/example1">
Order Deny,Allow
Allow from all
</Directory>
ErrorLog "logs/example1-error.log"
CustomLog "logs/example1-access.log" common
</VirtualHost>
Above is what I have in my httpd-vhosts.conf file.. bare in mind example1.com works fine. |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Wed 14 Jul '10 19:05 Post subject: |
|
|
make the first vhost a duplicate of the main host in httpd.conf |
|
Back to top |
|
dereko
Joined: 14 Jul 2010 Posts: 4 Location: Ireland
|
Posted: Wed 14 Jul '10 19:07 Post subject: |
|
|
glsmith wrote: | make the first vhost a duplicate of the main host in httpd.conf |
I don't quite follow you. What am I trying to do? |
|
Back to top |
|
glsmith Moderator
Joined: 16 Oct 2007 Posts: 2268 Location: Sun Diego, USA
|
Posted: Wed 14 Jul '10 21:29 Post subject: |
|
|
If in httpd.conf you have say
ServerName www.mydomain.com
DocumentRoot C:/www/htdocs
Then the First listed vhost needs to be a minimal duplicate of it.
<VirtualHost *:80>
DocumentRoot C:/www/htdocs
</VirtualHost>
then add any more below.
<VirtualHost *:80>
ServerName www.site1.com
DocumentRoot C:/www/site1
...
</VirtualHost>
<VirtualHost *:80>
ServerName www.site2.com
DocumentRoot C:/www/site2
...
</VirtualHost>
see the section about "Main host goes away"
http://httpd.apache.org/docs/2.2/vhosts/name-based.html |
|
Back to top |
|
dereko
Joined: 14 Jul 2010 Posts: 4 Location: Ireland
|
Posted: Thu 15 Jul '10 12:32 Post subject: |
|
|
I added the minimal vhost for c:/www to the top of my httpd-vhosts.conf file and restarted apache but still no joy. example2.org is still show the example2.com website.
Is there any way for me to trace how apache reads the config file as a new request comes in? |
|
Back to top |
|
dereko
Joined: 14 Jul 2010 Posts: 4 Location: Ireland
|
Posted: Thu 15 Jul '10 13:01 Post subject: |
|
|
I found the issue, there was more vhosts defined further down and
one was always getting defaulted to. I minimized the file right down
and added back in the stuff and found the problem.
thanks for your help, honed my understanding of apache configs at least. |
|
Back to top |
|