Home  >  Article  >  Backend Development  >  How to solve the problem of inconsistent php versions

How to solve the problem of inconsistent php versions

藏色散人
藏色散人Original
2020-12-02 09:07:152792browse

Solution to inconsistent php version: First search the php/bin directory; then edit the /etc/profile file; finally add an environment variable as "export PATH="/usr/local/php/bin:$PATH ""That's it.

How to solve the problem of inconsistent php versions

Recommended: "PHP Video Tutorial"

The operating environment of this tutorial: Windows 7 system, PHP version 7.2.6, This method works for all brands of computers.

Solution to the problem that the version viewed by php -v is inconsistent with the version printed by phpinfo()

The cause of the whole incident is this

Pulled through git I took the laraevl project and found that the .env file was missing. I planned to use composer install to generate a .env file. Then composer was prompted to use the minimum PHP version 7.1.3 and detected that my version was 5.4.16. The prompt is as follows:

# Then use phpinfo to print and find that the version is 7.2.6. The print result is as follows:

Solution

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:

Then check the result printed by phpinfo():

I found that the loaded php.ini configuration file was indeed inconsistent, and then searched the php/bin directory, Edited 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 agree to their loading configuration files. Finally, regarding the laravel .env file that cannot be pulled down, you can copy .env.local and rename it to .env

The above is the detailed content of How to solve the problem of inconsistent php versions. 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