• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to check the PHP version on Linux

by admin

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.

# php --version
PHP 5.4.16 (cli) (built: Mar  7 2018 13:34:47) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
# php -v
PHP 5.4.16 (cli) (built: Mar  7 2018 13:34:47) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

As you can see from both the command output above, the system has PHP 5.4.16 installed.

2. You can also check for the package versions installed on the system to get the PHP version.
On RedHat Based Distributions :

# rpm -qa | grep php
php-common-5.4.16-43.el7_4.1.x86_64
php-pdo-5.4.16-43.el7_4.1.x86_64
php-mysql-5.4.16-43.el7_4.1.x86_64
php-mbstring-5.4.16-43.el7_4.1.x86_64
php-cli-5.4.16-43.el7_4.1.x86_64
php-gd-5.4.16-43.el7_4.1.x86_64
php-5.4.16-43.el7_4.1.x86_64

On debian based distributions :

# apt list --installed | grep php

3. Let’s create a PHP file with content as shown below. The phpinfo() function outputs a great deal of information about the state of the current PHP environment, including loaded extensions, compilation options, version, server information, and so on.

# echo "<?php phpinfo();?>" > /var/www/html/phpinfo.php

4. Now, considering that Apache is installed and working, open a browser and test PHP using address as follow:

http://server/phpinfo.php

how to check PHP version in Linux

Filed Under: Linux

Some more articles you might also be interested in …

  1. aplay: command not found
  2. aws-shell: command not found
  3. pacman-key: command not found
  4. btrfs rescue Command Examples in Linux
  5. fprintd-enroll Command Examples in Linux
  6. cordova: Mobile apps with HTML, CSS & JS
  7. mcs Command Examples
  8. renice: command not found
  9. How to uninstall postgresql-client-common software package in Ubuntu
  10. lvremove Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright