PDA

View Full Version : Howto: WordPress 3.4.2, MySQL and PHP7



Ted Lyngmo
6th September 2017, 12:19 AM
If you've upgraded from Fedora 24 to something newer you may have noticed that the included php version no longer supports MySQL connections. This is troublesome if you are also hosting an old version of WordPress. Here's how I managed to solve that.

Download, build and install the shared library module needed for PHP7 to be able to do MySQL connections:


$ sudo dnf install php-devel
$ git clone https://github.com/php/pecl-database-mysql mysql --recursive
$ cd mysql
$ phpize
$ ./configure
$ make
$ sudo cp modules/mysql.so /usr/lib64/php/modules

Make sure the module is loaded after mysqlnd.so by creating an ini file with a larger number than mysqlnd.so's ini file.

# cat /etc/php.d/99-mysql.ini
; Enable legacy mysql extension module
extension=mysql.so

Add a MySQL entry in /etc/php.ini if it's not already there. Copy your old entry if you've saved the old file or add this:

[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
Restart your webserver:

$ sudo systemctl restart httpd.service

PHP7 should now be able to use MySQL.

If you did this to get an old WordPress installation to work, you now need to watch the webservers error log (/var/log/httpd/error_log). I found that many classes in plugins had overridden base class methods but using an incorrect signature for the methods. I simple copied the signatures from the base classes and put them in the derived classes one by one when seeing them in the error log.

Some plugins also had logic errors that required some thinking, like "continue" or "break" when there was nothing to continue or break from. Older php versions probably just ignored those statements but php7 refuses to execute files with those kinds of errors. All in all, it took an hour to correct the problems in the plugins used.

Br,
Ted

remi
11th September 2017, 08:02 AM
> If you've upgraded from Fedora 24 to something newer you may have noticed that the included php version no longer supports MySQL connections.

If does using the mysqli extension or pdo_mysql PDO driver.

Only the old deprecated mysql extension is deprecated and have been removed.

And Wordpress recent versions use the mysqli extension.

Using a very old wordpress 3 seems terrible strange (and unsecure)

If really needed, for some other legacy application, RPM of the OLD DEPRECATED UNSUPPORTED mysql extension are availalble in my repository: https://rpms.remirepo.net/ (php-pecl-mysql package)

antikythera
11th September 2017, 09:37 AM
thanks remi for contributing to the thread and for your repository. I use it myself for a couple of other packages

Ted Lyngmo
21st September 2017, 10:24 AM
> If you've upgraded from Fedora 24 to something newer you may have noticed that the included php version no longer supports MySQL connections.

If does using the mysqli extension or pdo_mysql PDO driver.

Only the old deprecated mysql extension is deprecated and have been removed.

And Wordpress recent versions use the mysqli extension.

Yes, I read that when trying to solve this myself but I have very limited knowledge about wordpress so I didn't dare trying to upgrade the site. Neither did I know how to make the old wordpress version use one of the new extensions replacing the mysql extension. So, the guide was written specifically for those wanting to get their old wordpress site up and running using the mysql extension.


Using a very old wordpress 3 seems terrible strange (and unsecure)

Perhaps. In my case it's just a matter of letting the old site live for a a little longer until the new hosted one is launched.


If really needed, for some other legacy application, RPM of the OLD DEPRECATED UNSUPPORTED mysql extension are availalble in my repository: https://rpms.remirepo.net/ (php-pecl-mysql package)

Oh, that's nice! Will those work with F25 or F26? I noticed that the mysql.so that I compiled for F25 did not work in F26 so I had to recompile it after the upgrade to F26.

Br,
Ted

remi
22nd September 2017, 11:39 AM
> Oh, that's nice! Will those work with F25 or F26?

Of course.