open_basedir的 - 如何为特定的目录 [英] open_basedir - how to set for specific directory
问题描述
我有一个目录 / htdocs中/无担保
,我想限制无论是在该目录或从该目录之外的任何访问其子目录。在哪里以及如何设置的open_basedir
此目录只?
I have a directory /htdocs/unsecured
and I want to limit whatever is in that directory or its subdirectories from accessing anything outside of that directory. Where and how do I set open_basedir
for this directory only?
推荐答案
您可以设置的open_basedir
在Apache的配置文件,php.ini中,或在一个.htaccess文件
You can set open_basedir
in your Apache configuration file, php.ini, or in a .htaccess file.
我通常设置这个在Apache的配置文件,如/etc/httpd/conf/httpd.conf中。
I normally set this in an apache config file such as /etc/httpd/conf/httpd.conf.
您将有一个目录结构当前域/虚拟主机,你可以直接在里面添加一行:
You will have a directory structure for your current domain/virtual-host and you can add the line directly in there:
<VirtualHost 123.123.123.123:80>
<Directory /htdocs/unsecured>
php_admin_value open_basedir "C:/htdocs/unsecured"
</Directory>
</VirtualHost>
的注:的的 123.123.123.123
是您的域的IP地址的和的这个样本块可能漏掉了的很多的该配置只显示什么需要为的open_basedir
数据。
Note: The 123.123.123.123
is the IP address of your domain and this sample block potentially leaves out a lot of data for this configuration only showing what's needed for open_basedir
.
在php.ini文件,你可以这样做一个备受更一般的水平(而且将被应用到的每个的域服务器上)与:
In php.ini, you can do this on a much-more general level (and it will be applied to every domain on your server) with:
open_basedir = "/htdocs/unsecured"
在的.htaccess,你应该能够使用下面的(虽然我没有测试过):
In .htaccess, you should be able to use the following (though I haven't tested):
php_value open_basedir "/htdocs/unsecured"
修改(Windows路径)结果
每一个评论,你是在Windows上运行XAMMP(而不是使用虚拟主机)。有了这些信息,我建议把你的的open_basedir
规则在的php.ini
文件。你这应该(希望)工作:
EDIT (Windows path)
Per a comment, you're running xammp on Windows (and not using Virtual Hosts). With this information, I would suggest to put your open_basedir
rule in your php.ini
file. This should (hopefully) work for you:
open_basedir = "C:\xampp\htdocs\unsecured"
在Linux系统中,:
是一个字段分隔符。在Windows中,;
是分隔符 - 所以这个的应的工作,但我无法亲自测试
In linux, a :
is a field separator. In Windows, the ;
is the separator - so this should work, but I am unable to test it personally.
这篇关于open_basedir的 - 如何为特定的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!