PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 9, 2022

[FIXED] Change PATH Environment Variable in MAMP

 January 09, 2022     macos, mamp, php     No comments   

Issue

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()

Apache Environment Variables

As you can see, it added the MY_TEST_DETAIL environment variable, but it did not change PATH.


Solution

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.



Answered By - Andrew Sinagra
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing