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?

青灯夜游
Release: 2023-03-09 20:52:01
Original
3148 people have browsed it

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
Copy after login

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"
Copy after login

Finally save And exit and execute the following command:

source /etc/profile
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template