[PHP-DB] semi-newbie | php, mysql RH Enterprise
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; //connect $db = mysql_pconnect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname,$db); ? 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. Finally 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 :-).
Re: [PHP-DB] semi-newbie | php, mysql RH Enterprise
On Saturday 01 January 2005 23:26, Evan Cooch wrote: 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. You need to install the mysql-devel package. 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)? Did you actually look in your php.ini? Because there is an entry there just for this purpose. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* I'm all for computer dating, but I wouldn't want one to marry my sister. */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] semi-newbie | php, mysql RH Enterprise
At 10:52 AM 1/1/2005, Jason Wong wrote: On Saturday 01 January 2005 23:26, Evan Cooch wrote: Thanks for the quick reply. Nice to see I'm not the only one working. :-) ./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. You need to install the mysql-devel package. Hmmm...OK. Why? (just for my understanding). Again, never had this problem with RH7.3... 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)? Did you actually look in your php.ini? Because there is an entry there just for this purpose. I did, and saw several (many!) options related to mySQL, but wasn't sure what to do with them. The one that seems most related to the 'socket' issue is ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. mysql.default_socket = Do I simply change this to mysql.default_socket=/var/lib/mysql Thanks again... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] semi-newbie | php, mysql RH Enterprise
Nice to see I'm not the only one working on Saturday. :-) Some followups embedded below. OK, so I try again, this time using --with-mysql=/usr/bin/mysql - no luck. Same message. You need to install the mysql-devel package. Hmmm...OK. Why? (just for my understanding). Again, never had this problem with RH7.3... 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)? Did you actually look in your php.ini? Because there is an entry there just for this purpose. I did, and saw several (many!) options related to mySQL, but wasn't sure what to do with them. The one that seems most related to the 'socket' issue is ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. mysql.default_socket = Do I simply change this to mysql.default_socket=/var/lib/mysql Thanks again... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] semi-newbie | php, mysql RH Enterprise
On Sunday 02 January 2005 00:14, Evan Cooch wrote: You need to install the mysql-devel package. Hmmm...OK. Why? (just for my understanding). Again, never had this problem with RH7.3... The same situation exists with RH7.3 (and probably most/every version of Red Hat Linux), it's just probably that you never came across it. For reference, under Red Hat, most PHP extensions that you may wish to compile will require that you install the corresponding extension-devel package. I did, and saw several (many!) options related to mySQL, but wasn't sure what to do with them. The one that seems most related to the 'socket' issue is ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. mysql.default_socket = Do I simply change this to mysql.default_socket=/var/lib/mysql That should point to the socket _file_ that is used by RH's implementation of MySQL. Do a locate/find mysqld.sock. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* I'm also pre-POURED pre-MEDITATED and pre-RAPHAELITE!! */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] semi-newbie | php, mysql RH Enterprise
At 11:34 AM 1/1/2005, Jason Wong wrote: On Sunday 02 January 2005 00:14, Evan Cooch wrote: You need to install the mysql-devel package. Hmmm...OK. Why? (just for my understanding). Again, never had this problem with RH7.3... The same situation exists with RH7.3 (and probably most/every version of Red Hat Linux), it's just probably that you never came across it. Probably true - I *think* when you selected mySQL for install under RH 7.3, it installed everything, which is why I never noticed it. Under RH Enterprise, it would seem this is no longer the case. For reference, under Red Hat, most PHP extensions that you may wish to compile will require that you install the corresponding extension-devel package. OK - thanks for the enlightenment! I did, and saw several (many!) options related to mySQL, but wasn't sure what to do with them. The one that seems most related to the 'socket' issue is ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. mysql.default_socket = Do I simply change this to mysql.default_socket=/var/lib/mysql That should point to the socket _file_ that is used by RH's implementation of MySQL. Do a locate/find mysqld.sock. As per a part of my initial (long) posting, its in /var/lib/mysql/mysqld.sock So, do I change the directive in php.ini to mysql.default_socket=/var/lib/mysql/mysqld.sock This would seem to make sense. Thanks again. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] semi-newbie | php, mysql RH Enterprise
OK, so I try again, this time using --with-mysql=/usr/bin/mysql - no luck. Same message. You need to install the mysql-devel package. Actually, turns out it is installed already. So, that suggestion won't take care of the problem. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] semi-newbie | php, mysql RH Enterprise
Jason Wong made several helpful suggestions to my earlier query - alas, non of them have panned out. As per his suggestion, I went into php.ini and changed the default mysql socket to mysql.default_socket =/var/lib/mysql/mysql.sock Then, I rebooted the system, since I'm guessing changes to php.ini aren't dynamic (like everything else that parses a config file isn't). But, this didn't work. Two possible answers: 1) If I read the PHP docs, I learn that mysqli.default_socket string The default socket name to use when connecting to a local database server if no other socket name is specified. The key here is 'if no other socket name is specified'. And therein lies the problem, I think. With mysql support builtin to PHP, the socket name IS specified as /tmp/mysql.sock (according to info.php). But, mysql on RH Enterprise WS doesn't put mysql.sock in /tmp, it puts it in /var/lib/mysql And, I see know obvious way to change this. 2) but, perhaps its simply because changes to php.ini aren't being read. In fact, this might also be the case: when I run info.php, I get the following for the mySQL bits: Active Persistent Links0 Active Links0 Client API version3.23.49 MYSQL_MODULE_TYPEbuiltin MYSQL_SOCKET/tmp/mysql.sock MYSQL_INCLUDEno value MYSQL_LIBS no value mysql.allow_persistent On On mysql.connect_timeout 60 60 mysql.default_host no value no value mysql.default_password no value no value mysql.default_port no value no value mysql.default_socket no value no value mysql.default_user no value no value mysql.max_links Unlimited Unlimited mysql.max_persistent Unlimited Unlimited mysql.trace_mode Off Off So, my change to the default socket isn't being 'read', even after a system reboot. Moreover, when I try changing ANY of these values in the php.ini, none of them are read. I even tried changing some other parameters, such as maximum execution time, and info.php still shows me the same values (i.e., no changes). So, I have a look at the top bits from the info.php output. It tells me that the Configuration File (php.ini) Path is /usr/local/lib. Not /etc. But, copying php.ini from /etc to /usr/local/lib doesn't seem to have done the trick. So, something more fundamental. And (tada) I think its because I have two versions of PHP on the machine. The old one (4.3.2-19ent) that comes with RH Enterprise, and the version I compiled from the PHP 4.3.10 tarball. I can confirm that I have 2 binaries. So, suggestions? I'm total confused by all this. I don't want to use 4.3.2, since its got a number of security issues that were corrected with 4.3.10. Should I simply re-install, but try to make sure PHP is NOT loaded, and then do it manually myself from the tarball? Or is there a way I can get everything to work with the 4.3.10 installation, and ignore the older 4.3.2? Thanks again... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] semi-newbie | php, mysql RH Enterprise
On Sunday 02 January 2005 05:44, Evan Cooch wrote: Jason Wong made several helpful suggestions to my earlier query - alas, non of them have panned out. That's because you have more problems than you know. Basically it mostly boils down to RH putting things in non-default places. As per his suggestion, I went into php.ini and changed the default mysql socket to mysql.default_socket =/var/lib/mysql/mysql.sock Then, I rebooted the system, since I'm guessing changes to php.ini aren't dynamic (like everything else that parses a config file isn't). Hmm, I see you're used to the Windows philosphy of rebooting everytime you move your mouse so that the changes can take effect. All you need do is restart Apache. But, this didn't work. Two possible answers: [snip] 2) but, perhaps its simply because changes to php.ini aren't being read. That explains why your changes to mysql.default_socket have no effect. In fact, this might also be the case: when I run info.php, I get the following for the mySQL bits: Active Persistent Links0 Active Links0 Client API version3.23.49 MYSQL_MODULE_TYPEbuiltin MYSQL_SOCKET/tmp/mysql.sock MYSQL_INCLUDEno value MYSQL_LIBS no value So, I have a look at the top bits from the info.php output. It tells me that the Configuration File (php.ini) Path is /usr/local/lib. Not /etc. But, copying php.ini from /etc to /usr/local/lib doesn't seem to have done the trick. The output from phpinfo() will give the definitive location for where PHP expects to find its php.ini. Did you restart webserver? Search php-general archives for more info about php.ini. So, something more fundamental. And (tada) I think its because I have two versions of PHP on the machine. The old one (4.3.2-19ent) that comes with RH Enterprise, and the version I compiled from the PHP 4.3.10 tarball. I can confirm that I have 2 binaries. So, suggestions? I'm total confused by all this. I don't want to use 4.3.2, since its got a number of security issues that were corrected with 4.3.10. Should I simply re-install, but try to make sure PHP is NOT loaded, and then do it manually myself from the tarball? Or is there a way I can get everything to work with the 4.3.10 installation, and ignore the older 4.3.2? Although not strictly necessary it is however strongly recommended that you do remove RH's PHP, and if you're feeling brave I suggest removing Apache too and install both from source, just follow the instructions in manual. And while you're at it you might as well ditch RH's MySQL and install MySQL's own RPMs. That way you can keep on top of all the updates that RH7.3 won't be having. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* Using words to describe magic is like using a screwdriver to cut roast beef. -- Tom Robbins */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] semi-newbie | php, mysql RH Enterprise
On Sunday 02 January 2005 04:55, Evan Cooch wrote: OK, so I try again, this time using --with-mysql=/usr/bin/mysql - no luck. Same message. You need to install the mysql-devel package. Actually, turns out it is installed already. So, that suggestion won't take care of the problem. You're specifying the incorrect directory, it needs to point to the _header_ files which in the case of RH is simply --with-mysql=/usr [Bonus tip, most extensions which needs a library will most likely be specified in the same way, ie /usr] NB no matter which MySQL library you use (whether the PHP-bundled one or the MySQL one) it will have no bearing on your socket problem. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db -- /* I WILL NOT TEASE FATTY I WILL NOT TEASE FATTY I WILL NOT TEASE FATTY I WILL NOT TEASE FATTY Bart Simpson on chalkboard in episode 5F05 */ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php