Find Out PHP Version installed On Unix / Linux Server

Posted on in Categories , , , last updated January 21, 2013

How do I find out php version under Linux operating systems? How do I find out php version under Unix like systems? How to find out what version of PHP is installed on my server?

To find out php version installed on the server type the following commands:

$ php --version


$ php-cgi --version


$ php5-cgi --version


$ php5 --version
Sample output

PHP 5.3.3 (cgi-fcgi) (built: Jun 25 2012 04:38:39)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

I do not have SSH based access to my hosting server

If you can not login to your server using ssh commmand. Create a php script as follows (myversion.php):

// program to tell php version using ftp client

Upload the above file using ftp client and type the url:
Sample outputs:

Fig.01: What version of PHP am I running on my Unix / Linux / Windows server?
Fig.01: What version of PHP am I running on my Unix / Linux / Windows server?

Using package manager

Type the following command on RHEL / Red Hat / CentOS / Fedora Linux based system to find out php version:
$ yum info php
Sample outputs:

Loaded plugins: auto-update-debuginfo, protectbase, rhnplugin
0 packages excluded due to repository protections
Installed Packages
Name        : php
Arch        : x86_64
Version     : 5.3.3
Release     : 14.el6_3
Size        : 3.5 M
Repo        : installed
From repo   : rhel-x86_64-server-6
Summary     : PHP scripting language for creating dynamic web sites
URL         :
License     : PHP
Description : PHP is an HTML-embedded scripting language. PHP attempts to make it
            : easy for developers to write dynamically generated webpages. PHP also
            : offers built-in database integration for several commercial and
            : non-commercial database management systems, so writing a
            : database-enabled webpage with PHP is fairly simple. The most common
            : use of PHP coding is probably as a replacement for CGI scripts.
            : The php package contains the module which adds support for the PHP
            : language to Apache HTTP Server.

OR just list packages:
$ 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:

ii  libapache2-mod-php5                      5.3.3-7+squeeze14                  server-side, HTML-embedded scripting language (Apache 2 module)
ii  php5                                     5.3.3-7+squeeze14                  server-side, HTML-embedded scripting language (metapackage)
ii  php5-cgi                                 5.3.3-7+squeeze14                  server-side, HTML-embedded scripting language (CGI binary)
ii  php5-cli                                 5.3.3-7+squeeze14                  command-line interpreter for the php5 scripting language
ii  php5-common                              5.3.3-7+squeeze14                  Common files for packages built from the php5 source
ii  php5-gd                                  5.3.3-7+squeeze14                  GD module for php5
ii  php5-mysql                               5.3.3-7+squeeze14                  MySQL module for php5
ii  php5-suhosin                                            advanced protection module for php5

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

2 comment

  1. Hello,

    Firstly, I’d like to thank you for this post.
    Secondly, I’ll be thankful if you can tell me how can I know which Ajax version (or librairy) my php server is using ?

    For info, I’m using ClearOS with PHP 5.1.6 and I’m not able to use Ajax fonctions on this server, tried on xampp server on windows and it’s working fine.

    Many Thanks for your help.

  2. Hello
    i tried all of the above codes but nothing has displayed about php. so i imagine it is not installed in my vps ubuntu 14.04
    but apache is installed and working. How can i install php?

Leave a Comment