How to install PHP 8.0 and PECL extensions on Ubuntu 20.04, 18.04, 16.04

Want to install PHP 8.0 and many PECL extensions on your Ubuntu server? There is a reliable PPA that includes packages for all current Ubuntu releases.

Ondřej Surý, the Debian developer who manages the official PHP packages on Debian, Ubuntu PPA It includes the latest PHP 5.6, PHP 7.0, PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4, and PHP 8.0 packages, as well as PECL extensions for all current Ubuntu releases.

1.) Open a terminal or connect to a remote Ubuntu server and run the command to verify. software-properties-common Installed:

sudo apt install software-properties-common

How to install PHP 8.0 and PECL extensions on Ubuntu 20.04, 18.04, 16.04

2.) Then run the command and run the following command to add the phpPPA repository.

sudo add-apt-repository ppa:ondrej/php

For locales other than UTF-8 LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php

How to install PHP 8.0 and PECL extensions on Ubuntu 20.04, 18.04, 16.04

3.) If you are using php-gearman, you need to run the command to add the Gearman PPA.

sudo add-apt-repository ppa:ondrej/pkg-gearman

I’m using an Nginx web server, but I recommend adding an Nginx stable PPA instead.

sudo add-apt-repository ppa:ondrej/nginx

How to install PHP 8.0 and PECL extensions on Ubuntu 20.04, 18.04, 16.04

If you are using Apache2, we recommend that you add apache2PPA.

sudo add-apt-repository ppa:ondrej/apache2

4.) Finally, update the system package cache and use the command to install the php8.0 package.

sudo apt update

sudo apt install php8.0-fpm libapache2-mod-php8.0 php8.0-mysql php8.0-xml

There are also many other packages available. php8.0-amqp, php8.0-apcu, php8.0-memcache, php8.0-memcached, More. Just add or remove the package name after “sudo apt install” and all you need is different.

How to install PHP 8.0 and PECL extensions on Ubuntu 20.04, 18.04, 16.04

With all the commands so far, you can replace php8.0 with php7.4, php7.3, php7.2, php7.0, or php5.6 and install the specified version of PHP package.

Uninstall PHP.

To remove Ubuntu PPA --remove Flags when adding PPA commands. For example, remove phpPPA with the following command:

sudo add-apt-repository --remove ppa:ondrej/php

Instead of removing the Ubuntu PPA, you can also remove the PPA that downgrades the installed package to the stock version of the Ubuntu repository.

sudo apt install ppa-purge && sudo ppa-purge ppa:ondrej/php

To remove the php package, just run the following command:

sudo apt remove Package_Name_Here

Share this:

  • More
Sidebar