PHP 8.0 is the latest major release of the PHP language. It introduces several breaking changes, performance improvements, and lots of new features such as named arguments, JIT compiler, union types, match expression, and more
In this short tutorial, we’ll go over the steps to update and enable PHP 8 on ubuntu.
Enabling PHP Repository
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
Once they’re installed, we can now install php8.
Install PHP 8.0 with Apache
Installing PHP 8.0 with apache is a straight forward task.
sudo apt update
sudo apt install php8.0 libapache2-mod-php8.0
Once these packages are successfully installed, restart the apache server,
sudo systemctl restart apache2
Enable PHP 8.0
You might still see older PHP version on running php -v
command, that’s fine, let’s quickly fix this:
sudo a2dismod php7.4
sudo a2enmod php8.0
Well, that’s it, you’ve successfully updated your PHP version to 8.0 on your ubuntu machine.
Installing PHP extensions
PHP extensions are compiled libraries that extend the core functionality of PHP. Extensions are available as packages and can be easily installed:
sudo apt install php8.0-[extname]
After installing any php 8 packages, do not forget to restart your apache or nginx server.