Originally published November 23, 2019 @ 11:24 am

This is mostly just a note to self. As I mentioned previously (probably more than once), I very much dislike systemd and will stick with CentOS 6 for as long as possible. Having said that, WordPress dashboard has been nagging me about having to update PHP. So here we go.

I had PHP 5.6w from webtatic repo and now I need to install version 7.1u from the iuscommunity.org repo. The first step, as I’ve learned, should’ve been updating all the WordPress plugins, especially if you haven’t done that in a while. This is what I did for PHP version update:

# your current PHP version
php --version | grep -oP "(?<=^PHP )[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}(?= \(c)"

# as root
/bin/cp -p /etc/php.ini /etc/php.ini_56w
/bin/cp -p /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.conf_56w
yum list installed | grep -i webtatic > installed_php_webtatic.txt
yum -y remove webtatic-release
yum -y install https://centos6.iuscommunity.org/ius-release.rpm
yum -y remove php56w*
yum -y install $(grep ^php installed_php_webtatic.txt | awk -F. '{print $1}' | sed 's/php56w/php71u/g' | xargs)
yum -y install php71u-mysql* php71u-json php71u-fpm pear1u
/bin/cp -pf /etc/php.ini_56w /etc/php.ini 
/bin/cp -pf /etc/php-fpm.d/www.conf_56w /etc/php-fpm.d/www.conf
chkconfig php-fpm on
service php-fpm restart
php -v
service httpd restart

And that did it. It also broke one my older WordPress sites: the `mysql_get_server_info` function has been removed from PHP 7 for security reasons. You can find the plugins that may use this function like so:

# cd ${your_website_home}/wp-content/plugins] && ack "mysql_get_server_info\(\)"

101:            <br/>&middot; mySQL (Server): <?php echo mysql_get_server_info(); ?>

9:                      <td><?php echo $_SERVER['SERVER_SOFTWARE']; ?>, <?php echo $_SERVER['GATEWAY_INTERFACE']; ?>, PHP <?php echo phpversion(); ?>, <?php $link = mysql_connect( DB_HOST, DB_USER, DB_PASSWORD ); if ( !$link ) { die( 'Could not connect: ' . mysql_error() ); } printf( "MySQL %s", mysql_get_server_info() ) ;?></td>

186:                    <br />&middot; mySQL (Server): <?php echo $mysqli ? mysqli_get_server_info( $GLOBALS['wpdb']->dbh ) : mysql_get_server_info(); ?>

128:            $sql_version = substr(mysql_get_server_info(),0,3);

Go through the list, rename the plugin folder, see if that restored access to the site. If not, rename it back and continue until you find the culprit.