How to install PHP 8 on Ubuntu 20.04 LTS Server

PHP doesn’t need an introduction to those who are in the software development field. Well, for those who don’t know about it, PHP is an open-source scripting language PHP for web development and widely used for creating dynamic web pages. It came into existence in 1994 and since then it has been developing to perform more complex operations and that’s the reason why it is considered a standard for dynamic web content.

Unlike other script languages, the websites are generated on the server-side and then sent to the web browser. This has the advantage that the client – in this case, the browser – does not have to bring any special plug-ins.

The connection of PHP to a database such as MySQL is practical, which significantly expands the possibilities of web offers. You can find numerous tips, tricks, and instructions for this and much more in the PHP manual.

Commands to install PHP 8 on Ubuntu 20.04 or 18.04 LTS Server

In this article, we will see the steps to download and install the current latest version of PHP i.e 8.0 while writing this article. It was launched in Nov 2020 with lots of improvements for better performance and security updates. However, yet most of the commercial applications on the web are not on PHP 8.0 instead of using php7.x but soon they will.

1. Run system update

The first thing we have to do is running of system update command that will update existing packages and also rebuild the repositories cache. Therefore, open a command terminal and run:

sudo apt update


2. Add PHP Ondrej PPA repository

Currently, on Ubuntu 20.04 the PHP version officially available to install is PHP 7.0, thus to get 8.0, we need to add an extra PPA repository on your system. This will help us to download and install PHP version 8.0 on our Ubuntu-based Linux systems.

sudo apt install apt-transport-https software-properties-common
sudo add-apt-repository ppa:ondrej/php

Install Software common properties

Add PHP PPA reopsitory on Ubuntu 20.04


3.  Command to install PHP 8 on Ubuntu 20.04/18.04

Finally, the repo is set and our system also has been updated, now its time to run the command to install PHP 8.0 on our Ubuntu Linux system

sudo apt install php8.0

command Install PHP 8.0 on Ubuntu 20.04


4. Install some command PHP 8 Extensions

Here are a few common extensions that we need to have for web applications such as WordPress and others to functions properly…

sudo apt install php8.0-common php8.0-gd php8.0-ldap php8.0-odbc php8.0-xsl php8.0-apcu php8.0-curl php8.0-gmp php8.0-opcache php8.0-mbstring php8.0-pgsql php8.0-imagick php8.0-memcached php8.0-bz2 php8.0-ds php8.0-imap php8.0-cgi php8.0-mysql php8.0-cli php8.0-fpm php8.0-xml


5. Check Verison

To confirm the install version of PHP type-

php -v


PHP 8.0.2 (cli) (built: Feb 14 2021 14:21:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.2, Copyright (c) Zend Technologies
with Zend OPcache v8.0.2, Copyright (c), by Zend Technologies


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.