Still, on May 2023, it is common for many of the users to continue using WordPress 4.9, PHP 7.2, Ubuntu 16.04LTS etc. There are several reasons behind the fear of not to continue upgrading them. The mentioned versions had breaking changes which forced them to fight for many hours to get back their site working. Additionally, WordPress 4.9 was the last version with the classic editor and classic way of using WordPress. Many of the site owners had hand-coded PHP snippets which required modifications to work with PHP7.2.
At this moment, PHP is at 8.2. It is still a good time to plan to upgrade WordPress to the latest stack. This article explains the method which will help the readers to upgrade to the latest Ubuntu, PHP, MySQL and WordPress without the risk of facing any downtime.
Prepare a Cloud Server to Upgrade Old WordPress to the Latest Version
Spin a cloud server instance on some reliable web host which supports pay-as-you-go billing for their cloud servers, such as Linode or DigitalOcean. Install the server software to set up a LAMP server running the latest version of Ubuntu LTS. If your old server is running PHP 7.2, then install and configure PHP 7.2, PHP 7.4 and PHP 8.x. We recommend upgrading PHP to 7.4 from the older version. You can upgrade to PHP 8.x later.
Consider using the Apache web server, and prefork module (that is what comes as default) for easy switching between PHP versions. On Ubuntu, you can easily switch between the versions of PHP. The below example is for switching from PHP 8.1 to PHP 7.4:
# If using PHP 8.1 as for example
sudo a2dismod php8.1
# point apache to use your desired version
# such as php7.4
sudo a2enmod php7.4
# switch php version
sudo update-alternatives --set php /usr/bin/php7.4
# test configuration for compatibility
# restart apache, it is not reload
sudo systemctl restart apache2
# reboot the server
# check php version
Upgrading the MariaDB version is not complex.
At the time of writing this article, still you can switch from MySQL, and Percona to MariaDB without doing any extra steps. There will be difficulties in the future.
Copy-paste the various settings of your production server (which is running WordPress now) such as Apache virtual hosts, PHP settings, and SSL certificates to the new server.
Disable HSTS, DNSSEC, TLS Dane etc Security Features
Go to the control panel of your DNS server, and decrease the TTL of A name to the minimum (it can be 1 second to 600 seconds as the minimum value). Wait for 1-2 days so that the value gets updated to the whole system across the globe.
If you have security features such as HSTS or DNSSEC or TLS Dane then disable them and wait for a week.
Upgrade WordPress to Version 5.3 on This New Server
You can simply move the backup to this new server and manually upgrade to WordPress 5.3. You’ll get the list of releases here:
If that fails, then your method of the first step of the upgrade will be like server migration. You have to install WordPress against the IP address. Even with HSTS, on this new server, after moving the FTP content and database, you’ll be able to browse the front and posts by IP, for example:
If everything is OK, update the new server’s IP in WordPress settings to your domain name. Thereafter you’ll fail to log in to the new server’s WordPress installation. Now you can switch the IP address from DNS. After 2-3 days, the propagation will complete and you can normally log in.
You should test whether your site is available everywhere on this planet by testing from WebPageTest.ORG, using the Tor browser, and other tools to test TTFB, DNS propagation etc.
Now Upgrade to the Latest WordPress on This New Server From WordPress 5.3
Take a backup. Now, you can automatically update WordPress to version 6.x.