Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running Centos 5 and I need to know what version of PHP I'm running, is there a command for this which I can run?

share|improve this question
up vote 103 down vote accepted

try running any of the following at the command line

php -i

to get alot of info or

php -v

to just get the version information

It should give you all information you need about the php install.

share|improve this answer
+1 php -v was a lot faster – hyperslug Aug 24 '09 at 9:10
Thx, this worked :-) php -i | grep 'PHP Version' gave me the answer – Roland Aug 24 '09 at 9:12
Just be cautious that the CLI version of PHP (checked from command line) can be different from the one served by your webserver (shown by phpinfo()) – Akshay Raje Jun 4 '14 at 11:14

You can make an index.php file with

<?php phpinfo() ?>
share|improve this answer
this has the advantage of working on servers you don't have ssh access to, though personally I've always preferred <?php ?>, just for the futureproofing :P – Phoshi Aug 24 '09 at 10:56
Ah, right, I have a habit of using ASP tags. – hyperslug Aug 24 '09 at 21:26
On any PHP website one can often see the version in the X-Powered-By header in each PHP generated HTTP response. When you don't have SSH access, then sometimes can be used. (Though with much care, like one needs to check if a folder is writable before running a tar command.) – Arjan Sep 14 '09 at 16:21


more /etc/php.ini

This will show you:

  1. Apache Version
  2. PHP Versions
  3. PHP Functions
  4. Various options regarding PHP
share|improve this answer

It can usually be done remotely by checking the X-Powered-By HTTP Header

On-line Test @

Or try this against any website to see the headers:

 curl -I
share|improve this answer

An answer was accepted, but another option on RPM systems (RHEL, Centos, Fedora, etc.) is to use the following:

rpm -q php

And while I'm at it, the general method for using RPM to find info on a package for any rpm-installed program or file is similar to this (for awk):

  1. Find the full path to the file if not known, such as for an executable in $PATH:

    type -path awk

  2. Find the name, including version, of the package containing the file:

    rpm -qf /usr/bin/awk

  3. If desired, query for info from that package:

    rpm -qi gawk

It's a bit trickier for packages installed and used by Apache since they may not be on $PATH, but you can start with something like:

rpm -qa | egrep -i 'php|awk'

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.