How To Install PHP 7.4 on Debian 10 / Debian 9

Share Now

====MAIN METHOD======

Step 1. Check PHP version

php -v

-> output

PHP 7.0.33-0+deb9u8 (cli) (built: Jul 5 2020 06:34:50) ( NTS ) 
Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies 
with Zend OPcache v7.0.33-0+deb9u8, Copyright (c) 1999-2017, by Zend Technologies 

Step 2. Update System

apt update && apt upgrade

Maybe you will also need to reboot Debian.

Step 3. Configure PHP 7.4 Repository

sudo apt -y install lsb-release apt-transport-https ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Finally, use this command to add the repository

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Next, update system

apt update

Step 4. Install PHP 7.4 on Debian 9/10

sudo apt -y install lsb-release apt-transport-https ca-certificates
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Finally, use this command to add the repository

sudo apt install php7.4

Now check the PHP version using php -v command again and you should see the new version is installed as follow

Step 5. Install PHP modules

apt install -y php7.4-common php7.4-xml php7.4-mysql php7.4-pdo php7.4-phar php7.4-simplexml php7.4-curl php7.4-mbstring php7.4-imagick php7.4-zip php7.4-gd

Step 6. Disable PHP 7.0 module and Enable PHP 7.4 module

sudo a2dismod php7.0
sudo a2enmod php7.4
sudo systemctl restart apache2

Now, log in to WordPress again and the issue should be fixed. Your PHP installation is now up to date and you no longer see the “PHP Upgrade Required” error.

 

 

====ANOTHER METHOD======

Step 1: Update system
Ensure your system is updated:

sudo apt update
sudo apt upgrade -y && sudo reboot

Step 2: Add SURY PHP PPA repository
Download and store PPA repository in a file on your Debian Server/Desktop. But first, download GPG key.

sudo apt -y install lsb-release apt-transport-https ca-certificates 
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

Then add the repository.

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list

Step 3: Install PHP 7.4 on Debian 10 / Debian 9
The last step is to Install PHP 7.4 on Debian 10 / Debian 9. Before installation, update system package list on added repositories.

sudo apt update

Then install PHP 7.4 on Debian 10 / Debian 9:

sudo apt -y install php7.4

Answer yes[just click enter] when prompted to complete installation of PHP 7.4 on Debian 10 / Debian 9 Linux system.

*** Install Additional Packages

sudo apt-get install php7.4-xxx

Example

sudo apt-get install php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip}

PHP configurations related to Apache is stored in /etc/php/7.4/apache2/php.ini

*** Using PHP with Nginx:

sudo systemctl disable --now apache2
sudo apt-get install nginx php7.4-fpm

after that choose this from VESTA CP

Main Article:

How to Update to PHP 7.4 for WordPress Site on Debian 9/10

 

 

Upgrade PHP version to PHP 7.4 on Ubuntu

Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert