open_basedir 没有任何效果
对于我的网络托管面板,需要阻止用户访问其自己目录 (/var/www/u/s/username
) 之外的文件。 我尝试在 httpd.conf 中使用这一行来阻止人们访问目录。
<Directory /var/www/users/>
php_admin_value open_basedir .:/usr/lib/php5
</Directory>
但在php.ini
中,似乎没有效果。 我究竟做错了什么?
For my web hosting panel, users need to be blocked from accessing files outside their own directory (/var/www/u/s/username
). I tried to use this line in httpd.conf
to prevent people from going up a directory.
<Directory /var/www/users/>
php_admin_value open_basedir .:/usr/lib/php5
</Directory>
But in php.ini
, it seems to have no effect. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能是一个愚蠢的建议,但是您在更改 php.ini 后是否重新启动了网络服务器?
您可能尝试使用的另一种方法是使用“auto_prepend_file”指令附加一个文件,以包含一个脚本以将 open_basedir 指令收紧到当前用户目录:
来自 PHP.net (http://www.php.net/manual/en/ini.sect.safe-mode.php)
其他建议:
Apache 配置将需要正确设置 INI 覆盖才能有效。 确保您在服务器或虚拟主机的 Apache 配置中设置了“AllowOverride Options”或“AllowOverride All”。
https://www.php.net/configuration.changes
http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride
It might be a silly suggestion, but have you restarted the webserver after making the php.ini changes?
Another method you might try using is to append a file using the "auto_prepend_file" directive to include a script to tighten up the open_basedir directive to the current users directory:
From PHP.net (http://www.php.net/manual/en/ini.sect.safe-mode.php)
ADDITIONAL SUGGESTION:
The Apache configuration will need to be set up properly for INI overrides to be effective. Ensure that you have "AllowOverride Options" or "AllowOverride All" set in the Apache config for your Server or Virtual Host.
https://www.php.net/configuration.changes
http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride
您可能需要为每个用户目录添加一行:
请注意,此处的尾部斜杠是为了防止用户“username”访问“username2”目录。
You may need to add a line for each user Directory:
Note that the trailing slash is here to prevent user "username" from accessing a "username2" directory.
chdir('/wherever/you/want')
,其中包含“.” 扩展为/wherever/you/want
chdir('/wherever/you/want')
, having "." expanded as/wherever/you/want
您很可能修改了错误的“php.ini”。
Most probably you're modifying the wrong "php.ini".