Check PHP Version and Install on Ubuntu 24.04
Checking the PHP version on Ubuntu 24.04 takes just one quick command in your terminal. PHP is the programming language that powers popular platforms like WordPress, making websites interactive and dynamic.
Type php -v to see your current version instantly. Checking this helps you avoid errors when running software that needs a specific update, like PHP 8.2 or 8.3.
Check your PHP version on Ubuntu 24.04 by opening a terminal and running `php -v`. If you need to install a different version, you can add a PPA using `add-apt-repository ppa:ondrej/php` and then install your desired version with `apt install phpX.X`.
Find out what version of PHP is installed
Checking the PHP version installed on your Ubuntu 24.04 system takes a quick command in your terminal. Run `php -v` or `php –version` to display the exact PHP version alongside other system details. This command provides the fastest way to confirm the active release on Ubuntu 24.04.
Run the commands below to check the PHP version in your Ubuntu Linux terminal.
php -v # OR php --version
Once you run the command above, it should output lines similar to these:
PHP version 7.4.3 is available in the Ubuntu repository, but this fact does not guarantee that the absolute latest PHP version can be installed. Newer PHP versions often require specific system updates or manual compilation to install on Ubuntu 24.04.
More information on the installed PHP version can be found by running the commands below:
apt info php
When you run the commands above, it should list output similar to this:
Package: php
Version: 2:7.4+75
Priority: optional
Section: php
Source: php-defaults (75)
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian PHP Maintainers <team+pkg-php@tracker.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
sudo nano /var/www/html/phpinfo.php
Copy and paste the line below into the file, then save and close it.
<?php phpinfo( ); ?>
Next, open your browser and go to localhost/phpinfo.php or your domain name (example.com/phpinfo.php). The PHP server version will be displayed on your screen:

Find out what PHP modules are installed
Once your PHP version is checked on Ubuntu 24.04, seeing which PHP modules are installed and active is possible with a specific command. Run `dpkg --get-selections | grep -i php` to display a list of all installed PHP packages and their current status. This helps you understand what PHP extensions are available.
dpkg --get-selections | grep -i php
After executing the commands above, you should see output that resembles the lines shown below.
libapache2-mod-php8.1 install php-common install php-fpm install php7.4-cli install php7.4-common install php7.4-fpm install php7.4-json install php7.4-opcache install php7.4-readline install php8.1 install php8.1-cli install php8.1-common install php8.1-opcache install php8.1-readline install ftp
The length of this list can vary based on your environment.
To list modules compiled with PHP, run the commands below:
Ubuntu 24.04 installs the latest stable PHP version by default. Projects requiring a different release need a third-party software source added first. This is common when you need an older PHP version or a very new PHP version.
A third-party repository might need to be added to your system if you want to install a specific version that isn't available in Ubuntu Linux.
Adding a repository in Ubuntu Linux lets you install specific software versions, such as PHP 8.2. Use the commands below to add this repository.
First, install the necessary commands:
sudo apt update sudo apt install software-properties-common
Next, run the commands below to add the repository.
sudo add-apt-repository ppa:ondrej/php sudo apt-get update
After that, you can search for and install a specific version of PHP.
apt-cache showpkg php
Install a specific version using the command format below:
sudo apt-get install php8.x=<complete version name>Replace 'x' with the PHP minor version number (e.g., 2 for 8.2) and '<complete version number>' with the full version number available for Ubuntu.
Here’s an example:
sudo apt install php8.1=8.1.0-1+ubuntu20.04.1+deb.sury.org+1
Now the new version should reflect as shown below:
PHP 8.1.0 (cli) (built: Nov 25 2021 20:22:03) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies
That should do it!
Keeping track of active PHP versions is crucial for security and application compatibility.
- Understanding the PHP version running on your system is crucial for compatibility and security.
- PHP installation on Ubuntu is straightforward and can be tailored to specific versions using third-party repositories.
- The
phpinfo()function is a helpful tool for verifying PHP configuration and installed modules. - Regularly checking for updates and managing PHP versions ensures optimal performance for your web applications.
- Knowing how to list installed PHP modules enhances your ability to troubleshoot and manage your server environment effectively.
What is the default PHP version in Ubuntu 24?
What PHP version does Ubuntu 24.04 include? Ubuntu 24.04 ships with PHP 8.3 in its default repositories.
How do I check my PHP version?
And it will give you detailed information on your PHP installation and extensions.
How do I find out what version of Ubuntu 24.04 I have?
Scroll to the very bottom of the left-hand sidebar in the Settings window and select “About“. 4. Your Ubuntu version will be listed under the OS Name label (e.g., Ubuntu 24.04 LTS, Ubuntu 22.04. 5 LTS).
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!