Setting up PHP 5.6 on GridPane

DISCLAIMER

The following commands change how your GridPane server functions. This may void any support provide by GridPane, use at your own discretion. If you contact GridPane support, inform them that you made these changes.

This article will go over how to set up PHP 5.6 on a GridPane server.

Why?

You might be asking why would you want to install PHP 5.6? It’s slow, slowly being phased out of WordPress as a minimum supported version.

My main reasoning is migrations and upgrades. I’ve had to upgrade sites on WordPress 3.5.1 to 5.3.2 and I needed to do this within a staging environment.

I could simply install a custom LAMP stack with PHP5.6, and do everything manually. But why when I pay for GridPane?

Step 1 – Install the required packages

onYou will need to install the required PHP 5.6 packages for Ubuntu 18, which unfortunately aren’t shipped or available on the Ubuntu mirrors. But let’s just add a PPA (personal package archive). There is a rather popular one by ondrej and is rather easy to use. Let’s go!

sudo add-apt-repository ppa:ondrej/ppa

Shell

Step 2 – Copy FPM config and modify

Now that we have all the PHP 5.6 bits, we just need to configure the PHP 5.6 php-fpm daemon with an appropriate pool.

We’ll take the configuration from an already active website that is configured, in this instance, wpinfo.net is the site and it’s has PHP 7.2 enabled. So just copy the configuration to the php-fpm 5.6 directory pool.

Shell

Now we should modify the configuration otherwise if we try and restart php-5.6-fpm service it will error stating that the socket for this new configuration is already in use. Which is true because we just copied the configuration.

Shell

Restart the php5.6-fpm service to take the new configuration.

Shell

You shouldn’t receive an error if everything was done correctly after running the above command. However, double-check php5.6-fpm process is running correctly by using the following commands.

Shell

Step 3 – Modify NGiNX

No we just need to modify the NGiNX configuration to use the new socket for PHP5.6

Shell

Then test NGiNX

Shell

If all is good then do a configuration reload on NGiNX.

Shell

You should then be able to go to the site in question and see that it’s running PHP 5.6. To confirm, run the following command in the document root to create a PHP information page.

Shell

Step 4 – Change MySQL/Percona Server Charset

Unfortunately, MySQL/Maria/Percona 8.x change the default charset used. This breaks PHP 5.6 code. https://severalnines.com/database-blog/how-run-php-5-applications-mysql-80-centos-7

So we need to change the default charset. Add the following to /etc/mysql/mysql.conf.d/mysqld.cnf below [mysqld]

Shell

Then restart mysqld

Shell

Step 5 – Jeff Cleverly’s Additions

Jeff the CTO at GridPane kindly provided some additional configuration files you’ll need if you enable specific options after the initial site deploy.

Everything here is perfect if you follow things immediately after site build, which is of course the most common use case for anything like this, but for anyone who is wanting to perhaps do something like this after some settings have been adjusted here are the updated commands as per state.

(This will be more useful in an upcoming update when users will be able to specify various initial builds or even a preferred default. I also mention them, because during internal switching of functions I can’t guarantee the system won’t freak when it doesn’t find 7.x and lead to incomplete configurations changeovers.)

The /etc/nginx/common/{site.url}-wpcommon.conf will be common to all caching/firewall settings but the other files and adjusted commands are as follows.

No server page caching w/out ModSec

Shell

FastCGI Page Caching w/out Modsec

Shell

Redis Page Caching w/Modsec and HTTPS

Shell

Redis Page Caching w/Modsec and no HTTPS

Shell

No server page caching w/Modsec and HTTPS

Shell

No server page caching w/Modsec and no HTTPS

Shell

FastCGI Caching w/Modsec and HTTPS

Shell

FastCGI Caching w/Modsec and no HTTPS

Shell
0 Shares:
You May Also Like