Solution PHP environment variables under Linux without modification in force

This problem server has multiple PHP versions, php -vand phpinfo()show two different versions

Recently Really, I gave a friend to solve a problem. . .

phpinfoView the php version is 7.2.6, to use bash to php -vsee is indeed 5.4.2

Direct started to change environment variables, global permanent kind ~

vi /etc/profile

Added at the end corresponding to the path PHP

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

Save, and then make the configuration take effect

source /etc/profile

Use php -vto view or 5.4.2 version, environment variables still point to the old, did not take effect

In this way, first check the corresponding php.ini, use the command, found there are three php.ini

$ find / -name php.ini

/usr/local/php/etc/php.ini
/usr/local/php7.0/etc/php.ini
/etc/php.ini

Then use the command to view the PHP configuration file which is loaded, this acquisition is the location of php.ini in the system, not Apache or Nginx loaded php.ini file

$ php -i | grep php.ini

Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini

Find about the PHP system related to directory

$ find / -name php

We can see there is a/usr/bin/php

This should be the default installation of PHP server

ok, use the command to delete /usr/bin/phpa folder

rm -rf /usr/bin/php

Do not abuse, do not knock on the wrong carriage return

Let it take effect Configuration

source /etc/profile

Thus, in view of the Bash version of PHP is using phpinfo()to view the version of the

 

 php running version location

 

 

 

Guess you like

Origin www.cnblogs.com/yehuisir/p/11737217.html