So today I decided to take on an adventure of updating my WordPress from an ancient 4.x to 5.x.
I did my due diligence of backing up and take a snapshot from DigitalOcean (my VPS service provider) and then started the risky process. The WordPress upgrade itself was relatively smooth with no issues. Little did I know that I was jumping into something more serious…
The first I noticed after the upgrade was the awful new “Gutenberg” visual editor so I immediately switched back to old one using the Classic Editor plugin.
Then I noticed that the AMP plugin was not working as it required php 5.6, but I only had php 5.5. This is where I realized that my Ubuntu 14.04 is really old at this point and has reached its “End of Standard Support” so no php 5.6 for me.
What to do now? Update the Ubuntu 14.04 to the next LTS 16.04 of course. I doubled checked that 16.04 does have php 5.6 (for now) and went ahead with the DO guide on how to do so.
And boom! I was greeted with an error upon upgrading and re-sshing into the machine:
“-bash: cannot create temp file for here-document: Read-only file system”
And sure enough, Cloudflare was starting to give an error page when I tried to access my website.
A quick googling suggests that this issue was due to DO and that opening a support ticket was the best way to do so. So raised a ticket but continued to dig into it. On the upgrade guide, someone mentioned that it seemed to be a kernel issue, so I updated the kernel to the recommended “DigitalOcean GrubLoader v0.2 (20160714)”, but the error is still there.
Turns out that in the same askubuntu page, the second answer was more useful than the most voted one. I just need to get fix some UUID issue with the file system. Here is what I did from my bash history:
1 2 3 4 5 6 7 |
808 cat /etc/fstab 809 sudo fsck / 810 blkid 813 mount -rw -o remount /dev/vda1 / 814 sudo mount -rw -o remount /dev/vda1 / 815 sudo sed s/815063a9-c956-44a6-ab11-05e1d0bb3a58/18254707-08e8-494e-b456-938592928a5e/ -i /etc/fstab 816 sudo fsck / |
Then comes the problem where my apache2 was not starting due to some config issue in /etc/apache2/apache2.conf . After some googling, it seems to be an issue with deprecated php configs – php_flag and php_admin_value, so I went ahead and commented them out:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<DirectoryMatch ^.*/wp-content/uploads/> AllowOverride None # php_flag engine off # php_admin_value engine Off </DirectoryMatch> <Directory /var/www/wp-content/plugins/akismet/> AllowOverride All </Directory> <DirectoryMatch ^.*/wp-content/blogs.dir/> AllowOverride None # php_flag engine off # php_admin_value engine Off </DirectoryMatch> |
The next error that greeted me was on my website (paradite.com), it just rendered the content of /var/www/index.php as the HTTP response:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells WordPress to load the theme. * * @package WordPress */ /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define( 'WP_USE_THEMES', true ); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' ); |
I know I had to do something with php, so I went back to the guide that teaches me how to upgrade php5.5 to php5.6 and installed php5.6 as well as its apache2 modules:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
896 php --version 897 sudo add-apt-repository ppa:ondrej/php 898 sudo apt-get update 899 sudo apt-get purge php5-common # remove and purge old PHP 5.x packages 900 sudo apt-get install libapache2-mod-php5.6 901 sudo a2dismod php5 902 sudo a2enmod php5.6 903 sudo service apache2 restart 904 sudo apt-get install php5.6-mbstring 905 sudo service apache2 restart 906 sudo apt-get install php5.6-gettext 907 sudo apt-get install php5.6-mysql 908 php --version 909 sudo service apache2 restart |
At this stage, my website was telling me “Error Establishing a Database Connection”, an error that I have seen too many times due to mysql service suddenly shutting down. However, this time it is different, no matter how many times I run sudo service mysql restart , it just exits immediately but there is also no error logs in /var/log/mysql/error.log. This got me quite confused for a while until I started checking my mysql pacakge installed on Ubuntu.
This is when I ran apt list --installed and found out that I didn’t have mysql server pacakge installed! Somehow it went missing after upgrading from 14.04 to 16.04. The next step was simple: sudo apt-get install mysql-server and mysql service automatically started and even repaired my old tables (a bit scary to see that this was required)!
At this stage, my WordPress website was finally rendering properly again! Though there were some issues with some WP plugins missing php extensions that was fixed easily:
1 2 3 |
931 sudo apt-get install php5.6-curl 932 sudo apt-get install php5.6-dom 933 sudo service apache2 restart |
And that’s it, welcome to Ubuntu 16.04 and WordPress 5.1.5! Not gonna update it any further for now!