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 are unfamiliar with it, PHP is an open source PHP scripting language for web development and widely used for creating dynamic web pages. It came into being in 1994 and since then it has grown to perform more complex operations and that is why it is considered a standard for dynamic web content.
Unlike other scripting languages, 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 need to provide special plugins.
Connecting PHP to a database such as MySQL is convenient, which considerably expands the possibilities of web offers. You can find many 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 latest current version of PHP namely 8.0 when writing this article. It was released in November 2020 with many improvements for better performance and security updates. However, most commercial applications on the web are not based on PHP 8.0 instead of using php7.x, but they will be soon.
1. Run the system update
The first thing we need to do is run the system update command which will update the existing packages and also rebuild the repository cache. Therefore, open a command terminal and run:
sudo apt update
2. Add the Ondrej PPA PHP repository
Currently on Ubuntu 20.04, the PHP version officially available for installation is PHP 7.0, so to get 8.0 we need to add an additional PPA repository on your system. This will help us 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
3. Command to install PHP 8 on Ubuntu 20.04 / 18.04
Finally the repository is set and our system has also been updated, now it’s time to run the command to install PHP 8.0 on our Ubuntu Linux system
sudo apt install php8.0
4. Install PHP 8 command extensions
Here are some common plugins that we need for web applications like WordPress and others to run smoothly …
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 the version
To confirm the PHP installation version, type-
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