I need to update my PATH variable within a MAMP v3.4 server.
As you can see, the PATH environment variable that Apache is using does not match the PATH that I use when I open terminal.
<?php
passthru('env');
die();
The script above prints out:
...
PATH=/usr/bin:/bin:/usr/sbin:/sbin
...
Meanwhile, my PATH when I run my terminal is:
$ env
...
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I have tried the solutions offered here and here, but none have worked.
Setting an environment variable in /Applications/MAMP/conf/apache/httpd.conf
seemed promising, but it doesn't work when setting PATH.
# Near the top of my httpd.conf file...
SetEnv MY_TEST_DETAIL foo
SetEnv PATH /usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I restart my MAMP server, and looked at phpinfo()
As you can see, it added the MY_TEST_DETAIL environment variable, but it did not change PATH.
In MAMP 4.0.6 for OSX I was able to update the Apache Environment Path by doing the following:
First check /Applications/MAMP/Library/bin/apachectl
for a line with the comment:
#pick up any necessary environment variables
Just below this line you should see a path to where MAMP will load environment variables.
Mine said:
/Applications/MAMP/Library/bin/envvars
In the /Applications/MAMP/Library/bin
path you should see a file named envvars_
.
Copy this file and rename to envvars
and add the following line:
export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
Now restart your MAMP servers. The phpinfo should now have the updated path information.