Try running the following at the command line.

To just get the version information:

php -v

Or to get a lot of info:

php -i

It should give you all information you need about the php install.

Answer from Paxxi on Stack Exchange
🌐
Reddit
reddit.com › r/centos › command to find php version
r/CentOS on Reddit: Command to find PHP version
March 17, 2022 -

This great technote tells me to use the php -v command.: https://www.linuxcnf.com/2018/05/how-to-check-php-version-in-centos-7.html Told command not found.

I do not have the info.php /var/www/html/ in this directory. I know I have php installed because mediawiki is already using it. I need to know the version before I start upgrading.

Discussions

linux - How to check if there are multiple versions of PHP installed on Ubuntu 12.04 LTS? - Stack Overflow
How to know if I have both php5.3 and php5.5 installed in my system? How to delete php5.3 if it is there and configuring Apache2 to work with php5.5? More on stackoverflow.com
🌐 stackoverflow.com
linux - PHP version switch on centos 7 - Stack Overflow
I have multiple version installed in my Linux centos vps server. when I check PHP version with the command php -v it gives me the result PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01) How to sw... More on stackoverflow.com
🌐 stackoverflow.com
Updates php on Centos 7 but phpinfo.php show older version - Unix & Linux Stack Exchange
And it's ok!But when I try to use ... the new version of owncloud I just installed it said: So I crear a phpinfo.php file to check what the owncloud said: ... [root@nube-preprod-clon ~]# rpm -qa | grep http httpd24-runtime-1.1-18.el7.x86_64 httpd24-httpd-tools-2.4.27-8.el7.1.x86_64 httpd-2.4.6-80.el7.centos.1.x86_64 ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
March 19, 2020
Command to find PHP version
That means you don't have php-cli package installed, which lets you do PHP stuff from the command line. If you're not planning on doing PHP stuff from the command line, you can just do rpm -qa | grep -i php to see a list of all of the installed PHP packages and their versions. More on reddit.com
🌐 r/CentOS
3
3
March 17, 2022
🌐
nixCraft
cyberciti.biz › nixcraft › howto › php › how to check php version
How to Check and Print PHP Version on Linux / Unix - nixCraft
April 9, 2024 - Type the following dnf command/yum command on RHEL / Red Hat / CentOS / Fedora Linux based system to find out php version: $ yum info php My CentOS 8 Linux server running PHP version 7.4.14: Last metadata expiration check: 1:21:08 ago on Thu ...
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to check php version
How to Check PHP Version | phoenixNAP KB
December 9, 2025 - The methods covered in this tutorial include running PHP code, using the command-line interface, or checking the version via plugins or WP dashboard. Next, check out how to make a redirect in PHP or see the 4 different types of errors in PHP. ... DevOps and Development Web Servers PHP Error Reporting: How to Enable & Display All Errors / Warnings · DevOps and Development SysAdmin How To Install PHP 7, 7.2 & 7.3 On CentOS 7
Top answer
1 of 9
108

I use the following command to view installed PHP versions in Ubuntu:

sudo update-alternatives --list php

Second way go to php directory where all PHP version configuration file stored:

cd /etc/php 
dir 

Output:

 > 5.6  7.0  7.1
2 of 9
40

Since you have a Linux environment, you can run this on your console:

locate bin/php

And then for anything that looks like a PHP binary, get the version. The output for me for the above is:

/home/xx/Development/Personal/Project1/webapp/bin/phpunit
/home/xx/Development/Personal/Project1/webapp-backup/vendor/bin/phpunit
/home/xx/Development/Personal/Project2/app/vendor/bin/phpunit
/home/xx/php-threaded/bin/php
/home/xx/php-threaded/bin/php-cgi
/home/xx/php-threaded/bin/php-config
/home/xx/php-threaded/bin/phpize
/usr/bin/php
/usr/bin/php5
/usr/local/bin/php-cgi
/usr/local/bin/php-config
/usr/local/bin/php53
/usr/local/bin/phpize
/usr/sbin/php5dismod
/usr/sbin/php5enmod
/usr/sbin/php5query

Out of those, there are a few that look like PHP binaries. So let's get the version for each:

/home/xx/php-threaded/bin/php -v
/usr/bin/php -v
/usr/bin/php5 -v
/usr/local/bin/php53 -v

That will give you the versions of PHP you have installed.

I wouldn't bother deleting an old version, it might remove files that will stop things working. You can just configure the console version, or the Apache version, to use the version you want.


In answer to your supplementary question: it seems that you've followed the instructions here to add an unofficial repo to your version of Ubuntu, since the standard repo does not support 5.5.

We discovered together that the way to get it working was first to upgrade Apache from 2.2 to 2.4:

sudo apt-get upgrade apache2

It should be noted that this can cause some vhost repair to be required, as some Apache directives changed in this version. Once you have done that, you can get the new version of mod_php:

sudo apt-get install libapache2-mod-php5
🌐
TecAdmin
tecadmin.net › check-php-version
How to Check PHP Version (Apache, Nginx and CLI) – TecAdmin
April 26, 2025 - Then press ‘Y’ and again hit Enter to save and exit from text editor. Next, open a web browser and access `https://localhost/phpinfo.php` URL. Update localhost with the IP address or the configured domain name on the system checking php version.
🌐
The Geek Diary
thegeekdiary.com › how-to-check-the-php-version-on-linux
How to check the PHP version on Linux – The Geek Diary
You can get the version of PHP installed using the phpinfo() function or using the commands "php --version" or "php -v". You can also check for the package versions installed on the system to get the PHP version.
🌐
Linuxcnf
linuxcnf.com › 2018 › 05 › how-to-check-php-version-in-centos-7.html
How to check PHP version in Centos 7 - The Linux Guide
May 14, 2018 - To check the PHP version from the web browser: create a file info.php in the web server's document root and Paste the following code. By default, on Apache, this would be: Save and quit the file info.php. Now, visit http://server-url/info.php · Installed PHP version display like above screenshot!!! By Rajkumar P. at ... How to zip/unzip the directory in Linux with comma... How to install zip/unzip package in Linux Centos 7
Find elsewhere
🌐
Simplified
simplified.guide › php › check-version
How to check PHP version
$ php -i | grep "PHP Version" PHP Version => 7.4.3 PHP Version => 7.4.3
🌐
Linuxize
linuxize.com › home › php › how to check the php version
How to Check the PHP Version | Linuxize
January 20, 2020 - Open your browser, go to yourdoman.com/phpinfo.php ,and the version of the PHP server will be displayed on your screen: Once you find out what PHP version you have, either remove the file or restrict the access to it.
🌐
HOSTAFRICA
hostafrica.com › home › how to install or upgrade to php 7 on centos 7 linux
How to Install or Upgrade to Php 7 On Centos 7 Linux - HOSTAFRICA
1 week ago - Running the command # php –version again should result in the PHP 7 version that you just installed. If you need any assistance with this guide on how to install or upgrade to PHP 7 on CentOS 7 Linux server, feel free to contact HOSTAFRICA today.
🌐
Unihost
unihost.com › help › how to upgrade php version on centos 7
How to upgrade PHP version on CentOS 7 - Unihost.FAQ
September 12, 2023 - This tutorial will show you how to upgrade PHP 5.4 to PHP 7.4 on CentOS 7 ... # php -v PHP 5.4.16 (cli) (built: Nov 1 2019 16:04:20) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies · As you can see the default PHP version is 5.4, and now we will update it.
🌐
Linux Hint
linuxhint.com › check-php-version-linux
Check PHP Version Linux
March 23, 2022 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Pixert
pixert.com › home › centos › how to check what php version running on linux?
How to check what PHP version running on Linux? - Pixert’s Blog
August 11, 2011 - in CentOS · It’s very simple to check PHP version · 1. PHP Info · You can use the following to yield PHP version number via Command Line · php -i · or · You can create a php file contain the following, upload it to your website · phpinfo(); Note: if your sys admin disabled phpinfo, ...
🌐
LinuxConfig
linuxconfig.org › home › how to check php version on ubuntu
How to check PHP version on Ubuntu
September 22, 2020 - Learn how to check your PHP version on Ubuntu via command line, interactive shell, and PHP scripts. Keep your server up-to-date!
🌐
Linux TLDR
linuxtldr.com › home › how to check php version in linux (via 4 methods)
How to Check PHP Version in Linux (via 4 Methods)
February 20, 2025 - Then, you have two options: either run the PHP server and access the PHP file in your web browser to check the PHP version, or pass the PHP file to the absolute path of the PHP binary file and use the grep command to find the PHP version.
🌐
Stack Overflow
stackoverflow.com › questions › 51857814 › php-version-switch-on-centos-7
linux - PHP version switch on centos 7 - Stack Overflow
I have multiple version installed in my Linux centos vps server. when I check PHP version with the command php -v it gives me the result PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01) How to sw...
🌐
Envato Tuts+
code.tutsplus.com › home › php › php scripts
How to Check the PHP Version | Envato Tuts+
June 30, 2020 - Mainly, if you have SSH access to your server, you can use the command-line interface to check it. On the other hand, if you don’t have terminal access, I’ll show you how to check the PHP version using the phpinfo function.