Ubuntu 20.04 will stop receiving security updates from Ubuntu in April 2025.
Operating system upgrades are risky. If the upgrade fails, your server will become unusable. It is often better to migrate your apps to a new server running the latest version of Ubuntu.
It is critical that you take a snapshot of your server before upgrading Ubuntu.
You can take a snapshot of your server through your server provider's control panel.
Once you've taken a snapshot of your server, SSH in to your server as root and run the following command to make sure your server is ready to be upgraded to a new version of Ubuntu.
sudo apt-get update && sudo apt-get -y dist-upgrade && sudo dpkg --configure -a
If the above command fails or prints an error message, do not proceed with upgrading.
Once all packages have been updated, reboot your server by running this command:
sudo reboot
PHP versions below PHP 7.4 are not available on Ubuntu 22.04. If any apps are using PHP versions below PHP 7.4, you must switch them to using PHP 7.4 or any higher PHP version before proceeding with the upgrade.
Make sure no apps on the server are using a PHP version below PHP 7.4. For each app, go to the app's "Settings" page in ServerPilot and verify the app is using PHP 7.4 or greater. For any app using a PHP version below PHP 7.4, change the app to use PHP 7.4 and then verify the app still works correctly. If the app is not working on PHP 7.4, do not upgrade Ubuntu until the app's code is fixed to support at least PHP 7.4.
Uninstall all PHP packages by running the following command as root:
sudo apt-get -y remove 'sp-php*'
To upgrade your server from Ubuntu 20.04 to Ubuntu 22.04, SSH in to your server as root and run the following command:
sudo do-release-upgrade -f DistUpgradeViewNonInteractive
If you encounter problems or the upgrade fails, take screenshots of any errors and then restore your server to the snapshot you made before you began the upgrade. Once your server has been restored from a working snapshot, please contact support and provide us the details of the errors.
Once the upgrade is complete, reboot your server by running the following command:
sudo reboot
Run the following command to update the package manager's configuration for ServerPilot's repositories:
sudo bash -c "echo 'deb [signed-by=/usr/share/keyrings/serverpilot.gpg] https://download.serverpilot.io/ubuntu jammy main' > /etc/apt/sources.list.d/serverpilot.list"
You can verify the file is correct by running the following command:
sudo cat /etc/apt/sources.list.d/serverpilot.list
You should see the following output from the above command:
deb [signed-by=/usr/share/keyrings/serverpilot.gpg] https://download.serverpilot.io/ubuntu jammy main
Next, update the package manager's list of available packages by running this command:
sudo apt-get update
Then run the following command to install any package updates that are now available:
sudo apt-get -y dist-upgrade
Install the versions of PHP that are supported on Ubuntu 22.04 by running the following command
sudo apt-get -y install sp-php7.4 sp-php8.0 sp-php8.1 sp-php8.2 sp-php8.3
After you install these PHP packages, if you do not see any of these PHP versions available in ServerPilot when choosing the PHP version for apps on this server (that is, when editing an app's PHP version on the app's "Settings" page), please contact support so we can enable the missing PHP versions for you.
Update the version of PHP used for the PHP-CLI (the "php" command) by running the following command as root:
sudo dpkg-reconfigure sp-php-cli
Select the version of PHP you'd like to be the default for the "php" command.
Regardless of which PHP version you chose as the CLI default, you can access any PHP-CLI version by using a version-specific "php" command.
If you've previously installed any PECL extensions on your server, you should now recompile them. See how to recompile PECL extensions.
As the final step, take a snapshot of your server now that the upgrade is complete. All of your existing snapshots are for an older version of Ubuntu. If you needed to restore your server and used one of those older snapshots, you would have to perform the upgrade again.