I don't understand at all why :
php -v
(or) php -m
return : PHP 7.0
and phpinfo() says I am using PHP 5.
it's strange, any idea?
I'm using Ubuntu and Nginx. Below is a printscreen :
Because every system is setup differently, phpinfo() is commonly used to check configuration settings and for available predefined variables on a given system. phpinfo() is also a valuable debugging tool as it contains all EGPCS (Environment, GET, POST, Cookie, Server) data.
The phpinfo() function can be used to output a large amount of information about your PHP installation and can be used to identify installation and configuration problems. To run the function, just create a new file called test. php and place it into the root directory of your web server.
Local and Master valuesThe Master Value is the value of the entry compiled into PHP or set in the main configuration php. ini file. The Local Value is the value of the entry in effect when you execute phpinfo. It's the result of using directives that can modify PHP's configuration like ini_set() or php_value in .
Checking PHP Information Using Hosting Control Panel Once you're logged in, scroll down and go to Advanced -> PHP Info. You'll then be forwarded to a page with detailed information about your current PHP version, modules, and values, etc.
It's not strange. php -v
runs php-cli
, which in turn reads a different ini file. phpinfo()
is evaluated by your webserver, which reads a webserver-specific ini file.
In case of Ubuntu, those are: /etc/phpX/apache2/php.ini
and /etc/phpX/cli/php.ini
, for nginx in your case it uses php-fpm
, whose config is located in /etc/phpX/fpm/php.ini
.
Also, in your case PHP7 is probably either compiled or pulled from some other repo. If you want nginx to pick up PHP7, you'll need to either compile or install php7-fpm
or something in those lines. YMMV depending on how you got PHP7 onto your system.
To get a feeling of how this works - create a file anywhere on the filesystem inside your web folder, say, called test.php
with the following content:
<?
phpinfo();
?>
Then try running:
# php test.php
and then access this file from a web browser at http://path.to.your.site.com/path/to/test.php
You'll see that cli PHP will report version 7.0, whereas nginx will keep reporting PHP5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With