Install PHP 8 on Ubuntu 20.04

In Ubuntu 20.04 the standard version of PHP is 7.4. You might want to install the newest version which is 8.0 (as of April 2021).

Before installing it, you need to update your repository to get the packages:

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

Now let’s intstall PHP 8

sudo apt install php8.0 libapache2-mod-php8.0 

Install some additional libraries (choose whatever you need or add others; you can do this later, too)

sudo apt install php8.0-mysql php8.0-curl php8.0-dev php8.0-gd php8.0-mbstring php8.0-zip php8.0-xml

And.. restart the web server so the changes can become effective

sudo systemctl restart apache2

And let’s see what PHP version is running

php -v

Leave a Reply

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