On this tutorial we will learn how to install PHP 8.0.0 on Ubuntu 20.04 LTS operating system.
PHP is one of the most famous general-purpose scripting language especially suited to web development, it was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1994. The PHP reference implementation is now produced by The PHP Group. Ubuntu 20.04 LTS repositories contains PHP 7.4 as default PHP application. If we need to have the latest PHP version, we have to install it first. PHP 8.0 is a major update of the PHP language. On this tutorial we will install PHP 8.0 on Linux Ubuntu 20.04 LTS.
PHP 8 Installation On Ubuntu 20.04 LTS
The PHP 8.0 installation on Ubuntu 20.04 LTS will be consist of several steps as shown below :
- Update Ubuntu System packages to the latest
- Add Ondřej Surý PPA repository
- Install PHP 8 on Ubuntu 20.04
- Install PHP 8 Extensions on Ubuntu 20.04
- Verify PHP 8
Update Ubuntu System Packages to the Latest
On this step, we will update Ubuntu system packages and install some dependencies libraries. we are going to do some steps namely:
sudo apt update
ramans@diginet-app02:~$ sudo apt update [sudo] password for ramans: Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [109 kB] Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease Get:3 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Get:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [24.3 kB] Get:5 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB] Get:6 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [56.6 kB]
sudo apt upgrade
ramans@diginet-app02:~$ sudo apt upgrade Reading package lists… Done Building dependency tree Reading state information… Done Calculating upgrade… Done The following packages were automatically installed and are no longer required: libapr1 libeclipse-jdt-core-java libfprint-2-tod1 libllvm9 libtcnative-1 Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: apt-config-icons apt-config-icons-hidpi libllvm11 linux-headers-5.8.0-36-generic linux-hwe-5.8-headers-5.8.0-36 linux-image-5.8.0-36-generic linux-modules-5.8.0-36-generic linux-modules-extra-5.8.0-36-generic python3-click python3-colorama
sudo apt install software-properties-common
ramans@diginet-app02:~$ sudo apt install software-properties-common [sudo] password for ramans: Reading package lists… Done Building dependency tree Reading state information… Done software-properties-common is already the newest version (0.98.9.3). software-properties-common set to manually installed. The following packages were automatically installed and are no longer required: libapr1 libeclipse-jdt-core-java libfprint-2-tod1 libllvm9 libtcnative-1 linux-headers-5.4.0-26 linux-headers-5.4.0-26-generic linux-image-5.4.0-26-generic linux-modules-5.4.0-26-generic linux-modules-extra-5.4.0-26-generic
Add Ondřej Surý PPA Repository
Next step is adding Ondřej Surý PPA repository to the system, as we know if Ondřej Surý hold the newest PHP version. The task can be done the by submitting command line :
sudo add-apt-repository ppa:ondrej/php
ramans@diginet-app02:~$ sudo add-apt-repository ppa:ondrej/php Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided. Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa You can get more information about the packages at https://deb.sury.org IMPORTANT: The -backports is now required on older Ubuntu releases.
Install PHP 8 on Ubuntu 20.04
On this step we will install PHP 8 by submitting command line :
sudo apt install php8.0
ramans@diginet-app02:~$ sudo apt install php8.0 Reading package lists… Done Building dependency tree Reading state information… Done The following packages were automatically installed and are no longer required: libeclipse-jdt-core-java libfprint-2-tod1 libllvm9 libtcnative-1 linux-headers-5.4.0-26 linux-headers-5.4.0-26-generic linux-image-5.4.0-26-generic linux-modules-5.4.0-26-generic linux-modules-extra-5.4.0-26-generic
Verify PHP 8
After installing PHP 8 was completed done, then the next step is to verify if the installation was successful. This task can be done by querying PHP version by submitting command line :
ramans@diginet-app02:~$ php -v PHP 8.0.0 (cli) (built: Nov 27 2020 12:26:22) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies
PHP 8.0 Extension
PHP extension is a specially formed library or plug-in that provides a function that can be used by many applications. By using extensions, we can avoid having to recreate the same code for numerous applications.
The PHP 8.0 installation on Ubuntu 20.04 LTS has been completed done successfully.