如何向 Apache PATH 变量添加路径?

编程入门 行业动态 更新时间:2024-10-24 12:20:21
本文介绍了如何向 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 变量添加路径?

本文发布于:2023-05-31 10:05:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/389549.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   路径   Apache   PATH

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!