Home >Backend Development >PHP Problem >What should I do if the versions viewed by php -v and phpinfo are inconsistent?

What should I do if the versions viewed by php -v and phpinfo are inconsistent?

青灯夜游
青灯夜游Original
2021-05-21 17:56:073157browse

Solution: First open the "/etc/profile" file, execute the "export PATH="/usr/local/php/bin:$PATH"" command and add an environment variable in the last line; then execute " source /etc/profile" command to save and exit.

What should I do if the versions viewed by php -v and phpinfo are inconsistent?

The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, PHP version 7.1, DELL G3 computer

php -v shows that the version is inconsistent with the version printed by phpinfo()

First check how many php.ini there are on Linux. It turns out that there are two:

I roughly guess that the php configuration file loaded by php cli is inconsistent with the configuration file loaded by phpinfo(). Use the command to view the php.ini loaded by cli. Which one is it:

php -i | grep php.ini

The result is:

What should I do if the versions viewed by php -v and phpinfo are inconsistent?

Then check the result printed by phpinfo():

It is found that the loaded php.ini configuration file is indeed inconsistent, then search the php/bin directory, Edit the /etc/profile file Add an environment variable in the last line:

export PATH="/usr/local/php/bin:$PATH"

Finally save And exit and execute the following command:

source /etc/profile

Summary

It is caused by the inconsistency between the php configuration file loaded by cli and the php configuration file loaded by the web server. Just unify their loading configuration files.

Recommended study: "PHP Video Tutorial"

The above is the detailed content of What should I do if the versions viewed by php -v and phpinfo are inconsistent?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn