在MAMP中设置环境变量? [英] Setting Environment Variables in MAMP?
问题描述
我假设可以在〜/.bash_profile中设置MAMP环境变量,但是似乎在那儿设置它们并不总是立即生效.例如,我只是在.bash_profile中设置了一个变量,并尝试重新启动MAMP服务器,重新启动MAMP本身,甚至登出计算机,但似乎没有任何效果.在我的环境中仍然无法访问该变量.有没有其他方法可以设置我丢失的MAMP env var,还是有需要清除的缓存?
I assume that MAMP environment variables can be set in ~/.bash_profile, but it seems that setting them there does not always take effect right away. For instance, I just set a variable in my .bash_profile and have tried restarting MAMP servers, restarting MAMP itself, and even logging out of my computer and nothing seems to work. The variable is still not accessible from within my environment. Is there another way to set MAMP env vars that I'm missing or is there a cache that I need to clear?
谢谢.
推荐答案
在启动apache时,MAMP会将/Applications/MAMP/Library/bin/envvars
的内容加载到其环境变量中.因此,您可以编辑文件并添加:
MAMP will load the contents of /Applications/MAMP/Library/bin/envvars
into its environment variables when starting apache. So you can edit the file and add:
MY_VAR="foo"
export MY_VAR
然后像这样访问该变量:
Then access that variable like so:
echo $_ENV["MY_VAR"];
打印:
foo
OSX优胜美地更新:
将envvars
重命名为_envvars
请参阅: MAMP Mavericks上的Pro 3.05已更新为优胜美地-Apache无法启动
这篇关于在MAMP中设置环境变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!