How to modify the default php on mac: first create a ".bas_profile" file and edit it; then enter the php version you want in the file; then reload the environment variable through "source ~/.bash_profile" ;Finally run which php to view the default version of php.
Recommended: "PHP Video Tutorial"
Modify the default PHP version under MAC system
I encountered a problem today when using mac, because I need composer to pull laravel5.6, but it prompts me that the php version is too low, but I am using the integrated environment MAMP and have switched to php7.2 version, why doesn’t this take effect? After checking, it is because composer detects the PHP version in which the environment variables are effective under mac
$ which php /usr/local/bin
Thoughts
At first I wanted to uninstall the environment that comes with mac. After searching online, they all found the same thing. I deleted the directory on the left and on the right, but I couldn't delete it now. When I deleted it under the root user, it prompted me that I didn't have permission. I was obedient, and I went to Baidu as the root user and couldn't delete the file. , and then what flags problem was mentioned, then I removed the flags
#去除flags Mac [sudo] chflags nouchg filename
and then executed rm -rf and still got the same result
php: Operation not permitted
gg. This way is different. If anyone has studied it, please let me know.
Change environment variables to modify the default php version
Create a .bas_profile file and edit it
vim ~/.bash_profile
Then enter the php version you want in it
export PATH=/Applications/MAMP/bin/php/php7.2.7/bin:$PATH #/Applications/MAMP/bin/php/php7.2.7/bin是我的php版本路径
Save the reloaded environment variable
source ~/.bash_profile
Run which php to view the default version of php and get it
The above is the detailed content of How to modify default php on mac. For more information, please follow other related articles on the PHP Chinese website!