httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Betts <>
Subject [users@httpd] mysql connect problem on intranet using NameVirtualHost and hosts file
Date Sat, 14 Dec 2002 11:31:36 GMT
I am trying to use NameVirtualHost to allow me to serve several websites accross an intranet.
want to do this because I need to serve them all from the same ip address ... the ip address
pc on a p2p network running the apache server. Using :

Windows 98 running:
  Apache 1.3.12
  PHP    4.0.6
  MySQL  3.23.21-beta 
& windows 2000 & 98 on othe networked PC's

Up untill now I have beeen using ip-based virtual hosts and this works fine if I only want
access the domains on the one server machine, but if I want to access them all via another
p2p pc
I only have one ip address available (the ip address of the apache server pc on the network)

All the mysql db's are accessable if I run directly on the apache server pc if I use ip-based
hosting ... so I know that mysql is setup ok.

I am using the windows Hosts file to point the domain names to the local server, so on each
pc I
have: [url][/url] [url][/url]

Note: is really the ip address of the pc on the P2P network that is running the

When I switch to Name-Based virtual hosting, standard HTML & PHP pages work without problem
all virtual hosts, locally and across the network.

But when I try to connect to a website that has a database e.g.:
$connection = mysql_connect("", "username", "password");

I get the error:
Unable to connect to MySQL server..1045
Access denied for user: '' (Using password: YES)
            ????? sitea ... should be siteb ?????

It appears that mysql always tries to connect to the first site in my hosts file.

If I switch the order of the lines in the hosts file so that siteb is first then restart apache,
mysql & the browser and retry I can access siteb's db correctly (from ...
but now
not sitea's db (from!?!


this is the relevent apache http.conf

    ServerName [url][/url]
    DocumentRoot c:/home/sitea/public_html
    ScriptAlias /cgi-bin/ c:/home/sitea/cgi-bin/
    ServerAdmin [email][/email]
    ErrorLog logs/
    CustomLog logs/ common

    ServerName [url][/url]
    DocumentRoot c:/home/siteb/public_html/merlin
    ScriptAlias /cgi-bin/ c:/home/siteb/cgi-bin/
    ServerAdmin [email][/email]
    ErrorLog logs/
    CustomLog logs/ common

Is there a fix to let mysql use name-based

or does this point to some other boob i've made?

or am I missing something in the network setup that will either allow me to access each domain
using ip-based V.Hosting from another PC on the network ... 

for ip-based I think I need to either :

setup a DNS for this 
... if so do you know of any good (i.e. simple!) guides that could help?

or I could assign multiple ip addresses to the network card and 
then I could attach each name to its own ip address 
... this is messy as unfortunatly the server is a WIn98 PC and it requires a bit of a registry
hack to assign multiple ip addresses to a network card.

Thanks (and sorry for the long posting)


Chris Betts

Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message