Most people tend to overcomplicate the process to install PHP 8.0 on Ubuntu. But is it really rocket science, or is the process rather a straightforward one? Read more to find out.
Hypertext Preprocessor or PHP is one of the most well-known server-side programming languages. Whether you’re looking to craft amazing web pages or build fully functional web-based applications, PHP is one of those efficient tools that will let you showcase your creativity in the most technically sound manner.
Getting PHP installed on Ubuntu is a straightforward task if you know what you’re doing. However, the same can get troubling for many if the appropriate approach is not known. To help you with that, we’re here with the most flexible tutorial. Following that will let you activate PHP 8.0 on your system in under minutes.
How to Install PHP 8.0 on Ubuntu
Before you begin installing PHP 8.0 on Ubuntu, you must have a few things sorted.
1. Firstly, get yourself logged into Ubuntu with sudo privileges. For this tutorial, I’m using Ubuntu 20.04 as a reference.
2. Once done, you’ll need to check if PHP is already installed on your system or not. Verifying it is pretty straightforward. Type in:
$ which php
3. Hit “Enter”. If you get nothing back, it means your system lacks any version of PHP installed as of now.
As a healthy practice, it is always a good idea to have your software package list updated. It will help you make sure you’re looking at the latest list of available packages.
1. Type in the following commands:
$ sudo apt update
$ sudo apt upgrade
Enabling PHP Repository
1. Input the following command:

$ sudo apt install software-properties-common
2. The system will then ask if you want to add additional repositories to the system other than what’s already available on your system. Type “Y“ for yes and hit “Enter”.
3. Now, type the add-apt-repository
ppa:ondrej/php
command, and then hit the “Enter“ key.
$ sudo add-apt-repository ppa:ondrej/php
All that you need to do then is wait for a few seconds until the process concludes, and the Ondrej PHP repository (containing the desired PHP version) gets activated on your system.
Installing PHP 8.0 on Ubuntu
1. Input the following command:
$ sudo apt install php8.0
2. Proceed with the yes option by typing “Y” and hitting “Enter“.
Wait for the process to conclude, and once the system is done with that, make sure to check the PHP version using the steps mentioned below. You can easily do that by running the following command:
$ php --version
You can now see that your system is running PHP 8.0.0.
Installing PHP 8.0 on Ubuntu with Apache

Running Apache Web Server
1. Update the system repository by running this code:
$ sudo apt update
2. Install PHP 8.0 by inputting this command:
$ sudo apt install php8.0 libapache2-modphp8.0
3. Hit the “Enter” key, and then type “Y”.
4. Restart the Apache web server. Do that using the command:
$ sudo systemctl restart apache2
Running Apache Web Server with PHP-FPM

1. Update the system repository by running the following code:
$ sudo apt update
2. Install PHP 8.0 by inputting:
$ sudo apt install php8.0-fpm libapache2-modfcgid
3. One thing you’ll need to keep in mind is that PHP-FPM isn’t enabled by default. This is the reason why you’ll need to cite the following codes:
$ sudo a2enmod proxy_fcgi setenvif
$ sudo a2enconf php8.0-fpm
4. Restart the Apache web server by running the following command:
$ sudo systemctl restart apache2
And with that, you’re done installing PHP 8.0 on Ubuntu using Apache.
Installing PHP 8.0 on Ubuntu: The Extension Method
When we talk about PHP Extensions, we generally look for a “plugin,” or a “library” specially designed to extend PHP functionality. These usually exist in the form of packages. It is vital to be aware that any file that has a .php file extension is not similar to the ones that a PHP developer codes for taking the functionality to the next level.
Installing Extension is pretty simple. All you need to do is run the following command:
$ sudo apt install php8.0-[extension-name]
Once you’re done installing the PHP extension, restart Apache or PHP FPM.
Installing PHP 8.0 on Ubuntu with Nginx

1. For installing PHP 8.0 on Ubuntu with Nginx, the most appropriate approach is having the PHP-FPM installed. You can do that using the following code:
$ sudo apt install php8.0-fpm
2. Hit “Enter”, and the PHP-FPM server should start automatically. Make sure you verify it using the following command:
$ sudo systemctl status php8.0-fpm
3. Next up, you’ll need to make Nginx process the PHP files. To do that, configure the Nginx server block simply by updating the server section as:
server {
# … some other code
location ~ \,php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
}
}
4. The last thing to do is restarting the Nginx server using the command:
$ sudo systemctl restart Nginx
With that, we’re done talking about the best available methods to install PHP 8.0 on Ubuntu. But before you start operating, make sure to take a step and verify if the installation was successfully concluded.
Verifying PHP 8.0 Installation

1. Input the which php
command and hit “Enter”.
$ which php
2. Run either of the commands and make sure it displays PHP 8.0.0 (cli) alongside the built date.
$ php --version
$ php -v
How to Test PHP Processing?
Are you wondering how you can test whether the web server is properly configured for PHP processing or not? Well, it can be done in minutes.
1. Create a new file inside /var/www/html and name it info.php
2. Save the file.
3. Launch your browser.
4. Visit “http://your_server_ip/info.php”
Make sure it comes up with something like:

This is pretty much everything about installing PHP 8.0 on Ubuntu. Although the process involves plenty of technical jargon, you will soon realize it is quite simple to get around, once you get started.
In case you find implementing any of the steps a bit troubling, don’t hesitate to let us know in the comment section below.
If this guide helped you, please share it.