PHP 5.3.13 / mysqlnd

Support/Development for PHP
rockhopper79
New Forum User
New Forum User
Posts: 2
Joined: Fri May 25, 2012 8:28 am
Location: UK

PHP 5.3.13 / mysqlnd

Unread post by rockhopper79 »

Hi

Currently running Plesk 9.5.4 on CentOS 5.8 - had swapped over to Atomic's PHP 5.3.6 / MySQL 5.1 and now trying to yum update to Atomics PHP 5.3.13 / MySQL 5.5.

The update goes throught fine, confirmed the upgrades and Plesk continues to function as expected - the one implication that I noted from the PHP release notes / documentation was that in 5.3 'mysqlnd' is an option as opposed to 'libmysql' and in 5.4 'mysqlnd' is default.

If i run 'php -i' or phpinfo() from a script on the command line I note the following in the ./configure command:

'--enable-mysqlnd=shared' '--with-mysql=shared,mysqlnd' '--with-mysqli=shared,mysqlnd'

...so it seems that 'mysqlnd' is enabled with this version *BUT* if I run phpinfo() from within a PHP script in a virtual site via a browser I still see:

'--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/lib/mysql/mysql_config' '--with-pdo-mysql=shared,/usr/lib/mysql/mysql_config'

The phpinfo() results in the browser version do show that it is using 5.3.13 and I can make a change in /etc/php.ini that is reflected in phpinfo results but I don't understand why the configure options are different.

This does have an implication for me as some clients are connecting back to pre-MySQL 4.1 databases which is an issue for 'mysqlnd' due to the password hash lengths.

Can anybody explain why I see different configured options and would the web scripts actually be using 'mysqlnd' or still 'libmysql'?

Many thanks in advance!
Rob
scott
Atomicorp Staff - Site Admin
Atomicorp Staff - Site Admin
Posts: 8355
Joined: Wed Dec 31, 1969 8:00 pm
Location: earth
Contact:

Re: PHP 5.3.13 / mysqlnd

Unread post by scott »

Well for starters you shouldnt rely on phpinfo(), it hasnt been relevant for a long time. Using it is just going to confuse you. Best way to look at the way its built is from the spec file, which you'll find under the sources/ dir on any of the mirrors
rockhopper79
New Forum User
New Forum User
Posts: 2
Joined: Fri May 25, 2012 8:28 am
Location: UK

Re: PHP 5.3.13 / mysqlnd

Unread post by rockhopper79 »

Thank you for taking the time to reply Scott... I was surprised by your comment about phpinfo(), I always took that as gospel.

I am far from an expert on PHP's inner workings or how RPM's are compiled / built but for the benefit of anyone else who stumbles across this post with a similar question - here is what I found... I am NOT saying this is 100% accurate but it is the conclusion I am came to.

With Atomic's PHP 5.3.13 installed on a Plesk 9.5.4 server with the default php.ini and the virtual site configured to use PHP as an 'Apache module' (default) in the 'Web Hosting Settings' section of the Plesk GUI = the PHP files in the virtual site will not use 'mysqlnd', they will still use 'libmysql' as they did before.

To figure this out I started at the top - what is Apache told to use for .php files?

/etc/httpd/conf/httpd.conf = "AddType application/x-httpd-php .php" (Doesn't really help)
/etc/httpd/conf/httpd.conf = "/Include conf.d/*.conf" (Load the additional .conf files from /etc/httpd/conf.d)

Here we have the file /etc/httpd/conf.d/php.conf which includes:

Code: Select all

<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>
So we need to know if Apache is configured to run as 'prefork' or 'worker' MPM, to find out you run 'httpd -l' and you should see either 'prefork.c' or 'worker.c', in Plesk's case Apache is compiled to run as prefork so based on the conditional above Apache is loading the /etc/httpd/modules/libphp5.so module.

If you run the phpinfo() command from a PHP script on your virtual site you will see in the list of loaded modules under 'Configuration' we have got 'mod_php5' loaded, that refers to the module described above.

So where did that libphp5.so file come from - I figured it came from the PHP installation and noted that the modify date on the file was the same as when I updated PHP, you can't view the contents of that file because it's a library / shared object file (created during during the PHP build process).

So I ran that file through 'strings' to see if there was any mention of 'mysql' (>strings libphp5.so|grep mysql) and that actually returns the 'Configure Command' line that we see in the phpinfo() results.

It was at this point I realised that what I was seeing when running 'php -i' from the command line was not completely relevant as that is running from the CLI PHP executable /usr/bin/php, if you run that file through strings and grep for mysql it returns the 'Configure Command' that we see from running 'php -i' on the command line.

To further confirm what I was thinking I took Scott's advice and downloaded / unpacked the source RPM:

wget http://www2.atomicorp.com/channels/sour ... rt.src.rpm
rpm2cpio php-5.3.13-5.art.src.rpm | cpio -idmv --no-absolute-filenames

I opened php-art.spec and started going through that, this further confirmed that the build process creates separate shared object files (.so) with different configure options that are used to run PHP in it's various forms (i.e. command line, apache module as prefork or worker etc).

So in CONCLUSION (in this case) command line PHP = 'mysqlnd' and PHP run as an Apache module = 'libmysql'

Just for reference - to further test for mysqlnd you can check if the function 'mysqli_fetch_all' exists, this is only available when PHP is compiled with mysqlnd as per:

http://php.net/manual/en/mysqli-result.fetch-all.php

This is probably useless ramblings to most people but I had to write it up for my own notes anyway and you never know so....

Thanks
Rob
dayo
Forum Regular
Forum Regular
Posts: 158
Joined: Sun Jul 12, 2009 1:33 pm

Re: PHP 5.3.13 / mysqlnd

Unread post by dayo »

Did you try running phpinfo from the command line to see what it gives?
breun
Long Time Forum Regular
Long Time Forum Regular
Posts: 2813
Joined: Sat Aug 20, 2005 9:30 am
Location: The Netherlands

Re: PHP 5.3.13 / mysqlnd

Unread post by breun »

ART's PHP build builds php-mysql and php-mysqlnd as separate modules, MySQL support is not compiled into mod_php. You'll either have the php-mysql package or the php-mysqlnd package installed (they should conflict with eachother, so you should never have both installed).

So the easiest check in this is case is running rpm -q php-mysql php-mysqlnd. Unless you specifically installed php-mysqlnd (and removed php-mysql) you'll be using the old skool php-mysql, which is compatible with the old MySQL auth.
Lemonbit Internet Dedicated Server Management
Post Reply