Update to PHP 7.4 with Redis on Apache2 Ubuntu 16.04/18.04/20.04

PHP 7.4 is recommended to use used by WordPress. In this guide the simple to use commands will be layed out one by one for easy copy and pasting to your Ubuntu VPS/Server.

First update/sync your repositories and make sure you have redis-server and php7.4 installed

sudo apt update
sudo apt install redis-server php7.4

next disable php7.3/php7.2 and enable php7.4 (substitute for your currently used php version)

sudo a2dismod php7.3
sudo a2enmod php7.4

Install common php7.4 modules. You may skip this step if you know exactly what modules you need.

sudo apt install php7.4-dom php7.4-common php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-opcache php7.4-soap php7.4-zip php7.4-intl -y

Install php-redis and enable the module

sudo apt install php-redis
sudo phpenmod -v 7.4 -s ALL redis

restart the apache2 service

sudo service apache2 restart