Greetings -

First message to the list. I've been happily running a RH 7.3 server for some time, hosting various websites, many of which using PHP-based BBS systems (and the like). However, for various reasons I recently decided to upgrade - to RH Enterprise 3 WS (which I can get via a unit-wide site license for no cost).

I'm having some problems getting PHP, Apache and MySQL to 'play nice'. I'll start with the small stuff.

Step 1)

First, I normally compile PHP (4.3.10) with mysql support builtin, using

 ./configure  --with-apxs2=/wwwroot/bin/apxs  --with-mysql

With my old RH system, this worked absolutely perfectly. But, various things make me suspect things are not quite working on my new system - much of this having to do with where RH has installed mysql. Basically, RH Enterprise WS does not come with the mysql-server, but you can download it from their website and install it from RPM's. OK, fine, did that. Got the mysql server running, gave it a root password, and, in theory, things should be fine.

Step 2)

But, whenever I try even a simple PHP script to connect to the mysql server, I get a socket error - for example, if I run the following, trying to connect to a mysql database called db_test,

//set local variables
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "password-goes-here";
$dbname = "db_test";
$db = mysql_pconnect($dbhost,$dbuser,$dbpass);

I get the following error:

Warning: mysql_pconnect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in sql_test.php on line 10

Step 3)

Weird. I connect to mysql monitor from the command line (which I can do no problem), and check the server status, and find that the socket is NOT in /tmp, but /var/lib:

UNIX socket:            /var/lib/mysql/mysql.sock

So, I'm guessing its not surprising that mysql_connect crashed - it wasn't finding the socket.

OK, so I do a bit of reading, and see that maybe what I should do is explicitly tell PHP where mysql is, during compilation. On this machine, whereis mysql yields

mysql: /usr/bin/mysql /usr/lib/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

OK, so the mysql binary is in /usr/bin, and the library files are in /usr/lib. So, I try a recompile of PHP, using

./configure  --with-apxs2=/wwwroot/bin/apxs  --with-mysql=/usr/lib/mysql

But, this bombs during configure - I get the following error message:

configure: error: Cannot find MySQL header files under /usr/lib/mysql

OK, so I try again, this time using --with-mysql=/usr/bin/mysql - no luck. Same message.

Step 4)

I do some reading. From the PHP man pages, I see

"Also in PHP 4, if you enable MySQL without specifying the path to the MySQL install DIR, PHP will use the bundled MySQL client libraries. "

OK, so, not specifying the directory for mySQL (which I don't seem to be able to do successfully) uses the 'bundled' client libraries.

But (and here's the big step), this doesn't seem to work - since it seems to default to the wrong socket location.


So, how do I either (i) compile PHP (or tweak php.ini) to tell it to look in /var/lib/mysql for the mysql.soc file, or (2) tell mySQL to put the mysql.sock file somewhere else (like, presumably, /tmp, so PHP can find it)?

Thanks - sorry for the long first post, but I wanted to provide full details (which I found for other maillists is a reasonable strategy to minimize the severity of flames :-).

Reply via email to