Apache virtual hosts trouble

Associate
Joined
30 Dec 2005
Posts
415
Hey to all!

I'm just trying to reinstall my development web server (wamp), but am having a few problems with virtual hosts. It seems that the structure of the httpd.conf file has altered, and I basically can't get them to work at all...

Right my document root is set to be "D:/Websites". The server name is set to be "localhost:80".

Towards the top of the document I have this:
Code:
Listen 80
Listen 8083

At the bottom I have this:
Code:
NameVirtualHost *:80
NameVirtualHost *:8083

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /www/docs/dummy-host.localhost
    ServerName dummy-host.localhost
    ServerAlias www.dummy-host.localhost
    ErrorLog logs/dummy-host.localhost-error_log
    CustomLog logs/dummy-host.localhost-access_log common
</VirtualHost>

<VirtualHost *:8083>
    ServerAdmin [email protected]
    DocumentRoot "D:/Websites/Route Hiker v2/dev"
    ServerName dummy-host2.localhost
    ErrorLog logs/dummy-host2.localhost-error_log
    CustomLog logs/dummy-host2.localhost-access_log common
</VirtualHost>

However, when I go on http://localhost:8083 I get presented with the page found at D:/Websites...

Has anyone got any ideas as to what i'm doing wrong?

Cheers,
Rich
 
Assuming you want to access it at http://localhost (or http://localhost:80), then change the second code block you posted to the following:
Code:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/Websites/Route Hiker v2/dev"
    ServerName dummy-host2.localhost
    ErrorLog logs/dummy-host2.localhost-error_log
    CustomLog logs/dummy-host2.localhost-access_log common
</VirtualHost>
All you're doing is replacing the virtualhost values for *:80 with the values from the other Virtualhost container.
 
Augmented said:
Assuming you want to access it at http://localhost (or http://localhost:80), then change the second code block you posted to the following:
Code:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:/Websites/Route Hiker v2/dev"
    ServerName dummy-host2.localhost
    ErrorLog logs/dummy-host2.localhost-error_log
    CustomLog logs/dummy-host2.localhost-access_log common
</VirtualHost>
All you're doing is replacing the virtualhost values for *:80 with the values from the other Virtualhost container.

What i'd really like to do is access D:/Websites/Route Hiker v2/dev on the port 8083 because i'm going to have quite a few websites on this machine and I want to put each one on a different port...

I suppose for now I could do as you have suggested and put it on port 80, but in the long run it's not ideal :(

Cheers!
 
You're doing name-based virtual hosts, your server name of 'dummy-host2.localhost' doesnt match 'localhost' so it gives you the global server default.

If you want a different site on each port (why?), don't use name-based virtual hosting (leave out the NameVirtualHost)
 
Ah thanks for that. Explaining about the nam-based virtual hosts really clears a lot of things up for me. However, I still can't get it working :o

I tried the following:

Code:
#NameVirtualHost *:8083
<VirtualHost *:8083>
    ServerAdmin webmaster@localhost:8083
    DocumentRoot "D:/Websites/Route Hiker v2/dev"
    ServerName localhost:8083
    ErrorLog logs/localhost.8083.localhost-error_log
    CustomLog logs/localhost.8083.localhost-access_log common
</VirtualHost>

However, neither worked.

Any ideas?
 
Last edited:
What startup errors are you getting?
If you're not starting from the command-line, then post the last entries in either "logs/localhost.8083.localhost-error_log" or the main Apache error.log/error_log.
 
I can't find the logs/localhost.8083.localhost-error_log log, but the Apache error.log/error_log reports this:

[Mon Mar 05 18:20:05 2007] [notice] Apache/2.2.4 (Win32) PHP/5.2.1 configured -- resuming normal operations
[Mon Mar 05 18:20:05 2007] [notice] Server built: Jan 9 2007 23:17:20
[Mon Mar 05 18:20:05 2007] [notice] Parent: Created child process 2672
[Mon Mar 05 18:20:05 2007] [notice] Child 2672: Child process is running
[Mon Mar 05 18:20:05 2007] [notice] Child 2672: Acquired the start mutex.
[Mon Mar 05 18:20:05 2007] [notice] Child 2672: Starting 250 worker threads.
[Mon Mar 05 18:20:05 2007] [notice] Child 2672: Starting thread to listen on port 8083.
[Mon Mar 05 18:20:05 2007] [notice] Child 2672: Starting thread to listen on port 80.
 
Back
Top Bottom