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
Answer from Jignesh Joisar on Stack Overflow
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
Discussions

bash - Getting PHP Version for Currently Running Version - Stack Overflow
I have just built 3 different versions of PHP from source on an Ubuntu server (alongside NGINX and MySQL 5.7). I am looking for a way to run php --ini for the currently running version. I know I ha... More on stackoverflow.com
🌐 stackoverflow.com
How to check PHP version?
The URL given is one that works with the script they provide or expect you to write. There's no built-in "magic URL" to show that information with PHP. A HTML page of configuration information can be generated in PHP code using phpinfo() You may also want to pay attention to the top section of phpinfo() output that lists the ini files read, to make sure you're editing the right files. This same information is available on the command line through the following commands: php -i (full information similar to phpinfo()) php -m (enabled modules / extensions) php -v (version) php --ini (ini files read) See also php --help for more command-line options. Note that you can also set most ini settings at runtime in a script using ini_set() . In this specific case see also the error_reporting() function. More on reddit.com
🌐 r/PHPhelp
6
1
November 4, 2023
Which php version is default on Ubuntu 23.04?
Ondrej Sury maintains repositories with the latest PHP version for various Ubuntu releases. You may want to check that out so you can stay on an LTS release like 22.04 but get the PHP version you want: https://deb.sury.org/ More on reddit.com
🌐 r/Ubuntu
8
1
April 20, 2023
Question: finding version No
If you run this command you need to be in the Nextcloud home Directory, or run sudo -u www-data php /var/www/Nextcloud/occ status If you installed Nextcloud at /var/www/Nextcloud/ for example. You just need to specify the path to occ if you aren’t in the Nextcloud Directory with your ssh User. More on reddit.com
🌐 r/NextCloud
2
4
February 26, 2018
🌐
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 - The most reliable way to print PHP version from the Linux and Unix command line is to type the following command: $ php --version Outputs from my SUSE Enterprise/OpenSUSE Linux server:
🌐
LinuxConfig
linuxconfig.org › home › how to check php version on ubuntu
How to check PHP version on Ubuntu
September 22, 2020 - $ php -version PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies · What if we want a little more in depth information? You can start a PHP interactive shell (again, from the command line) and use the phpinfo function.
🌐
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 - 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, and voilà!
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to check php version
How to Check PHP Version | phoenixNAP KB
December 9, 2025 - ... The command outputs the PHP version number, build date, and copyright information. Note: If there is more than one PHP version installed on the server, the php -v command shows the default command-line interface (CLI) 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
There are several possibilities to check and validate PHP version on Linux. 1. Open a bash shell terminal and use the command “php –version” or “php -v” to get the version of PHP installed on the system.
Find elsewhere
🌐
Benjamin Crozat
benjamincrozat.com › home › blog › check php version: command line and browser methods
Check PHP version: command line and browser methods
August 11, 2025 - If you also need the framework version, here are 6 ways to check Laravel’s version. Run php -v in your macOS terminal. Run php -v in your Ubuntu terminal. Run php -v in your Windows command prompt.
🌐
Simplified
simplified.guide › php › check-version
How to check PHP version
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 -v PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend ...
🌐
TecAdmin
tecadmin.net › check-php-version
How to Check PHP Version (Apache, Nginx and CLI) – TecAdmin
April 26, 2025 - To determine the PHP version that is currently set as default for command line operations, run the subsequent command in the terminal: ... 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.
🌐
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. $ /path/to/php phpversion.php | grep "PHP Version" ... This method would work for all Linux distributions, as well as Windows and macOS. If you’ve relocated the PHP directory and can’t locate it, neither of the previous methods will work. In such cases, you can use a few command-line tools to find the PHP directory.
🌐
iSeePassword
iseepassword.com › blog › how-to-check-if-php-is-installed-on-ubuntu
How to Check If Php Is Installed on Ubuntu? – iSeePassword Blog
August 5, 2023 - To determine if PHP is installed on your system, you can follow these steps: 1. Check the Command Line: – Open the command prompt or terminal on your operating system. – Type “php -v” and press Enter. This command will display the current PHP version if PHP is installed.
🌐
Gcore
gcore.com › home › developers › how to check the php version
How to check your PHP version via CLI or PHP File | Gcore
April 8, 2025 - A Detailed Guide Explaining How to Verify the PHP Version on Your Server, Utilizing Either the Command Line Interface or a PHP File.
🌐
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?
March 21, 2025 - 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
🌐
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
🌐
Linuxize
linuxize.com › home › php › how to check the php version
How to Check the PHP Version | Linuxize
January 20, 2020 - To get the server version, invoke the php binary using the --version or -v option: ... The command will output information about the PHP version and exit.
🌐
Reddit
reddit.com › r/phphelp › how to check php version?
r/PHPhelp on Reddit: How to check PHP version?
November 4, 2023 -

hi, I'm new to PHP.

I want to change display_errors to On for debugging, but see many PHP versions installed.

I thought going to http://localhost/first/index.php?language=English&page=phpinfo would give me the version , but it just renders the regular index page.

Ty.

🌐
Linux Today
linuxtoday.com › home › blog
How to Check PHP Version in Linux (via 4 Methods) | Linux Today
November 8, 2024 - Learn how to check the PHP (or PHP-FPM) version on Ubuntu and other Linux distributions from the command line.