This post will discuss the procedure to install PHP 8 on Ubuntu 22.04. So, let’s start!
How to install PHP 8 on Ubuntu 22.04
For the installation of PHP 8 on Ubuntu 22.04, you must follow the below-given step-by-step instructions.
Step 1: Update system repositories
Press “CTRL+ALT+T” to open the terminal of your Ubuntu 22.04 and run the below-given command to update system repositories:
Step 2: Install required dependencies
After updating the system packages, the next step is to install required dependencies for PHP 8:
The specified dependencies will be installed in a few minutes:
Step 3: Set up PHP repository
Then, set up the PHP 8 repository on your system repositories with the help of the following command:
Press “Enter” to permit the prompt to continue:
Step 4: Install PHP 8 on Ubuntu 22.04
At this point, we have installed the required dependencies and added the PHP repository. Now, we will move ahead and execute the below-given for PHP 8 installation on our Ubuntu 22.04 system:
Type “y” to allow the system for completing PHP 8 installation:
Step 5: Verify PHP version
You can also verify the version of the installed PHP by executing the “php” command with the “-v” option:
As you can see from the output, PHP 8 is all set up on our Ubuntu 22.04 system:
Step 6: Install PHP 8 Extensions
As a Linux-based system, Ubuntu permits the installation of PHP 8 extensions to enhance its functionality.
You have to follow the below-given syntax for the installation of PHP 8 extensions:
For instance, we will use the given syntax for installing some PHP 8 extensions as follows:
Wait for a few minutes until the installation of PHP 8 extensions gets complete:
Step 7: Check PHP 8 loaded modules
To check the loaded modules of PHP 8, utilize the following command:
Step 8: Check php-fpm status
If you want to use PHP 8 with Nginx then before doing so check if the “php-fpm” service is currently active or not:
On our Ubuntu 22.04 system, the “php-fpm” service is active which can be seen in the below-given output:
We have compiled the simplest method for PHP 8 installation on Ubuntu 22.04. Give it a try and start web development.
For the installation of PHP 8 on Ubuntu 22.04, firstly update the system repositories and install the required dependencies. Then, add the PHP repository using the “$ sudo add-apt-repository ppa:ondrej/php” command and install PHP 8 by executing the “$ sudo apt install php8.0” command. You can install its available extensions for improving the web development experience. This post discussed the method to install PHP 8 on Ubuntu 22.04.