出于安全原因,我运行fastcgi php作为非特权用户“用户”,但看起来像运行php,因为不同的用户提供不同的能力,
我有一个奇怪的问题与PHP安装程序:
root@devz:~# su -c "php5 /www/root.php" user PHP Warning: file_get_contents(): SSL: Success in /www/root.php on line 3 PHP Warning: file_get_contents(): Failed to enable crypto in /www/root.php on line 3 PHP Warning: file_get_contents(https://twitter.com/): failed to open stream: operation failed in /www/root.php on line 3
和
root@devz:~# su -c "php5 /www/root.php" root <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de"> <head>....
root.php
<?php print file_get_contents("https://twitter.com/"); ?>
系统:Debian 6.0 64位与所有需要的更新,PHP:
root@devz:~# php -v PHP 5.3.6-8 with Suhosin-Patch (cli) (built: Apr 10 2011 22:41:22) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
也许有人有同样的问题? 如果是的话,请在这里注明。 谢谢!
如果你使用的是Suhosin,那么看看这个文档 。 Suhosin显式阻止获取url,文件和包含在不属于它的configuration的地方。
在Debian上,Suhosin日志默认是closures的,所以看看/etc/php5/conf.d/suhosin.ini并启用syslog日志选项来检查它是否真的阻止了你的请求。 如果这是问题,请在这个相同的文件中添加你想访问Suhosin白名单的URL,你的php应该可以正常运行。