You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Chris Betts <ch...@yahoo.co.uk> on 2002/12/14 12:31:36 UTC
[users@httpd] mysql connect problem on intranet using NameVirtualHost and hosts file
I am trying to use NameVirtualHost to allow me to serve several websites accross an intranet. I
want to do this because I need to serve them all from the same ip address ... the ip address of
the
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 to
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:
123.4.5.6 [url]www.sitea.com[/url]
123.4.5.6 [url]www.siteb.com[/url]
etc...
Note: 123.4.5.6 is really the ip address of the pc on the P2P network that is running the apache
server.
When I switch to Name-Based virtual hosting, standard HTML & PHP pages work without problem for
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("www.siteb.com", "username", "password");
I get the error:
Unable to connect to MySQL server..1045
Access denied for user: 'mydbname@sitea.com' (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 www.siteb.com) ... but now
not sitea's db (from www.sitea.com)!?!
~~~~~~~
this is the relevent apache http.conf
NameVirtualHost 123.4.5.6
#--------------------------------------------------------------------
<VirtualHost 123.4.5.6>
ServerName [url]www.sitea.com[/url]
DocumentRoot c:/home/sitea/public_html
ScriptAlias /cgi-bin/ c:/home/sitea/cgi-bin/
ServerAdmin [email]webmaster@sitea.com[/email]
ErrorLog logs/www.sitea.com-error_log
CustomLog logs/www.sitea.com-access_log common
</VirtualHost>
#--------------------------------------------------------------------
<VirtualHost 123.4.5.6>
ServerName [url]www.siteb.com[/url]
DocumentRoot c:/home/siteb/public_html/merlin
ScriptAlias /cgi-bin/ c:/home/siteb/cgi-bin/
ServerAdmin [email]webmaster@siteb.com[/email]
ErrorLog logs/www.siteb.com-error_log
CustomLog logs/www.siteb.com-access_log common
</VirtualHost>
etc...
Is there a fix to let mysql use name-based V.hosting?
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
=====
Chris Betts
chrisbetts@prosolutions.co.uk
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org