Linux, PHP

How to find PHP version in Linux

There are many instances when we want to know which php version our server supports. It matters when you are trying to install some open source application like phpfreechat or Drupal 7.x it requires minimum PHP version to work. If you have access to console then there are various way to know else you can write script to get php info or even get header info of your site using curl which will show PHP version used for your website 😀

Below are some known methods that you may need (not all but at least one for sure) when you are dealing with your website setup related requirements/prerequisites.

how to find php version in linux
how to find php version in linux

Using command line

php –v or php --version

$ php -v

PHP 5.3.3 (cli) (built: Oct 26 2012 07:53:44)

Copyright (c) 1997-2010 The PHP Group

Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


$ php -i | grep 'PHP Version' 

Using rpm finder like

rpm –q php 

(want to know installed date as well type rpm –qi php)

Using dpkg for Debian

 dpkg --list | grep php 

Using yum (It informs you that which version of php is available for your distro ) in Redhat based

yum info php

Arch       : x86_64

Version   : 5.1.6

Release   : 40.el5_9

Size       : 2.4 M

Repo       : base (if it is installed then it will show  installed)


Using Curl for php (-I shows header info)

curl -I

Using php script

Or run a script by saving page as php-version.php which will have content as