How to install PHP 8 on Linux Mint 20 Ulyana or Ubuntu 20.04

8262
Share:
how-to-install-php-8-on-linux-mint-20-ulyana-or-ubuntu-20-04

As PHP had officially released PHP version 8, I decided to install it on my local development server. It uses Linux Mint 20 Ulyana which is based on Ubuntu 20.04 Focal Fossa, so official PHP package provided from their repository is at 7.4.3. Thanks to Ondřej Surý PPA repository that enables us to install the latest versions of PHP. Hence, run the command below to add this PPA repository to your Ubuntu 20.04 system.

Getting Started

As usual, before proceed with actual installation, make sure that your system packages are up-to-date. Run the commands below to perform system package update and upgrade.

$ sudo apt update
$ sudo apt upgrade

Add PPA Repository

As mentioned above, we need to add the ondrej/php which has PHP 8 package and other required PHP extensions.

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

Notice that after above command entered, message like this will likely shown:

You are about to add the following PPA:
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 <foo>-backports is now required on older Ubuntu releases.

BUGS&FEATURES: This PPA now has a issue tracker:
https://deb.sury.org/#bug-reporting

CAVEATS:
1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman
2. If you are using apache2, you are advised to add ppa:ondrej/apache2
3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline
   or ppa:ondrej/nginx

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see
https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:

# LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press Enter to continue or Ctrl+C to cancel

You can safely press "Enter" and the process will continue. Wait for it to finish end then enter this command:

$ sudo apt update

PHP 8 Installation

Right now your Ubuntu 20.04 system is ready for PHP 8 installation. Hence, run the command below to install PHP 8 on Ubuntu 20.04.

$ sudo apt install php8.0-fpm

It will ask you to confirm whether to continue with installation or not.

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
php8.0-cli php8.0-common php8.0-opcache php8.0-readline
Suggested packages:
php-pear
The following NEW packages will be installed:
php8.0-cli php8.0-common php8.0-fpm php8.0-opcache php8.0-readline
0 upgraded, 5 newly installed, 0 to remove and 206 not upgraded.
Need to get 4.432 kB of archives.
After this operation, 20,1 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Press "Y" and the installation process will start. After the installation has completed, confirm that PHP 8 FPM has installed correctly with this command:

$ 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

The verification of the same can be done by running the command below:

$ apt-cache policy php8.0-fpm
php8.0-fpm:
Installed: 8.0.0-1+ubuntu20.04.1+deb.sury.org+1
Candidate: 8.0.0-1+ubuntu20.04.1+deb.sury.org+1
Version table:
*** 8.0.0-1+ubuntu20.04.1+deb.sury.org+1 500
500 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages
100 /var/lib/dpkg/status

Install PHP 8 Extensions

If you're web developer like me, usually we need to install various extensions. To find specific extension, you can always search for a specific PHP 8 extension by running the command below:

$ apt-cache search "php8.0-*"
libapache2-mod-php8.0 - server-side, HTML-embedded scripting language (Apache 2 module)
libphp8.0-embed - HTML-embedded scripting language (Embedded SAPI library)
php8.0 - server-side, HTML-embedded scripting language (metapackage)
php8.0-amqp - AMQP extension for PHP
php8.0-apcu - APC User Cache for PHP
php8.0-ast - AST extension for PHP 7
php8.0-bcmath - Bcmath module for PHP
php8.0-bz2 - bzip2 module for PHP
php8.0-cgi - server-side, HTML-embedded scripting language (CGI binary)
php8.0-cli - command-line interpreter for the PHP scripting language
php8.0-common - documentation, examples and common module for PHP
php8.0-curl - CURL module for PHP
php8.0-dba - DBA module for PHP
php8.0-dev - Files for PHP8.0 module development
php8.0-ds - PHP extension providing efficient data structures for PHP 7
php8.0-enchant - Enchant module for PHP
php8.0-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
php8.0-gd - GD module for PHP
php8.0-gmp - GMP module for PHP
php8.0-igbinary - igbinary PHP serializer
php8.0-imagick - Provides a wrapper to the ImageMagick library
php8.0-imap - IMAP module for PHP
php8.0-interbase - Interbase module for PHP
php8.0-intl - Internationalisation module for PHP
php8.0-ldap - LDAP module for PHP
php8.0-mailparse - Email message manipulation for PHP
php8.0-mbstring - MBSTRING module for PHP
php8.0-memcache - memcache extension module for PHP
php8.0-memcached - memcached extension module for PHP, uses libmemcached
php8.0-mongodb - MongoDB driver for PHP
php8.0-msgpack - PHP extension for interfacing with MessagePack
php8.0-mysql - MySQL module for PHP
php8.0-oauth - OAuth 1.0 consumer and provider extension
php8.0-odbc - ODBC module for PHP
php8.0-opcache - Zend OpCache module for PHP
php8.0-pgsql - PostgreSQL module for PHP
php8.0-phpdbg - server-side, HTML-embedded scripting language (PHPDBG binary)
php8.0-pspell - pspell module for PHP
php8.0-psr - PSR interfaces for PHP
php8.0-raphf - raphf module for PHP
php8.0-readline - readline module for PHP
php8.0-redis - PHP extension for interfacing with Redis
php8.0-rrd - PHP bindings to rrd tool system
php8.0-smbclient - PHP wrapper for libsmbclient
php8.0-snmp - SNMP module for PHP
php8.0-soap - SOAP module for PHP
php8.0-solr - PHP extension for communicating with Apache Solr server
php8.0-sqlite3 - SQLite3 module for PHP
php8.0-sybase - Sybase module for PHP
php8.0-tidy - tidy module for PHP
php8.0-uuid - PHP UUID extension
php8.0-xdebug - Xdebug Module for PHP
php8.0-xhprof - Hierarchical Profiler for PHP 5.x
php8.0-xml - DOM, SimpleXML, XML, and XSL module for PHP
php8.0-xsl - XSL module for PHP (dummy)
php8.0-yac - YAC (Yet Another Cache) for PHP
php8.0-yaml - YAML-1.1 parser and emitter for PHP
php8.0-zip - Zip module for PHP
php8.0-zmq - ZeroMQ messaging bindings for PHP

To install specific extension, you can type these command:

$ sudo apt install php8.0-<extension-name>

where <extension-name> is the name of a specific extension. For example:

$ sudo apt install php8.0-bcmath

Or, if you're impatient, you could use this:

$ sudo apt install php8.0-bcmath php8.0-mysql php8.0-mbstring php8.0-gd php8.0-xml php8.0-curl

Final Words

I hope that you now know how to install PHP 8 on Linux Mint 20 (Ulyana, Ulyssa) or Ubuntu 20.04 Focal Fossa. If you run into any issues or have any feedback feel free to drop a comment below.

Tags PHP Linux
Share:

0 comment

Leave a reply

Your email address will not be published. Required fields are marked *