2012-02-10 2 views
2

몇 가지 질문을하고 싶습니다.
웹 서버 (apache2/php/debian)와 PHP를 보안상의 이유로 open_basedir 옵션으로 구성했습니다.
file_get_contents()를 사용하여 URL에 액세스해야하지만 경고 : file_get_contents() : open_basedir 제한 사항이 적용됩니다.
PHP 구성을 확인했고 allow_url_fopen이 켜져 있습니다.

개발 서버 (우분투 10.10)에서는 제대로 작동하지만 debian (6.0 squeeze)에서는 제대로 작동하지 않습니다. 어떤 생각 ??
URL에 PHP Open_basedir 제한

의 php.ini :

Open_basedir = /var/securedir/:/var/www 
allow_url_fopen = On 

PHP 코드 :



PHP 버전 수호신 - 패치
예와 5.3.3-7 + squeeze7 인
$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) 
+1

예제를 보여줄 수 있습니까? –

+0

PHP의 버전은 무엇입니까? https://bugs.php.net/bug.php?id=48603 – symcbean

+0

수호신 패치가있는 5.3.3-7 + squeeze7 – EsteveBlanch

답변

0

대신 cURL을 사용하여 내용을 가져 오지 않는 이유는 무엇입니까? 단지 코드의 몇 가지 추가 라인이 될 것 : file_get_contents 보안을 위협 않기 때문에이 서버에서 사용할 왜

function fetch_content($sUrl) { 

    $aOptions = array(
     CURLOPT_RETURNTRANSFER => true, 
     CURLOPT_HEADER   => false 
    ); 

    $cUrlHndl = curl_init($sUrl); 
    curl_setopt_array($cUrlHndl, $aOptions); 
    $binaryContents = curl_exec($cUrlHndl); 
    curl_close($cUrlHndl); 

    return $binaryContents; 
} 

, 즉이다. 경고는 php.ini 설정 파일에 열려는 경로가 포함되어 있지 않기 때문에 나타납니다.