How to Install PHP 8.0 on Ubuntu 20.04 or 18.04
How to Install PHP 8.0 on Ubuntu 20.04 or 18.04?
let’s update your Ubuntu system packages and install some dependencies as shown.
$ sudo apt update $ sudo apt upgrade $ sudo apt install ca-certificates apt-transport-https software-properties-common
Next, add the Ondrej PPA.
$ sudo add-apt-repository ppa:ondrej/php
When prompted, press ENTER to proceed with adding the repository.
Step 2: Install PHP 8.0 with Apache on Ubuntu
Next, update the system repositories to start using the PPA.
$ sudo apt update
If you are running the Apache web server, install PHP 8.0 with the Apache module as shown.
$ sudo apt install php8.0 libapache2-mod-php8.0
Next, restart the Apache webserver to enable the module.
$ sudo systemctl restart apache2
If you want to use Apache webserver with PHP-FPM, run the command below to install the required packages:
$ sudo apt install php8.0-fpm libapache2-mod-fcgid
Since PHP-FPM is not enabled by default, enable it by invoking the following commands:
$ sudo a2enmod proxy_fcgi setenvif $ sudo a2enconf php8.0-fpm
Then restart the Apache webserver for the changes to come into effect.
$ sudo systemctl restart apache2
Verify PHP 8 Installation in Ubuntu
To confirm the version of PHP installed, run the command:
$ php -v