How To Install PHP 7.4 on Ubuntu 20.04/18.04/16.04
How to Install PHP 7.4 on Ubuntu?. Welcome to today’s guide on how to install PHP 7.4 on Ubuntu 20.04/18.04/19.04/16.04 Linux. The PHP release 7.4.0 has been made available for the general public and for use in Production environments.
PHP is a popular server scripting language known for creating dynamic and interactive Web pages. PHP is widely-used programming language in the Web. Use the steps below to install PHP 7.4 on Ubuntu
Install PHP 7.4 on Ubuntu 20.04
NOTE: Ubuntu 20.04 ships with PHP 7.4 in its upstream repositories. Just install it and the extensions you with the apt package manager.
sudo apt update
sudo apt install php php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath
Confirm PHP version:
$ php --version
PHP 7.4.3 (cli) (built: Mar 26 2020 20:24:23) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
Listing all loaded PHP modules:
$ php -m
Install PHP 7.4 on Ubuntu 18.04/16.04
For the other editions of Ubuntu, use the process below:
Step 1: Add PHP PPA Repository
We’ll add ppa:ondrej/php PPA repository which has the latest build packages of PHP.
sudo apt-get update
sudo apt -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
Step 2: Install PHP 7.4 on Ubuntu 18.04/19.04/16.04
Install PHP 7.4 on Ubuntu 18.04/19.04/16.04 using the command:
sudo apt -y install php7.4
Check version installed:
$ php -v
PHP 7.4.0beta4 (cli) (built: Aug 28 2019 11:41:49) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v7.4.0beta4, Copyright (c), by Zend Technologies
Use the next command to install additional packages:
sudo apt-get install php7.4-xxx
Example:
sudo apt-get install -y php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip,common}
PHP configurations related to Apache is stored in /etc/php/7.4/apache2/php.ini