DigitalOcean: Migrating WordPress Websites from Ubuntu Server 16.04 to 20.04

As you probably know (see the banner above) I am a happy user of DigitalOcean for many years now – I host multiple websites on a single server without any hassle. They don’t get that much traffic – 1000 or so hits a month for this one for example – so I’m happy sticking with the $5 per month offering for now.

Ubuntu 16.04 is reaching end of life!

It’s time for an upgrade! According to the DigitalOcean documentation it is not recommended to upgrade in-place (do-release-upgreade in the terminal)… I tried and stuff broke, so that is good advice. Luckily I have backups enabled for an extra $1 per month only, so restoring the server was a one-click affair. Now I have a new droplet and need to migrate ALL of my sites to it one by one.

Migration Notes:

  1. I followed this excellent tutorial: https://medium.com/@christoph.schmidl/how-to-manually-backup-wordpress-daa43e37a9bd to backup the mysql database and wordpress folder (/var/www/mysite) – but used wget on the new server to fetch the archives directly.
  2. I had to revoke the letsencrypt https certification – https://maximef.com/2020/10/21/how-to-delete-certbot-certificate-by-domain-name-lets-encrypt/ – don’t forget to remove old files left behind
  3. In the DigitalOcean dashboard, point the url to the new droplet
  4. Create new virtual host files and enable in apache (a2enmod sitename.com) – to learn more about using apache virtualhost files to host multiple sites on one server see: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04 – it’s the same for 20.04
  5. I had an issue with the WordPress database but found out that all that’s needed is to match the wordpress wp-config.php information to the mysql database and user info. This tutorial was helpful (if a bit out of date, the procedure for creating a user has changed…) https://www.vultr.com/docs/troubleshooting-wordpress-database-errors
  6. Create new LetsEncrypt https cert – see #2 link, using certbot.
  7. And everything works (hopefully)

Tweaking the server:

I had some issues with the Ubuntu Server being a bit slow sometimes – think I used the one click WordPress install. It seems that there are ways to optimize this – here is a great link to some ideas about this:

  1. Add swap: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04
  2. More settings for swap: https://bitlaunch.io/blog/how-to-create-and-adjust-swap-space-in-ubuntu-20-04/

Now my server is running smoothly, it’s time to migrate this blog. Or have I done it already? I doubt you would notice!

Leave a Reply

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