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

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

藏色散人
Release: 2023-03-17 06:42:01
Original
1940 people have browsed it

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

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

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

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

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 to refresh the environment variable:

[[email protected] /]#source /etc/profile
Copy after login

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!

Related labels:
php
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