can not modify PATH with putenv() running MAMP / P

2019-05-11 02:14发布

问题:

Config: MAMP Pro PHP 5.6.1 Mac OS X El Capitan

I need to add /user/local/bin to the system paths php can access

I've tried to use putenv()

but it seems like I can't change the value of environment variable PATH in php using putenv()

putenv('PATH=' . '/user/local/bin' . PATH_SEPARATOR . getenv('PATH') );

does not change the value

this works with other variables

PATH seems to be protected and I can not figure out where I can unprotect it - php ini settings do not seem to have anything regarding non-safe mode env vars.

does that ring a bel with anyone?

thanks

回答1:

Possibly protected by the new "rootless" or SIP(System Integrity Protection). I do not recommend disabling this feature unless you really know what you are doing, but disabling it could solve your problem.

More Info Here (wikipedia page) and how to Disable It Here (OS X daily)