In this tutorial, we will show you how to install PHP 7.4 on Ubuntu 22.04 LTS. For those of you who didn’t know, PHP 7.4 is a significant update of the PHP language that was “officially” released on November 28, 2019. This is a standard upgrade from now on from the existing PHP 7.3 release to PHP 7.4, which is the last version in the 7 PHP series. There are multiple uses of PHP that make it a strong scripting language option for web development. It operates over the web server and then processes all client requests into HTML files. Another good use of PHP is that it is compatible with different operating systems, like macOS, Windows, and Linux.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of PHP 7.4 on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
- A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
non-root sudo useror access to the
root user. We recommend acting as a
non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.
Install PHP 7.4 on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First, make sure that all your system packages are up-to-date by running the following
apt commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install wget apt-transport-https gnupg2 software-properties-common
Step 2. Installing PHP 7.4 on Ubuntu 22.04.
By default, PHP is not available on Ubuntu 22.04 base repository. Now run the following command below to add the Ondřej Surý PHP repository to your Ubuntu system:
sudo add-apt-repository ppa:ondrej/php
Next, refresh APT to load the new repository and now you can install PHP 7.4 on Ubuntu 22.04:
sudo apt update sudo apt install apache2 php7.4 php7.4 php7.4-common libapache2-mod-php7.4 php7.4-cli
If you use the Nginx web server, to handle the PHP files, you will need to install PHP-FPM “fastCGI process manager.”:
sudo apt install php7.4 php7.4-fpm php7.4-cli
Once is done, we can test PHP in the command line:
PHP 7.4.32 (cli) (built: Oct 19 2022 12:25:46) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.32, Copyright (c), by Zend Technologies
Step 3. Test PHP.
To test PHP, we create a new PHP file in the Apache root directory:
In this file, paste the following code:
<?php phpinfo(); ?>
Save and close the file, and try to access it at
http://your-IP-address/test.php. If the PHP info page is rendered in your browser then everything looks good and you are ready to proceed further.
Congratulations! You have successfully installed PHP 7.4. Thanks for using this tutorial for installing PHP 7.4 on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official PHP website.