Upgrade from PHP 7.4 to 8.0

With the latest release of PHP 8.0 in November 2020, it is once again time to begin upgrading your servers to the next PHP version. I’ve outlined the general steps required to do this on an Ubuntu system.

Be sure to review the migration plan and fix any backwards incompatible changes in your applications first before attempting the upgrade.

1. Update your server

sudo apt-get update
sudo apt-get upgrade

2. Prepare your installation

First find out what PHP modules are currently installed on your server so you can install the same ones afterwards.

sudo apt list --installed | grep php

Add the PHP repository.

sudo add-apt-repository ppa:ondrej/php

3. Install

sudo apt-get update apt-get install php8.0

Check the version of PHP installed on the command line interface (CLI).

php -v

Install the PHP 8 versions of the modules that are currently installed in your system. For instance:

sudo apt-get install php8.0-curl php8.0-fpm php8.0-gd php8.0-mbstring php 8.0-mysql php8.0-xml php8.0-zip

4. Post-Install

If you are using PHP FPM, change any version specific references to the PHP 7.4 to PHP 8.0. Restart nginx.

If there are old versions of PHP that you’re not using, you may choose to remove them.

sudo apt-get purge php7.4*

That’s it! Enjoy using your new installation of PHP 8! 😎