The php that comes with mac is 7.1, and then my brew php7.2,phpinfo is php7.1, and php-v is 7.2?

the php that comes with mac is 7.1, and then my brew php7.2,phpinfo is php7.1, and php-v is 7.2. how do I use it?

php -v
PHP 7.2.1 (cli) (built: Jan  5 2018 17:34:14) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
    with Xdebug v2.6.0beta1, Copyright (c) 2002-2017, by Derick Rethans

clipboard.png

 php-fpm -v
PHP 7.1.19 (fpm-fcgi) (built: Aug 17 2018 18:03:20)
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
Dec.15,2021

php-v is executed by cli, and phpinfo is executed by web. It should be that the command line path of your cli is not updated.


as mentioned above, php-v is the php version of cli,phpinfo bound to your nginx or apache. Take nginx as an example

set different port numbers for different php-fpm, and use address plus port number as parameter at fastcgi_pass


find the libphp7.so path of php7.2
in the configuration file of apache, LoadModule php7_module modules/libphp7.so (here the path fills in the dynamic library path of 7.2)
then restart apache

< hr >

brew install php7.2 's fpm


I'll tell you how to switch php versions on mac
you see that phpinfo is seen on the web page, use php-fpm
to execute the command:
1.brew services stop php71
2.brew services start php72

Menu