Home  >  Article  >  Backend Development  >  How to modify default php on mac

How to modify default php on mac

藏色散人
藏色散人Original
2020-09-03 10:25:082985browse

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.

How to modify default php on mac

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

How to modify default php on mac

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!

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