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
Discussions

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
Ubuntu Default PHP Version - A few questions
SYSTEM INFORMATION OS type and version Ubuntu Linux 22.04.3 Virtualmin version 7.9.0 Background I am new to the linux universe. 😄 When I installed Ubuntu it came with PHP 8.1 ( I think) pre-installed and this is called the default PHP version. You can install different PHP versions by adding ... More on forum.virtualmin.com
🌐 forum.virtualmin.com
1
0
February 8, 2024
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
🌐
LinuxConfig
linuxconfig.org › home › how to check php version on ubuntu
How to check PHP version on Ubuntu
September 22, 2020 - Learn how to check your PHP version on Ubuntu via command line, interactive shell, and PHP scripts. Keep your server up-to-date!
🌐
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 - We can list packages as follows using the rpm command: $ rpm -qa | grep php If you are using Debian / Ubuntu Linux based system, type the following command to find out php version: $ dpkg --list | grep php Sample outputs indicating PHP installed ...
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to check php version
How to Check PHP Version | phoenixNAP KB
December 9, 2025 - The methods covered in this tutorial include running PHP code, using the command-line interface, or checking the version via plugins or WP dashboard. Next, check out how to make a redirect in PHP or see the 4 different types of errors in PHP. Was this article helpful? YesNo · Contents · Subscribe to our newsletterSUBSCRIBE · Next you should read · DevOps and Development SysAdmin How To Install and Use PHP Composer on Ubuntu ·
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/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.

🌐
Liquid Web
liquidweb.com › home › help docs › server administration › linux server administration › upgrading or installing php on ubuntu 22.04
Upgrading or Installing PHP on Ubuntu — PHP 8.2 and Ubuntu 22.04 | Liquid Web
December 15, 2025 - List all PHP modules available for download by checking the apt-cache, replacing [version] with the PHP version you are using. ... You can install multiple modules by listing them in a single command. ... If you upgraded PHP, create a module list for the upgraded version to compare with the old one. Replace [version] with your PHP version: ... Ubuntu 22.04 uses commands to manage Apache modules, determining the PHP version Apache loads.
🌐
OSTechNix
ostechnix.com › home › programming › php › how to switch between multiple php versions in ubuntu
Switch Between Multiple PHP Versions In Ubuntu - OSTechNix
May 2, 2025 - After a while you find out that ... PHP 7.2 (Ubuntu 18.04 LTS installs PHP 7.x by default). Are you going to reinstall PHP or the whole LAMP stack again? Not necessary. You don't even have to downgrade the PHP to its earlier version. You can simply switch to the previous working PHP version in couple minutes. Let us check the default ...
🌐
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 - Inside this file, use the phpinfo() function: ... 3. In your web browser, navigate to https://your-server/phpinfo.php (be sure to replace “your-server” with your server’s IP address or domain name).
🌐
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.
🌐
Wikihow
wikihow.com › computers and electronics › software › web programming › how to check php version: 3 ways on windows, mac, & linux
How to Check PHP Version: 3 Ways on Windows, Mac, & Linux
December 3, 2025 - To see which version of PHP is installed, open a command prompt or terminal, type "php -v", then press Enter or Return. If you can't access the command line, you can createa quick script or WordPress.
🌐
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 - root@ubuntu ~]# apt update ; apt install software-properties-common -y ; add-apt-repository ppa:ondrej/php · Step 2. Install different versions of PHP by the below commands. ... Step 3. You can check the PHP version from CLI using the below command.
🌐
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.
🌐
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 …
🌐
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.