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.

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

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退