‘php pyrus.phar’不会被执行

前端之家收集整理的这篇文章主要介绍了‘php pyrus.phar’不会被执行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在Debian上使用 PHP 5.3,并根据PHP -m’Phar’加载.

但是执行PHP pyrus.phar或PHP pyrus.phar config-show根本没有输出.

可能是什么问题?

debian:~# PHP -v
PHP 5.3.5-1 with Suhosin-Patch (cli) (built: Feb 19 2011 01:57:59)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0,Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.1.0,Copyright (c) 2002-2010,by Derick Rethans
    with Suhosin v0.9.32.1,Copyright (c) 2007-2010,by SektionEins GmbH

PHP -i给我:

[...]

Phar

Phar: PHP Archive support => enabled
Phar EXT version => 2.0.1
Phar API version => 1.1.1
SVN revision => $Revision: 305584 $
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
gzip compression => enabled
bzip2 compression => enabled
OpenSSL support => enabled


Phar based on pear/PHP_Archive,original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.
Directive => Local Value => Master Value
phar.cache_list => no value => no value
phar.readonly => On => On
phar.require_hash => On => On

[...]

令我困惑的是libxml2默认可用于PHP> 5.3.1,但PHP -m仅列出libxml.
虽然PHP -i会给我:

libXML support => active
libXML Compiled Version => 2.7.8
libXML Loaded Version => 20708
libXML streams => enabled
找到了 :)

似乎Debian将使用Suhosin补丁安装PHP版本.我自己的PHP -v输出显示如下:

web01:/home/berry# PHP -v
PHP 5.3.5-1 with Suhosin-Patch (cli) (built: Feb 19 2011 01:57:59) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0,Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.32.1,by SektionEins GmbH

现在,似乎Suhosin导致这个问题:它不允许执行phar文件.如果你看/var/log/user.log,你应该看到一个条目如下:

web01:/home/berry# tail /var/log/user.log | grep pyrus
Mar 23 11:27:50 web01 suhosin[17463]: ALERT - Include filename ('phar:///home/berry/pyrus.phar/PEAR2_Pyrus-2.0.0a2/PHP/PEAR2/Pyrus/ScriptFrontend/Commands.PHP') is an URL that is not allowed (attacker 'REMOTE_ADDR not set',file '/home/berry/pyrus.phar',line 40)

由于我们仅在cli上执行此操作,所以将下面的行添加到/etc/PHP5/cli/conf.d/phar.ini应该可以解决这个问题,它对我来说是这样的.

suhosin.executor.include.whitelist="phar"

祝你好运 :)

猜你在找的PHP相关文章