【发布时间】:2012-02-10 11:24:48
【问题描述】:
我想问一些问题。
我有一个网络服务器 (apache2/php/debian),并且出于某些安全原因,PHP 配置了 open_basedir 选项。
我需要使用 file_get_contents() 访问 url,但我收到错误警告:file_get_contents(): open_basedir 限制生效。
我检查了 php 配置,并且 allow_url_fopen 已打开。
在开发服务器(ubuntu 10.10)中它可以正常工作,但在 debian(6.0 挤压)中它不能。有什么想法吗??
PHP 版本是 5.3.3-7+squeeze7 和 Suhosin-Patch
一个例子:
php.ini:
Open_basedir = /var/securedir/:/var/www
allow_url_fopen = On
php代码:
$a = file_get_contents("http://www.php.net");
Warning: file_get_contents(): open_basedir restriction in effect.
另一个问题是:
$b = file_get_contents("/var/securedir/file.xml")
Warning: file_get_contents(): open_basedir restriction in effect. File(/var/securedir/file.xml) is not within the allowed path(s): (/var/securedir/:/var/www)
【问题讨论】:
-
你能举个例子吗?
-
什么版本的 PHP?可能是bugs.php.net/bug.php?id=48603
-
PHP 版本是 5.3.3-7+squeeze7 和 Suhosin-Patch
-
一个例子是:
open_basedir = .:/var/securedir:/var/www $a = file_get_contents("http://www.php.net/"); -
您可能需要更改 Apache httpd.conf 中的 open_basedir 指令。 bigsoft.co.uk/blog/index.php/2007/12/30/…
标签: php apache2 debian open-basedir