Upgrading DigitalOcean Ubuntu Droplet from 20.04 to 22.04

The problem

Recently I found out that PHP 7.4 is going to reach End Of Life at the end of November, 2022. This was an unfortunate situation considering I have several websites running on a couple of Ubuntu Server 20.04 DigitalOcean Droplets. It’s unfortunate because I found out that the only supported version of PHP for Ubuntu Server 20.04 is the soon to be obsolete version 7.4.

The Solution

There are two ways to do this – upgrade PHP via a PPA on Ubuntu 20.04, or upgrade Ubuntu to 22.04. I already upgraded my desktop without any issues, so I went with the latter option.

I will outline the procedure I used below. It went without a hitch, apart from having to do it twice due to a broken WordPress plug-in. I am embarrassed to admit that the plug-in was my own creation (in my defense I am not a PHP developer)

  1. Check all WordPress plug-ins for compatibility with PHP 8.1
  2. Create a snapshot of the Droplet
  3. Use the snapshot to create a new Droplet with the same specs as the old one.
  4. Power on the new server, login and proceed to upgrade to 22.04. I used screen to keep the upgrade process alive in case of ssh dropout.
  5. Once this process is completed, you still need to switch the version of PHP that Apache is using (I’m not sure if this is necessary for Nginx). It was something like:
    sudo a2dismod php7.4
    sudo a2enmod php8.1
    sudo service apache2 restart
  6. In the control panel, switch over your website’s DNS to point to the new domain. Depending on TTL this can take a while to propagate – I did mine one at a time and checked them with the ping command.
    ping circusscientist.com – returns the IP address
  7. If anything went wrong, it’s easy to switch back to the old 20.04, so I left that running for a few days. Worpress.org has some great articles here and here which I sometimes use to help with troubleshooting
  8. Finally, switch off the old 20.04 server and remember to delete it (keep the snapshot, though, just in case!)

Leave a Reply

Your email address will not be published. Required fields are marked *