Install PHP 8.0 FPM on Ubuntu 18.04 for WordPress

The PHP 8 benchmarks are looking really sexy! More performance improvements are always welcome over PHP 7.4 🙂

Check out this in-depth list of the new PHP 8 features.

Remember to test the new PHP 8.0 in a staging environment for your WordPress or WooCommerce site first, ideally on a separate server. If you need help testing this feel free to get in touch.

This tutorial will show you how to install PHP 8.0 on Ubuntu 18.04 and update the CLI path to use the new PHP version.

Install PHP 8.0 php-fpm on Ubuntu 18.04

Start with adding the repository kindly provided by

sudo apt-get install apt-transport-https -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg
echo "deb stretch main" | sudo tee /etc/apt/sources.list.d/php.list

Update your package list

sudo apt-get update

Install the PHP 8.0 packages for nginx and php-fpm functionality

sudo apt-get install php8.0-cli php8.0-curl php8.0-mysql php8.0-fpm php8.0-gd php8.0-xml php8.0-mbstring php8.0-zip php8.0-soap php8.0-dev -y

Now we can update the PHP command line binary shorthand php to use the PHP 8.0 CLI binary.

Update PHP CLI to 8.0

Test your current PHP CLI version with this command

php --version

Output here is showing PHP 7.4!

PHP 7.4.13 (cli) (built: Nov 28 2020 06:24:43) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies

Update the CLI shortcut to use the 8.0 binary with this command

sudo update-alternatives --set php /usr/bin/php8.0

Now make sure it worked

php --version

Output is now showing PHP 8.0 🙂

PHP 8.0.0 (cli) (built: Nov 27 2020 12:26:05) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies

Remember to configure PHP-FPM for low memory consumption with this guide.