Upgrading My Old Version of WordPress Site
This blog was first built in 2015 using WordPress Version 4.3.1 and runs on Ubuntu 14.04 LTS VPS at Atlantic.Net. The server specification was the lowest available: 1vCPU, 256MB RAM, 10GB SSD, and cost 1.0 USD per month. Overtime the WordPress was upgraded to Version 4.9.20 but the Ubuntu stayed on 14.04 even when it reached its official end-of-life in April 2019. Simply because “if it ain’t broke, don’t fix it”, I didn’t have the urge to upgrade the Ubuntu. Upgrading the OS version needs more effort than the convenient WordPress’s ‘One-click Update’. By the way, later on, Ubuntu 14.04 end-of-life was extended to April 2024, an additional 5 years though.
I only started to consider upgrading the Ubuntu version after getting a security notification on the PHP version that is being used. Basically, the PHP version needs to be upgraded to a minimum version of 7.4. Because of many dependencies, it is easier to use Ubuntu 20.04 that comes with PHP 7.4 package rather than upgrade to PHP 7.4 on Ubuntu 14.04.
I researched the ways to copy and upgrade a WordPress site to a new server. I don’t want to upgrade in-place the existing server because of its low specification and for fall-back purposes. The common method seems to install the latest WordPress on a fresh Ubuntu 20.04 server and then copy over the content of the WordPress directory and database. It is indeed that simple if your site contains only WordPress without many add-ons or customization. However, if your site has several customization and additional tools then it will be not that simple anymore. I found it is easier to clone the existing server using the snapshot backup tool commonly available with VPS or Cloud providers.
Once I have the new cloned server, I can upgrade the Ubuntu, WordPress, and other tools that I have without re-installing them from scratch. Again the reason that I needed to create a cloned server was that I needed a bigger server specification, Atlantic.Net no longer provides 1.0 USD per month VPS ;-). If my existing server is big enough then I could do an upgrade in place without creating a new clone server and use the snapshot backup just for fall-back restoration only.
These are the steps that I used to upgrade this WordPress site:
- Create a snapshot backup of the existing Ubuntu 14.04 server.
- Create a new cloned Ubuntu 14.04 server from the snapshot backup.
- Switch DNS to point to the new server IP address so that my WordPress site is online on the new Ubuntu 14.04 server. I could turn off the old server and uses it as a backup server just in case.
- The new server has bigger specifications: 1vCPU, 1GB RAM, 25GB SSD
- The disk is bigger but the snapshot only creates the filesystem as the old server. To expand the filesystem to fully utilize the disk size:
sudo resize2fs /dev/sda1
- The RAM is also bigger so the /swapfile needs to be enlarged accordingly
- The disk is bigger but the snapshot only creates the filesystem as the old server. To expand the filesystem to fully utilize the disk size:
- Upgrade Ubuntu 14.04 to 16.04
sudo apt update && sudo apt upgrade
sudo apt install update-manager-core
sudo do-release-upgrade
sudo reboot
sudo apt update && sudo apt upgrade
sudo apt autoremove
- WordPress’s ‘One-click Update’ was implemented differently in the old version of WordPress
- Old WordPress used FTP so needs to define several FTP parameters and credentials in the wp-config.php whereas new WordPress just needs to add
define('FS_METHOD','direct');
- Old WordPress didn’t recommend that the WordPress directory and files are owned by Apache’s user and group. It doesn’t matter for new WordPress:
sudo chown -R www-data:www-data /var/www/html/
- Old WordPress used FTP so needs to define several FTP parameters and credentials in the wp-config.php whereas new WordPress just needs to add
- Upgrade the WordPress version using the ‘One-click Update’
- Upgrade Ubuntu 16.04 to 18.04
sudo apt update && sudo apt upgrade
sudo do-release-upgrade
sudo reboot
sudo apt update && sudo apt upgrade
sudo apt autoremove
- Upgrade Ubuntu 18.04 to 20.04
sudo apt update && sudo apt upgrade
sudo do-release-upgrade
sudo reboot
sudo apt update && sudo apt upgrade
sudo apt dist-upgrade
sudo apt autoremove
- Upgrade the WordPress version using the ‘One-click Update’ again to get the latest version on Ubuntu 20.04.
For your information, you can not upgrade from Ubuntu 14.04 to 20.04 directly. You have to upgrade the LTS version to the next LTS version.
My blog now runs on the latest WordPress 5.9.3.
It shocks me that this blog is still updating!