我怎样才能像这样写 open_basedir -> open_basedir = 'var/home/*/'

发布于 2024-08-17 19:17:10 字数 265 浏览 5 评论 0原文

如你所知。你必须写 open_basedir = '/var/home'

我想这样写: open_basedir = '/var/home/*/'

我想要的是 php对于每个不同的目录,应该限制主目录中的每个目录。

简短的问题:我怎样才能像这样编写open_basediropen_basedir = 'var/home/*/'

非常感谢。

As you know. You have to write open_basedir = '/var/home' etc

I want to write like this: open_basedir = '/var/home/*/'

Which i want is php should restrict every directory which is in home directory, for every different directories.

Short question: How can i write open_basedir like this: open_basedir = 'var/home/*/'?

Thank you very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦过后 2024-08-24 19:17:10

如果要将 PHP 限制在每个用户自己的主目录中,则需要一个 PHP 设置,其中:

  1. PHP 使用用户凭据运行
  2. PHP 接受每个用户的配置

典型情况是 CGI(或 FastCGI)设置,而不是像下面那样运行 PHP阿帕奇模块。然后您可以为每个用户提供一个自定义 php.ini 文件。

顺便说一句,我还没有测试过它,但也许 open_basedir = "~" 按预期工作...

====== 编辑 ======

一些说明来自OP的评论:

  1. 在Unix shell中,“~”是“当前用户的主目录”的同义词,所以如果你是约翰,它是“/var/home/john”,它是“/var/home/michael” “如果你是迈克尔. “var/home/~/”没有特殊含义:它只是一个名为 ~ 的目录。

  2. 许多程序都使用这种 shell 约定。我不知道 PHP 是否这样做。

  3. CGI 允许在服务器上执行任意程序,因此它的安全性不如静态 HTML,就像滑板不如航天飞机安全一样。但我们不是在谈论执行任意程序:我们正在谈论执行 PHP 解释器。它将与 PHP 和您的环境一样安全。

  4. 如果您对此主题感兴趣,请 Google 搜索 FastCGI(具有增强性能的 CGI 实现)。许多托管提供商都使用它。

If you want to restrict PHP to each user's own home directory you need a PHP setup in which:

  1. PHP runs with the user credentials
  2. PHP accepts a per-user configuration

A typical case is a CGI (or FastCGI) setup, rather than running PHP as Apache module. Then you can provide a custom php.ini file for each user.

BTW, I haven't tested it but perhaps open_basedir = "~" works as expected...

====== EDIT ======

Some clarifications that arise from the OP's comment:

  1. In Unix shells, "~" is a synonym for "current user's home directory" so it's "/var/home/john" if you are john and it's "/var/home/michael" if you are michael. "var/home/~/" has no special meaning: it's just a directory that's called ~.

  2. Many programs use this shell convention. I don't know if PHP does so.

  3. CGI allows to execute arbitrary programs on the server so it is less secure than static HTML the same way that a skateboard is less secure than a space shuttle. But we are not talking about executing arbitrary programs: we are talking about executing the PHP interpreter. It'll be as as secure as PHP and your environment are.

  4. If you are interested in the subject, Google for FastCGI (a CGI implementation with enhanced performance). Many hosting providers use it.

旧人九事 2024-08-24 19:17:10

你可以。您必须在指令中指定每个路径:

open_basedir = "/var/home/path1/:/var/home/path2/:/var/home/path3/"

You can. You must specify each path in the directive :

open_basedir = "/var/home/path1/:/var/home/path2/:/var/home/path3/"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文