So you log into your DigitalOcean hosted WordPress and see the dreaded yellow “Site Health Status” indicator. On further inspection you learn that your PHP version is now old. Here’s what you need to do to upgrade PHP on your DigitalOcean one-click WordPress Droplet:
Note: Your site will likely be up/down during the upgrade process. If you can’t afford any down time, you might want to create a snapshot of your site and deploy it to another Droplet to perform the upgrade and switch over via IP or DNS when your done.
Backup your WordPress site
- Make a full backup of your WordPress install. I recommend using UpdraftPlus. I have instructions over here.
- In addition to a full backup, I recommend shutting your Droplet off and creating a snapshot using DigitalOcean’s snapshot feature. If something goes wrong, you can always restore your snapshot which is even easier than a rebuilding your site manually and restoring from a backup.
Check your Ubuntu Version
- Log into DigitalOcean and locate your Droplet.
- Click the “Console” link and/or button to connect to the droplet’s command line console.
- Run the command “lsb_release -a” from the console to check the OS version.
- Check the Ubuntu Release cycle here: UbuntuUbuntu release cycle | Ubuntu
- If LTS standard security maintenance has expired for your Ubuntu version, proceed to the next section to upgrade Ubuntu.
Upgrade Ubuntu
Follow the official Ubuntu docs to upgrade your server: Ubuntu ServerHow to upgrade your Ubuntu release
If you are using the ondrej/php PPA to get more recent version of PHP, remove it prior to the upgrade using: “sudo add-apt-repository –remove ppa:ondrej/php”
If you run into trouble, ChatGPT is your friend. Copy and paste any unexpected errors to get contextual based help. One of the Droplets I upgraded had trouble with a couple MySQL packages. After some consultations with ChatGPT I was able to fix the broken packages so I could continue my upgrade.
Upgrade PHP
PHP 8.0 → PHP 8.3 Upgrade Steps (Apache mod_php)
From the Droplet Console:
1. Update package list
sudo apt update
2. Add Ondřej Surý’s PHP repository (if not already present)
sudo apt install -y software-properties-common ca-certificates lsb-release apt-transport-https
sudo add-apt-repository ppa:ondrej/php
sudo apt update
3. Install PHP 8.3 + Apache module
sudo apt install -y libapache2-mod-php8.3 php8.3 php8.3-cli php8.3-common \
php8.3-mysql php8.3-xml php8.3-curl php8.3-mbstring php8.3-zip php8.3-gd php8.3-intl
4. Switch Apache to PHP 8.3
sudo a2dismod php8.0
sudo a2enmod php8.3
sudo systemctl restart apache2
5. Verify PHP version
php -v
You should see something like:
PHP 8.3.24 (cli) ...
6. (Optional) Remove old PHP 8.0 packages
sudo apt purge -y php8.0*
sudo apt autoremove -y
That’s it!
Leave a Reply