Install PHP on Ubuntu 20.04
11 March 2022 (Updated 20 May 2022)
On this page
Add PPA repository
Ubuntu’s default PPA repositories will probably not include the latest PHP version so you’ll want to add ppa:ondrej/php
.
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
Install PHP packages
Head over to the PHP website to check the current stable version. At the time of writing, this is 8.1.1.
Assuming we’ll use PHP with MySQL, we’ll want to install the following packages.
sudo apt install php8.1-fpm php8.1-mysql php8.1-xml php8.1-curl
You may need to install more packages with time.
Verify installation
php -v
This should output something like:
PHP 8.1.1 (cli) (built: Dec 31 2021 07:26:20) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.1, Copyright (c) Zend Technologies
with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies
Sources
Tagged:
PHP