This is not strange. php -v runs php-cli , which in turn reads another ini file. phpinfo() is evaluated by your web server, which reads the ini file specific to the web server.
In the case of Ubuntu it is: /etc/phpX/apache2/php.ini and /etc/phpX/cli/php.ini , for nginx in your case php-fpm , whose configuration is in /etc/phpX/fpm/php.ini .
Also, in your case, PHP7 is probably compiled or pulled from another repo. If you want nginx to pick up PHP7, you need to either compile or install php7-fpm or something on these lines. YMMV depending on how you got PHP7 on your system.
To understand how this works, create a file anywhere in the file system inside your web folder, for example, test.php with the following contents:
<? phpinfo(); ?>
Then try running:
and then access this file from a web browser at http://path.to.your.site.com/path/to/test.php
You will see that cli PHP will report version 7.0, while nginx will continue to report PHP5.
favoretti
source share