How to upgrade Digitalocean WordPress Droplet​

How to upgrade Digitalocean WordPress Droplet​

how-to-upgrade-do-wordpress-droplet

Here in this article we will try to understand how we can upgrade a wordpress website launched using the digitalocean wordpress solution from marketplace.

Test Environment

  • Ubuntu 20.04

Procedure

Step1: Ensure Droplet is shutdown

As a first step ensure that you are connected to your ubuntu system and shutdown all the services gracefully using the below command.

$ sudo shutdown -h now

Step2: Create a Snapshot

Before any major upgrade activity with the wordpress application running on the digitalocean droplet, it is recommned to to take a snapshot of the droplet as documented in “How to Create Snapshots of Droplets“.

The time to complete this acitivty depends of the size the hard disk or volume that is being used.

These snapshots can be used to restore a Droplet to the point in time when the snapshot was taken. This can be useful for restoring files that were accidentally deleted or to revert to a known-good Droplet to recover from accidental configuration changes.

Step3: Stop Apache and MySQL services

Here let’s again stop the wordpress services which are Apache HTTP server with backend MySQL database once we have restarted the system after snapshot.

$ sudo systemctl stop apache2.service 
$ sudo systemctl stop mysql.service 

Step4: Update ubuntu os packages with latest

Let’s now update the local package index cache with the latest information from the configured repositories and upgrade installed packages to their latest available versions.

$ sudo apt-get update 
$ sudo apt-get upgrade -y

Once completed with the latest package installation, reboot the system for the changes to take effect.

Step5: Release upgrade

Here is an important step wherein we are upgrading the ubuntu OS from 20.04 to 22.04 with the latest packages insatlled. While the ugprade is being done, you will be asked to keep the current configuration or update them with the latest once, for which you can keep the configuration as the same so it does not break your wordpress website relying on them.

Also, you will be asked if you want to remove the old packages, you can accept it and continue.

$ sudo do-release-upgrade

Once the upgrade is completed successfully and the system is rebooted, you can reconnect to your server ssh terminal and validate the new version is reflecting on the server.

$ sudo cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.5 LTS"

Step6: Disable php7.4 module

Once the upgrade is completed successfully, the old php modules that were installed as a part of the wordpress setup are removed, so you need to disable those module configuration from Apache HTTP server as shown below.

$ sudo a2dismod php7.4
removing dangling symlink /etc/apache2/mods-enabled/php7.4.load
removing dangling symlink /etc/apache2/mods-enabled/php7.4.conf

Step7: Enable php8.1 module

Now we can enable the PHP8.1 modules configuration in Apache HTTP server as shown below and restart the apache2 service.

$ sudo a2enmod php8.1
Considering dependency mpm_prefork for php8.1:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php8.1:
Enabling module php8.1.
To activate the new configuration, you need to run:
  systemctl restart apache2

Step8: Restart Service

Let’s now restart the Apache HTTP server and MySQL service for a fresh startup.

$ sudo systemctl restart apache2
$ sudo systemctl restart mysql

Step9: Validate wordpress website

If everything go smoothly and all of you plugins that are installed within your wordpress website are compatible with the latest version of the OS and PHP package, you should be able to access your website as before.

IMPORTATN: If wordpress website is broken after the upgrade, you can restore your droplet to the known good snapshot version.

Hope you enjoyed reading this article. Thank you..