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
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
🌐
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
🌐
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, ...
🌐
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?
🌐
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.
Find elsewhere
🌐
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 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
🌐
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.
🌐
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
🌐
iSeePassword
iseepassword.com › blog › how-to-check-if-php-is-installed-on-ubuntu
How to Check If Php Is Installed on Ubuntu? – iSeePassword Blog
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.
Top answer
1 of 6
15

On Debian (and thus Ubuntu), the Apache configuration files are stored under /etc/apache2. In that directory, there are 2 sub-directories for configuring modules: mods-available and mods-enabled. When you install an Apache module (ie: foo), it will put foo.load (and possibly foo.conf) into the /etc/apache2/mods-available directory. When you enable an Apache module using a2enmod, it will create a symbolic link in /etc/apache2/mods-enabled for each of the matching files from /etc/apache2/mods-available.

Thus for an Ubuntu server with PHP5 enabled, you should see something like this:

$ cd /etc/apache2
$ ls -l mods-*/*php*
-rw-r--r-- 1 root root 133 2008-02-27 15:49 mods-available/php5.conf
-rw-r--r-- 1 root root  59 2008-02-27 15:49 mods-available/php5.load
lrwxrwxrwx 1 root root  27 2009-02-05 07:30 mods-enabled/php5.conf -> ../mods-available/php5.conf
lrwxrwxrwx 1 root root  27 2009-02-05 07:30 mods-enabled/php5.load -> ../mods-available/php5.load

If the php5 configuration files aren't shown in the mods-enabled directory, enable them as follows:

$ sudo a2enmod php5
$ sudo /etc/init.d/apache2 restart

Once you've done that, in order to test that PHP5 is configured, create /var/www/test.php as follows:

$ echo "<?php phpinfo(); ?>" | sudo tee /var/www/test.php
$ sudo chown www-data:www-data /var/www/test.php
$ sudo chmod 755 /var/www/test.php

Once that's done, you should be able to browse to /test.php on that server and see the PHP configuration data.

2 of 6
4

Use the phpinfo() function. Create a .php file that Apache will serve up and include the following:

<?php

phpinfo();

?>

When you navigate to the .php file, and php is installed, it should give you a whole lot of information about the php version you have installed.

🌐
eUKhost
eukhost.com › home › how to check your php version via ssh
How to check your PHP version via SSH - eukhost
July 3, 2024 - Multiple PHP Versions– If your server supports multiple PHP versions, you may need to specify the path to the PHP binary. For example: ... This command will display the loaded configuration files and directories. PHP Information Page: For a more comprehensive view of your PHP configuration, you can create a phpinfo.php file in your web directory with the following content: ... Access this file via your web browser to see detailed PHP information. This way, you can check your PHP version via SSH.