It is always awesome when new versions of PHP come out so we can test the performance improvements for WordPress and WooCommerce!
According to these benchmarks PHP 7.4 took around 500 ms of execution time for the same task that PHP 7.2 took over 650 ms to complete!
Remember to test the new PHP 7.4 in a staging environment 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 7.4 on Ubuntu 18.04 and update the CLI path to use the new PHP version.
If you want to install PHP 8.x go here!
Install PHP 7.4 php-fpm on Ubuntu 18.04
Start with adding the repository kindly provided by sury.org
sudo apt-get install apt-transport-https -y
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.listUpdate your package list
sudo apt-get updateInstall the PHP 7.4 packages for nginx and php-fpm functionality
sudo apt-get install php7.4-cli php7.4-curl php7.4-mysql php7.4-fpm php7.4-gd php7.4-xml php7.4-mbstring php7.4-zip php7.4-soap php7.4-dev -yNow we can update the PHP command line binary shorthand php to use the PHP 7.4 CLI binary.
Update CLI to PHP 7.4
Test your current PHP CLI version
php --versionOutput here is showing PHP 7.2!
PHP 7.2.24-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Oct 24 2019 18:28:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend TechnologiesUpdate the PHP CLI shortcut to use the 7.4 binary with this command
sudo update-alternatives --set php /usr/bin/php7.4Now make sure it worked
php --versionOutput is now 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
Remember to configure PHP-FPM for low memory consumption with this guide.
