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
๐ŸŒ
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.
๐ŸŒ
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 - Explains Linux / Unix commands and a php script that can be used to check / find out php version running on the Linux or Unix server.
๐ŸŒ
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ร !
๐ŸŒ
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
๐ŸŒ
Simplified
simplified.guide โ€บ php โ€บ check-version
How to check PHP version
Run php -i from the command line. $ php -i | grep "PHP Version" PHP Version => 7.4.3 PHP Version => 7.4.3
Find elsewhere
๐ŸŒ
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.
๐ŸŒ
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 - There are multiple ways to find ... simplest way to find out the PHP version is by using the โ€œ-hโ€ or โ€œโ€“helpโ€ flag with the โ€œphpโ€ command in your command line....
๐ŸŒ
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.
๐ŸŒ
Benjamin Crozat
benjamincrozat.com โ€บ home โ€บ blog โ€บ check php version: command line and browser methods
6 ways to check your version of PHP in 2025 - Benjamin Crozat
August 11, 2025 - To check your PHP version, run php -v in your terminal. The first line shows your current version immediately. If you cannot use the terminal, phpinfo(), phpversion(), and Laravelโ€™s php artisan about command are the next easiest options.
๐ŸŒ
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.
๐ŸŒ
Geek Rewind
geekrewind.com โ€บ how-to-check-install-specific-version-of-php-in-ubuntu-linux
Check PHP Version and Install on Ubuntu 24.04 - Geek Rewind
December 28, 2021 - Next, run the commands below to add the repository. sudo add-apt-repository ppa:ondrej/php sudo apt-get update ยท After that, you can search for and install a specific version of PHP. ... Replace the x with the PHP minor version number and <complete version number> with the version number available for Ubuntu.
๐ŸŒ
dotlinux
dotlinux.net โ€บ blog โ€บ how-to-check-php-version-on-ubuntu
How to Check PHP Version on Ubuntu: A Comprehensive Guide
If php -v returns "command not found," PHP is not installed. Fix this by installing PHP: sudo apt update sudo apt install php # Installs the default PHP version (e.g., 8.1 on Ubuntu 22.04) ...
๐ŸŒ
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 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
๐ŸŒ
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.