How to Check the PHP Version?

PHP is a famous scripting language that supports making dynamic and interactive web pages. Sometimes, you must upgrade the PHP version to meet the server requirement or acquire additional features. Like windows operating systems, PHP supports Ubuntu with all extended functionalities. The agenda of this article is to check the PHP version in the Linux system.

The content that carried out this guideline is as follows:

Let’s start this guide.

Prerequisites: How to Install PHP on Linux?

Different commands are provided to install PHP on Linux operating systems. These are addressed below:

For Ubuntu/Debian

$ sudo apt install php

For CentOS/RHEL:

$ sudo yum install php

For Fedora:

$ sudo dnf install php -y

Let’s check the PHP version.

How to Check the PHP Version Using the php Command?

The “php” command utility can get the versions of the installed PHP. The functionality of the php command can be obtained via the following command:

$ php -help

Method 1: Using the php –version Command

The “-v” or “–version” options are utilized to check the existing PHP version in the Linux operating system:

$ php --version

Now, you can verify that the latest version “PHP 8.1.2-1ubuntu2.8” is displayed after executing the “php –version” command.

Method 2: Using the php -i Command

The PHP version can also be checked through the “-i” option to display all information regarding PHP. Using this option, users can visualize additional information about the current system on which PHP is installed:

$ php -i

After executing the above command, you can verify that “PHP Version => 8.1.2-1ubuntu2.8” is installed in the current operating system.

Bonus Tip: How to Check the Specific PHP Versions?

It is additional information to check the specific version of PHP. To do so, the “php<version_name>” option is utilized with the “– version” utility as seen below:

$ php7 --version


$ php8 --version

Now, you can only display a specific “PHP” version if it is installed in the operating system. Each version has specific functionality that users can utilize according to requirements.

That is all from this guide.


In the Linux system, the “php –version” or “php-v” commands are utilized to check the installed PHP version. Moreover, the “php -i” command can also be used to get the PHP version. This guide has explained various methods to check the PHP version in the Linux operating system.