1. Aggiungere oncrej/php PPA


sudo add-apt-repository ppa:ondrej/php # Press enter to confirm.
sudo apt-get update


sudo apt install apt-transport-https lsb-release
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg # Download the signing key
sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' # Add Ondrej's repo to sources list.
sudo apt update

2. Install PHP 7.4 and required extensions

To install PHP 7.4 core

sudo apt install php7.4 php7.4-common php7.4-cli

Install required extensions

Simply prefix php7.4- with an extension that you need to install.
For example to get the php-curl extension use php7.4-curl

sudo apt install php7.4-curl php7.4-json php7.4-gd php7.4-mbstring php7.4-intl php7.4-bcmath php7.4-bz2 php7.4-readline php7.4-zip

3. PHP 7.4 for web:

To integrate PHP with your web server, If you are using Nginx, or Apache with mod_event, you will need to install php7.4-fpm package. If you are using PHP as an embedded Apache module, you will need the package libapache2-mod-php7.4. For Apache, you can use a2query -M to see your current MPM, whether it’s prefork or event.

Nginx or Apache with event MPM:

sudo apt install php7.4-fpm

Apache with prefork MPM:

sudo apt install libapache2-mod-php7.4
sudo a2enmod php7.4

4. Uninstall old PHP versions:

sudo apt purge php7.3 libapache2-mod-php7.3 # For removing PHP 7.3
sudo apt purge php7.2 libapache2-mod-php7.2 # For removing PHP 7.2
sudo apt purge php7.1 libapache2-mod-php7.1 # For removing PHP 7.1
sudo apt purge php7.0 libapache2-mod-php7.0 # For removing PHP 7.0

5. Verify PHP 7.4 installation:

To verify the installation of PHP 7.4

From CLI:

php -v
php -v output

From web server:

Create a file info.php. It must be saved to a very specific directory, which is called the “web root”. In Ubuntu and Debian this is located at /var/www/html/.

sudo nano /var/www/html/info.php

Type the following in the editor.


When you are finished, save and close the file.

Now visit this script in your browser. http://your_server_IP_address/info.php
You should see something similar to this.

phpinfo() output

5. Mettere a posto MySql e PHP

Potrebbe verificarsi il seguente errore all’accesso di WordPress

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Per mettere a posto questo errore procedere come segue:

sudo apt-get install php7.0-mysql
systemctl restart apache2
sudo apt-get update
sudo apt-get install php-mysql
systemctl restart apache2

Di andrea

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *