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
🌐
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 - phpinfo() PHP Version => 7.4.3 System => Linux nixcraft-wks01 5.4.0-62-generic #70-Ubuntu SMP Tue Jan 12 12:45:47 UTC 2021 x86_64 Build Date => Oct 6 2020 15:47:56 Server API => Command Line Interface Virtual Directory Support => disabled Configuration File (php.ini) Path => /etc/php/7.4/cli Loaded Configuration File => /etc/php/7.4/cli/php.ini Scan this dir for additional .ini files => /etc/php/7.4/cli/conf.d Additional .ini files parsed => /etc/php/7.4/cli/conf.d/10-opcache.ini, /etc/php/7.4/cli/conf.d/10-pdo.ini, /etc/php/7.4/cli/conf.d/20-calendar.ini, /etc/php/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
🌐
Simplified
simplified.guide › php › check-version
How to check PHP version
php binary is available in default PATH variable for Ubuntu and other Linux variance if installed using the default package manager. You might need to use full path for the binary if it's manually installed or using other methods such as XAMPP for Windows. Run php -v from the command line. $ php ...
🌐
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.
🌐
LinuxConfig
linuxconfig.org › home › how to check php version on ubuntu
How to check PHP version on Ubuntu
September 22, 2020 - Feel free to pick whichever method is most convenient for your situation. ... We’ll start off with the quickest method. Open a command line terminal and type the following command. $ php -version PHP 7.4.3 (cli) ...
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to check php version
How to Check PHP Version | phoenixNAP KB
December 9, 2025 - Check your website's PHP version to avoid compatibility issues when installing new features. This tutorial shows steps to perform the check.
🌐
Linuxcnf
linuxcnf.com › 2018 › 05 › how-to-check-php-version-in-centos-7.html
The Linux Guide: How to check PHP version in Centos 7
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
🌐
TecAdmin
tecadmin.net › check-php-version
How to Check PHP Version (Apache, Nginx and CLI) – TecAdmin
April 26, 2025 - Output PHP 7.4.8 (cli) (built: Jul 13 2020 16:45:28) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies · On Ubuntu and Debian systems, you can also access another version by pointing their versions like: php7.2 or php7.3 etc.
Find elsewhere
🌐
FOSS Linux
fosslinux.com › home › ubuntu › how to check php version on ubuntu
Step-by-Step Guide: How to Check PHP Version on Ubuntu
August 4, 2023 - To check the PHP version, open up your Terminal. You can do this by searching for it in the ‘Show Applications’ menu or using the keyboard shortcut Ctrl + Alt + T. Once the Terminal is open, type in the following command: ... Press Enter, ...
🌐
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.

🌐
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 - Learn how to check the PHP (or PHP-FPM) version on Ubuntu and other Linux distributions from the command line.
Top answer
1 of 1
4

First part, what's installed.

This all goes back to package versioning schemes, and why you're getting confused. So, lets dissect it into its individual parts. Assuming it conforms to typical Debian versioning and such, then...

Take php7 you stated:

PHP 7.0.0-2+deb.sury.org~trusty+1

This string is dissected as follows:

  • PHP = the software name
  • 7.0.0 = the version of that software (from PHP's own versioning schemes)
  • -2 = the Package Revision number - that is, how many different packaging changes have been done - this would be the "Second Package" which means they made changes to the packaging or applied patches through quilt in the second version.
  • +deb.sury.org indicates the repository source - it's from deb.sury.org repos, which are actually PPAs running on Launchpad, with packages made by the one who runs the deb.sury.org website.
  • ~trusty+1 - This indicates additional version specific changes done for the repository - this is an Ubuntu Trusty, package, and likely is either the first or second revision of the package (depending on if they ever had +0 or not) specific for Trusty.

TL;DR: This is a PHP 7.0.0 package, but it has had a couple of revisions since the initial PHP 7.0.0 package.


Second part, how to get PHP 7.0.2.

The repository you are using is a PPA - likely this one.

It was informed to me that 7.0.2 is available and you need to run apt-get update && apt-get upgrade. That should put you on the right versions. If it doesn't, then try using apt-get dist-upgrade as there may be other dependencies that need added and the upgrade was held back because of that.

🌐
dotlinux
dotlinux.net › blog › how-to-check-php-version-on-ubuntu
How to Check PHP Version on Ubuntu: A Comprehensive Guide
sudo apt update sudo apt install php # Installs the default PHP version (e.g., 8.1 on Ubuntu 22.04) ... If php -v (CLI) shows a different version than phpinfo.php (web server), your web server is using a separate PHP installation.
🌐
ezeelogin
ezeelogin.com › kb › article › how-to-install-and-switch-different-versions-of-php-in-ubuntu-506.html
How to install and switch different versions of PHP in Ubuntu?
After completing above three steps, check php version by running the below command. ... PHP 8.2.19 (cli) (built: Apr 21 2022 10:16:36) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.29, Copyright (c), by Zend Technologies ... Step 1. View current version loaded in GUI by viewing the PHP configuration file. Run below command and view the configuration in browser with <server_ip>/phpinfo.php · root@ubuntu ~]# echo "<?php phpinfo()?>" >> /var/www/html/phpinfo.php
🌐
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 - It's very simple to check PHP version 1. PHP Info You can use the following to yield PHP version number via Command Line [bash]php -i[/bash] or You can create a php file contain the following, upload it to your website [php]phpinfo();[/php] Note: if your sys admin disabled phpinfo, you cannot ...
🌐
Linux Hint
linuxhint.com › check-php-version-linux
Check PHP Version Linux
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
eUKhost
eukhost.com › home › how to check your php version via ssh
How to check your PHP version via SSH - eukhost
July 3, 2024 - This command will output the PHP version installed on your server.