douao2019 2016-11-23 15:04
浏览 293
已采纳

在MAMP中更改PATH环境变量

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.

  • 写回答

1条回答 默认 最新

  • dongtanxi5676756 2016-12-23 22:22
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能