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 - 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) (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?
🌐
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, ...
🌐
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 - For instance: $ php -i $ php -i | more # see if PHP pdo module loaded or not # $ php -i | grep pdo · 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/1
🌐
Simplified
simplified.guide › php › check-version
How to check PHP version
$ apt show php Package: php Version: 2:7.4+75 Priority: optional Section: php Source: php-defaults (75) Origin: Ubuntu Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> Original-Maintainer: Debian PHP Maintainers <team+pkg-php@tracker.debian.org> Bugs: https://bugs.laun...
🌐
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.
🌐
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.
Find elsewhere
🌐
ItSolutionstuff
itsolutionstuff.com › post › how-to-check-current-php-version-in-ubuntuexample.html
How to Check Current PHP Version in Ubuntu? - ItSolutionstuff.com
May 14, 2024 - I explained simply about ubuntu check php versions installed. If you want to check your current installed PHP version in ubuntu, Then I will help you how to check it. we can use php -v command to check current running PHP version in ubuntu.
🌐
dotlinux
dotlinux.net › blog › how-to-check-php-version-on-ubuntu
How to Check PHP Version on Ubuntu: A Comprehensive Guide
You’ll see a detailed PHP info page. The PHP Version is prominently displayed at the top (e.g., 8.1.2). The phpinfo.php file exposes sensitive server details (e.g., database credentials, paths). Delete it after checking: ... Ubuntu uses dpkg (Debian Package Manager) to track installed software.
🌐
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
🌐
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 - This method would only work for Debian or Ubuntu-based distributions; if you’re uncertain about the Linux distribution you’re running, use the command “cat /etc/os-release” to identify it. In this article, you’ve learned various methods to check the PHP version running on your Linux system.
🌐
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
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to check php version
How to Check PHP Version | phoenixNAP KB
December 9, 2025 - If you are implementing new features, installing a new PHP-based app, or trying to locate a bug on your website, it is important to know which PHP version your web server is running. In this tutorial, you will learn how to check your PHP version on a local machine, server, or WordPress website.
🌐
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.
🌐
Linuxize
linuxize.com › home › php › how to check the php version
How to Check the PHP Version | Linuxize
January 20, 2020 - In this article, we’ll show you how to check what version of PHP your server is running. There are some important differences between PHP versions, so knowing …