inicio mail me! sindicaci;ón

“undefined function mysql_connect()” While Migrating Virtualmin

While migrating virtualmin to our shiney new CentOS 5  box, I ran into this error on all our PHP sites:

If I look at php info, it shows –with-mysql, but there is no mysql section farther down. It looked like PHP’s Apache module was having trouble finding the mysql.so file. I immediately thought to check for the php-mysql module (there is no php5-mysql for CentOS 5, I noted) and found it installed:

[root@server apf]# yum install php-mysql
...
Parsing package install arguments
Package php-mysql - 5.1.6-20.el5_2.1.i386 is already installed.
Nothing to do

After a short dive into the php.ini settings, I noted that all the restored sites had this in their php.ini file:

extension_dir=/usr/lib/php5/modules

But that dir doesn’t exist. Connecting the dots, I realized that CentOS 5 has moved all the PHP 5 data to the default. So the dir is now at /usr/lib/php/modules. And this solved the rest:

[root@server lib]# ln -s /usr/lib/php /usr/lib/php5
[root@server lib]# ls -ld /usr/lib/php*
drwxr-xr-x 4 root root 4096 Jul 16  2008 php
lrwxrwxrwx 1 root root    3 Mar 30 21:01 php5 -> php
[root@server lib]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

Yay!

Leave a Comment