So, what I did:
apt-get update apt-get upgrade do-release-upgrade
That got my Ubuntu to be upgraded to 16.04. After that Apache web-server couldn’t start:
apache2: Syntax error on line 13 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory
Having googled it, I discovered that it’s because of missing
libapache2-mod-php5, so I tried to install it:
apt-get install libapache2-mod-php5
But that failed:
Package `libapache2-mod-php5` has no installation candidate
And the reason for that is this module is no longer available in Ubuntu 16.04 repositories, because PHP 5 is considered to be obsolete, apparently. So, you need to add some custom repository that has it.
But first, check, if you have PHP 7 installed in the system:
If it doesn’t show a version but complains instead, then it’s fine. If it does show the version 7.x, then delete it:
apt-get purge php7.*
You also need to disable (and delete) old PHP modules from Apache. Take a look at them:
$ ls -l /etc/apache2/mods-enabled/ ... lrwxrwxrwx 1 root root 34 Apr 19 2016 negotiation.load -> ../mods-available/negotiation.load lrwxrwxrwx 1 root root 27 Apr 19 2016 php5.conf -> ../mods-available/php5.conf lrwxrwxrwx 1 root root 27 Apr 19 2016 php5.load -> ../mods-available/php5.load ...
And disable them:
a2dismod php5 rm /etc/apache2/mods-enabled/php5.*
Okay, now add a new repository that has PHP 5 and install it from there (this should add the corresponding Apache module automatically):
apt-get install python-software-properties add-apt-repository ppa:ondrej/php apt-get update
It can give you that:
Err:4 http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C Reading package lists... Done W: GPG error: http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C E: The repository 'http://ppa.launchpad.net/ondrej/php/ubuntu xenial InRelease' is not signed. N: Updating from such a repository can't be done securely, and is therefore disabled by default. N: See apt-secure(8) manpage for repository creation and user configuration details.
In that case add the key it wants:
$ apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C Executing: /tmp/tmp.4F4cqgAm8F/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com gpg: key E5267A6C: public key "Launchpad PPA for Ond\xc5\x99ej Sur�" imported gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)
Now you can run:
apt-get update apt-get install php5.6
Note, that specifying explicitly
5.6 is important, pay attention here. Check the PHP version after installation (
php -v) and also check new Apache modules:
$ ls -l /etc/apache2/mods-enabled/ ... lrwxrwxrwx 1 root root 34 Apr 19 2016 negotiation.load -> ../mods-available/negotiation.load lrwxrwxrwx 1 root root 29 Jun 7 14:50 php5.6.conf -> ../mods-available/php5.6.conf lrwxrwxrwx 1 root root 29 Jun 7 14:50 php5.6.load -> ../mods-available/php5.6.load ...
Okay, you have the right PHP in the system. Now try to install
libapache2-mod-php5 again, but explicitly specify that it is version
apt-get --reinstall install libapache2-mod-php5.6
Try to restart Apache:
service apache2 restart
Now it should start without problems. However, if you would open your WordPress website, you’ll most probably see this error in browser:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress
Install it and restart Apache again (note the
apt-get install php5.6-mysql service apache2 restart
Refresh the page in browser. Now it actually works, but some images are not displayed. And if you would open any of them in a separate tab, you’ll see the error:
GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library
Install it and restart Apache again (note the
apt-get install php5.6-gd service apache2 restart
Refresh the page - now everything seems to be fine at last.
However, most probably your WordPress plugins are complaining about something, for example like this:
No CURL Found - Social Networks AutoPoster needs the CURL PHP extension
That means PHP extension for cURL has been lost during the upgrade too. You need to install it back (and restart Apache).
apt-get install curl libcurl3 libcurl3-dev php5.6-curl service apache2 restart
Check if it’s there:
$ ls -l /etc/php/5.6/mods-available/ php -i | grep curl
Now you’re all set.