How to install PHP 8.0 on Ubuntu 22.04 and 20.04, including PHP 8.0-fpm with full extensions, and configure multiple versions on Ubuntu Linux.
Step-by-step: Install PHP 8.0 on Ubuntu 22.04 FULL Extensions
The official release of PHP 8 on 11/26/2020 with many new features and performance improvements, and some great new feature sets that come with PHP 8 are the JIT compiler, named arguments, union types, attributes.
Step 1: Add PPA repository and Install PHP 8.0
Add repository only needs to be applied on Ubuntu 18 and 20, on 22.04 is available so you can skip this step. You can refer to the Ondřej Surý PPA for more information. Now start running the command below to install the required packages for PHP 8.0.
sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y
Next, Add the repository with the following command, and press
Enter to confirm.
sudo add-apt-repository ppa:ondrej/php
Then update the system and install php8.0 ubuntu, type
Enter to confirm.
sudo apt update sudo apt install php8.0
Installing php8.0 on ubuntu is as simple as that, type
php -v to check the version, and move on to the next step, install the extensions.
Step 2: Install php8.0-fpm on ubuntu and PHP modules
To install PHP 8 extensions on Ubuntu 22.04 | 20.04 | 18.04, use the command:
sudo apt install php8.0-<extension>
And here is the list of extensions for php8.0:
sudo apt install php8.0- php8.0-amqp php8.0-common php8.0-gd php8.0-ldap php8.0-odbc php8.0-readline php8.0-sqlite3 php8.0-xsl php8.0-apcu php8.0-curl php8.0-gmp php8.0-mailparse php8.0-opcache php8.0-redis php8.0-sybase php8.0-yac php8.0-ast php8.0-dba php8.0-igbinary php8.0-mbstring php8.0-pgsql php8.0-rrd php8.0-tidy php8.0-yaml php8.0-bcmath php8.0-dev php8.0-imagick php8.0-memcached php8.0-phpdbg php8.0-smbclient php8.0-uuid php8.0-zip php8.0-bz2 php8.0-ds php8.0-imap php8.0-msgpack php8.0-pspell php8.0-snmp php8.0-xdebug php8.0-zmq php8.0-cgi php8.0-enchant php8.0-interbase php8.0-mysql php8.0-psr php8.0-soap php8.0-xhprof php8.0-cli php8.0-fpm php8.0-intl php8.0-oauth php8.0-raphf php8.0-solr php8.0-xml
Here I only install php8.0-fpm and some necessary extensions for the project, so the command is as follows:
sudo apt install php8.0-fpm php8.0-cli php8.0-common php8.0-imap php8.0-redis php8.0-snmp php8.0-xml php8.0-zip php8.0-mbstring
Enable php8.0-fpm and allow
php-fpm to start with the system.
sudo systemctl enable php8.0-fpm sudo service php8.0-fpm restart
You can install and use multiple PHP versions for each website (project). The command changes the default php version, just enter the version number.
sudo update-alternatives --config php
Above are the steps on how to install PHP 8.0 on Ubuntu 22.04 or 20.04 LTS. If you want to configure PHP-FPM for performance optimization, you can refer to the article: Optimize performance pm.max_children and fix PHP-FPM.