Checking Your PHP Version In Linux

If you are trying to figure out what version of PHP you are running on Linux then there are various ways to accomplish that. Below are some of the ways you can quickly and easily verify what version of PHP is installed.

The below command will be the easiest way to find it, if this fails though, please try some of the other methods listed.

Check PHP Version

Depending on what flavor of Linux you are running you can quickly and easily identify what version of PHP you are running by looking at your installed packages. Below are some commands based on different Linux distributions.

CentOS / Fedora / Red Hat

The first method below will generate a list of all packages currently installed and then pipe the output into grep so that we will only see the information we actually need.

This second method will use yum to take a look directly at the PHP package.

Debian / Ubuntu

The following commands will basically all give you the same information, what PHP packages and modules are installed as-well as what version they are.

Check PHP Package Version

Using PHPINFO() Function To Find PHP Version

If all else fails and you are certain you are running PHP then you could try one of the following. The first option will basically run the phpinfo() function inside your terminal and then find the php version, the second method will do the same but will actually go into a php file in your web directory.

Run PHP Inside Terminal

To create a simple PHP script that will run phpinfo() function, please modify the following to point to your web directory. After running the command you should be able to navigate to it by opening a browser and pointing it to your domain.com/phpinfo.php.

If you are still unable to verify what version of PHP you are running, you may want to double check that PHP is even installed.

I hope you liked this post, please don’t forget to comment/like/share. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *