Home  >  Article  >  Backend Development  >  What should I do if the php v version is wrong?

What should I do if the php v version is wrong?

藏色散人
藏色散人Original
2022-10-19 09:22:381842browse

php v The solution to the wrong version: 1. Search for php.ini on Linux; 2. Use the "#php -i | grep php.ini" command to view the php.ini loaded by cli; 3. , search for the "php/bin" directory and edit the "/etc/profile" file; 4. Add an environment variable to the last line as "export PATH="/usr/local/php/bin:$PATH"".

What should I do if the php v version is wrong?

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

php v What should I do if the version is wrong?

Solve the problem that the version viewed by php -v is inconsistent with the version printed by phpinfo() (LNMP environment)

Use phpinfo to print and find that the version is 7.2.31?

Copyright (c) 1997-2013The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Solution

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

[[email protected] ~]#find / -name php.ini
/usr/local/php/etc/php.ini/etc/php.ini

It is roughly guessed that the php configuration file loaded by php cli is inconsistent with the configuration file loaded by phpinfo(). Use the command to see which php.ini is loaded by cli:

[[email protected] ~]#php -i | grep php.ini

The result is:

What should I do if the php v version is wrong?

It is found that the loaded php.ini configuration file is indeed inconsistent, then search the php/bin directory and edit the /etc/profile file

[[email protected] /]#vim /etc/profile

Add an environment variable in the last line:

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

Finally save and exit and execute the following command to refresh the environment variable:

[[email protected] /]#source /etc/profile

php -v View version

What should I do if the php v version is wrong?

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.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if the php v version is wrong?. 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