Apache Worker + PHP5 ZTS + MySQL - could not find mysql_connect()

Hi All,

I have a problem with mysql on threaded apache MPM - “worker”

When I turn it on in /etc/sysconfig/httpd
HTTPD=/usr/sbin/httpd.worker
then mysql is not available anymore: Could not find mysql_connect()

With prefork MPM everything is just fine except server load :slight_smile:

I have used yum to install all packages

I think I could recompile apache+php manually but in this case RPM dependencies will be lost.

Could you please advice why mysql is not loaded and how to fix this?

Here is some more info:

Packages installed with yum:
php-5.2.9-2.fc11.x86_64
php-devel-5.2.9-2.fc11.x86_64
php-pear-1.7.2-3.fc11.noarch
php-mysql-5.2.9-2.fc11.x86_64
php-common-5.2.9-2.fc11.x86_64
php-cli-5.2.9-2.fc11.x86_64
php-zts-5.2.9-2.fc11.x86_64
mysql-5.1.37-1.fc11.x86_64
mysql-libs-5.1.37-1.fc11.x86_64
mysql-server-5.1.37-1.fc11.x86_64
mysql-devel-5.1.37-1.fc11.x86_64

OS: Fedora Core 11

List of modules in /usr/lib64/php/modules:
bcmath.so gd.so mbstring.so mysqli.so pdo_mysql.so pdo_sqlite.so sysvmsg.so sysvshm.so wddx.so xmlreader.so xsl.so
dom.so json.so mcrypt.so mysql.so pdo.so posix.so sysvsem.so uploadprogress.so xcache.so xmlwriter.so zip.so

cat /etc/php.d/mysql.ini
; Enable mysql extension module
extension=mysql.so
;zend_extension=mysql.so
;zend_extension_ts=mysql.so

I tried to use the two last lines as well - doesn’t work

Thank you in advance.

LDS,

First, WELCOME to SitePoint’s Apache forum!

Second, I’m not quite geeky enough to be comfortable with Linux (compile? really?).

Third, from the snippet of error information (Could not find mysql_connect()), mysql is NOT your problem. I believe that you MUST check your php configuration as the mysql_ functions have been deprecated in favor of mysqli_ functions. You CAN make either/both available to you by uncommenting both the database modules in PHP’s config file (because they’re NOT available by default).

Regards,

DK

Hi DK,

Thank you for your response!

I have just tried to use mysqli but the problem is the same:
Fatal error: Class ‘mysqli’ not found

Both mysql and mysqli are enabled in /etc/php.d/* and /etc/php.ini

It seems that mysql.so and mysqli.so are just not loaded with /usr/lib64/httpd/modules/libphp5-zts.so
and are available with
/usr/lib64/httpd/modules/libphp5.so

According to the /etc/httpd/conf.d/php.conf libphp5-zts.so is used for worker:
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>

I have found out that libphp5-zts.so uses /etc/php-zts.d which has not existed. I have created it as a link to /etc/php.d but it didn’t help.

Could you pls advice how can somehow debug the process of modules loading in order to understand why they are not loaded?

LDS,

Other than checking the phpinfo() (it will tell you EVERYTHING about your PHP installation), you’ve hit my deficiency: Compiling an installation. IMHO, php.net should have the information you need in their Installation documentation, though.

Regards,

DK

The only solutions that I was able to find was to remove httpd and php packages by yum and install it manually by compiling source files.

When I used packaged httpd-2.2.13 and php 2.2.9 there were also some strange errors like “mysql.so could not be loaded - not such file or directory”, but mysql.so was available and mysql was also available in php. And quire frequently there were apache segfaults.

Now everything works fine - worker (zts) + php with built-in mysql.
No segfaults, no problems with mysql_connect and mysql_pconnect.

Server load is much lower now.

Thank you.

lds,

WHOA! You’ve switched from mysql to mysqli to mysql! Make up your mind!

Okay, look at your equivalent of php.ini and UNcomment the mysql(i) module that you’ve selected (or both).

Regards,

DK