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?
Linux – Checking PHP Version
centoslinuxPHP
Related Solutions
I tried "php -v"
A command like this will only work if you have the CLI version of PHP installed. If you have only the Apache module version of PHP this will not work.
You can install the CLI version with this command:
apt-get install php5-cli
That should make the info and version commands work.
If PHP was installed via your package manager then a command like this might give useful results.
# dpkg -l | grep php
ii libapache2-mod-php5 5.3.3-7+squeeze17 server-side, HTML-embedded scripting language (Apache 2 module)
ii libphp-phpmailer 5.1-1 full featured email transfer class for PHP
ii libzend-framework-php 1.11.9-0ubuntu1 a simple, straightforward, open-source software framework for PHP 5
ii libzend-framework-zendx-php 1.11.9-0ubuntu1 a simple, straightforward, open-source software framework for PHP 5
ii php-apc 3.1.3p1-2 APC (Alternative PHP Cache) module for PHP 5
ii php-html-common 1.2.5-1 A base class for other HTML classes
hi php-html-template-it 1.3.0-1 Integrated Templates
...
If PHP wasn't installed with your package manager and instead manually installed, then you might have to simply create a PHP script that looks like this <?php phpinfo();
and then access that script through your web browser.
@blackhatblade above is most likely coorect. To test this, log in as both your root and non root user and try this command
# which php $ which php
"which" should tell you the path. If they are different, an unqualified "php" will execute the first one found in each list of directories.
It's also possible that your root user may have a shell "alias" remapping php. to check this, try the command "alias"
Finally, it's possible your php executable is a wrapper of some kind, which checks for root execution environment, and shunts you to the fcgi version. Check that by examining the fully qualified path you found in the first step from "which," and see if it's a shell script doing something sneaky based on who is running it.
Best Answer
Try running the following at the command line.
To just get the version information:
Or to get a lot of info:
It should give you all information you need about the php install.