如何向 Apache PATH 变量添加路径? [英] How do I add paths to the Apache PATH variable?

查看:34
本文介绍了如何向 Apache PATH 变量添加路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 apache2 的 custom.conf 文件中设置了这个:

I've set in my custom.conf file in apache2 this:

SetEnv PATH $PATH:/opt/local/lib/mysql5/bin:/this-is-a-test

但是它不起作用.当我打电话时:

However it's not working. When I call:

$hey = shell_exec('env'." 2>&1"); var_dump($hey);

我明白了:

... PATH=/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/opt/local/bin

有人可以帮忙吗?我在 Mac 上使用 Macports 作为我的开发环境.谢谢!

Can anyone help? I'm on Mac using Macports for my development environment. Thanks!

推荐答案

对我来说,您试图从 Apache 中设置 PATH 似乎非常奇怪.相反,您应该为您的系统设置 PATH.在 Mac OS X 中有几种方法可以做到这一点:

That seems awfully strange to me that you are trying to set the PATH from within Apache. Instead, you should be setting the PATH for your system. There are several ways to do this in Mac OS X:

特定于用户
对于单个用户,您可以编辑 ~/.profile 并添加:

User-specific
For a single user, you can edit ~/.profile and add:

export PATH="$PATH":/opt/local/lib/mysql5/bin:/this-is-a-test

或者您可以创建/编辑 ~/.MacOSX/environment.plist 并以这种方式定义 PATH.

Or you can create/edit ~/.MacOSX/environment.plist and define the PATH that way.

全系统
在较新版本的 Mac OS X 上,有一个名为/etc/paths"的文件和一个名为/etc/paths.d"的文件夹,允许您扩展默认路径.基本上,您将在/etc/paths.d"中创建一个文件,其中列出了您希望添加到默认路径的所有路径.在不支持此功能的 Mac OS X 版本上(您可以根据/usr/libexec/path_helper"是否存在来判断),可以通过将上面的 export 语句放在/etc/profile 中来编辑所有用户的默认路径.

System-wide
On newer versions of Mac OS X, there is a file named "/etc/paths" and there is a folder named "/etc/paths.d" that allow you to extend the default paths. Basically, you would create a file in "/etc/paths.d" that lists all the paths that you wish to add to the default paths. On versions of Mac OS X that do not support this (you can tell based on whether "/usr/libexec/path_helper" exists), one can edit the default paths for all users by placing the export statement above in /etc/profile.

这篇关于如何向 Apache PATH 变量添加路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆