Home > Article > Backend Development > How to solve the problem of inconsistent php versions
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.
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()
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
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!