different result between php -v and phpinfo()

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.