PDA

View Full Version : PHP not getting along with MySQL


Keeper
2005-12-03, 09:34 AM CST
I'm wondering if I could get help to my problem here. Our domain recently moved to a FC2 virtual dedicated server, initially we asked them to pre-install MySQL 4.1 instead of the usual 3.23. However, PHP 4.3.11 does not seem to have working MySQL support even though it was reconfigured with "--with-mysql=shared,/usr".

All php pages that contains sql-functions appears as blank, as does their sourecode. All applications, such as phpMyAdmin, wiki and fresh install of discussion forums are all complaining about missing MySQL support in PHP.

I have quoted configure command below, perhaps someone here can spot the problem.

'./configure' '--host=i686-redhat-linux-gnu' '--build=i686-redhat-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--enable-force-cgi-redirect' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--with-db4=/usr' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' '--with-expat-dir=/usr' '--with-dom=shared,/usr' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-xmlrpc=shared' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-pear=/usr/share/pear' '--with-imap=shared' '--with-imap-ssl' '--with-kerberos' '--with-ldap=shared' '--with-mysql=shared,/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-bcmath' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mcal' '--enable-mbstring=shared' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-pic' '--with-apxs2=/usr/sbin/apxs'


PHPInfo is not outputting "mysql" and "mysqli" information tables either.
I'm not experienced linux user, so if you know how to fix this problem, step-by-step instructions would be much appreciated. Thank you for any help, much appreciated.

LLS
2005-12-03, 11:20 AM CST
First find all of your php related files
rpm -ql php
and look for php.d and it should contain two file mysqli.ini and mysql.ini that should contain this
; Enable mysql extension module
extension=mysql.so
; Enable mysql extension module
extension=mysql.so
If php.d is not there, there should be a place in php.ini that allows for dynamic extensions to be enabled.
Some forums just say to as root yum -y install php-mysql
or download the php-mysql rpm and as root rpm -Uvh php-mysql.xxx
I hope this helps.

Keeper
2005-12-03, 12:59 PM CST
Thanks for your reply.

I found mysql.ini from /etc/php.d and it had the two lines. There was no mysqli.ini as PHP does not seem to be configured with mysqli, I'm not sure what mysqli is required for exactly.

php-mysql is installed and is the latest version available for FC2.

Keeper
2005-12-04, 12:45 AM CST
I think our problems are caused by missing --with-mysqli configuration option. Since PHP was pre-installed, unfortunately I am unsure as in what folder I should run the configure command again. I have assumed it would be /etc/httpd, is this correct?

According to this (http://php.net/mysqli), mysqli is required when running MySQL 4.1.

Keeper
2005-12-04, 01:50 AM CST
This is just unbelievable, we just installed PHP 4.4.1 with mysql and with mysqli, checked that /etc/php.d/mysql.ini and mysqli.ini files exists and have uncommented the second line. But PHP still does not have working MySQL support. MySQL server works fine though as we can access it through webmin and any non-php client. Also, php-mysql was already installed before we updated PHP. We're pretty stumped here.

Keeper
2005-12-04, 10:33 PM CST
I was advised to run php -m and see if there are errors, this was outputted.

PHP Warning: Unknown(): Unable to load dynamic library './domxml.so' - ./domxml .so: cannot open shared object file: No such file or directory in Unknown on lin e 0
PHP Warning: Unknown(): Unable to load dynamic library './imap.so' - ./imap.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: Unknown(): Unable to load dynamic library './ldap.so' - ./ldap.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: Unknown(): Unable to load dynamic library './mbstring.so' - ./mbst ring.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: Unknown(): Unable to load dynamic library './mysql.so' - ./mysql.s o: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: Unknown(): Unable to load dynamic library './mysqli.so' - ./mysqli .so: cannot open shared object file: No such file or directory in Unknown on lin e 0
PHP Warning: Unknown(): Unable to load dynamic library './odbc.so' - ./odbc.so: cannot open shared object file: No such file or directory in Unknown on line 0




Edit: Changed extension_dir in php.ini to /usr/lib/php4 and that fixed most of the errors, but these remains:

PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib/php4/mysql.so' - libmysqlclient.so.10: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: Unknown(): Unable to load dynamic library '/usr/lib/php4/mysqli.so' - /usr/lib/php4/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0



Edit 2: Found libmysqlclient.so in /usr/lib but its not working if I copy it to libmysqlclient.so.10. Only getting a lot PHP/MySQL errors when outputting php -m. I installed PHP 4.4.1 from source, should I also try to reinstall MySQL 4.1.15 from source? MySQL was installed from rpms.


Edit 3: OK, I finally got PHP working with MySQL after installing MySQL-shared-compat, but now PHP thinks I have MySQL 3.23 installed even though it has never been installed. PHPInfo is displaying mysql information but no mysqli. PHP based applications that use MySQL still are not working correctly, they all have authentication failures. php -m now outputs lots of MySQL related errors.

LLS
2005-12-05, 10:10 AM CST
Check the PHP and mySQL sections here, maybe it can help remedy your problem.
http://www.lamphowto.com/lamp.htm
http://forums.fedoraforum.org/showthread.php?t=45216

Keeper
2005-12-05, 10:13 AM CST
Thanks, I think we'll end up reinstalling Apache, PHP and MySQL in any case, so the LAMP guide should come in handy.