Home > Backend Development > PHP Problem > How to modify default php on mac

How to modify default php on mac

藏色散人
Release: 2023-03-05 17:20:01
Original
3105 people have browsed it

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

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

and then executed rm -rf and still got the same result

php: Operation not permitted
Copy after login

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

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版本路径
Copy after login

Save the reloaded environment variable

source ~/.bash_profile
Copy after login

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!

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