Shr*_*eni 8 php phing nginx phar
我们在服务器上使用Ubuntu + nginx + php5-fpm组合,PHP版本为5.5.我们正在尝试运行index.php,其中包含一堆phar文件.就像是:
<?php
include "a.phar";
include "b.phar";
//...
?>
Run Code Online (Sandbox Code Playgroud)
当从命令行PHP运行此脚本时,它工作正常.当从php开发服务器(php -S)或从nginx运行时,我们收到以下错误:
2013/11/18 17:56:06 [error] 14384#0: *597 FastCGI sent in stderr: "PHP message: PHP Fatal error: Cannot redeclare class Extract_Phar in b.phar on line 103
Run Code Online (Sandbox Code Playgroud)
我没有一个名为Extract_Phar的类 - 所以我假设我的构建过程正在将它添加到某个地方.我使用phing来构建相同的,以防万一.目标是:
<target name="phar" depends="prepare">
<pharpackage destfile="./build/phar/LogUtils.phar"
basedir="./build/intophar"
compression="bzip2">
<fileset dir="./build/intophar/">
<include name="*.*" />
<include name="**/**" />
</fileset>
<metadata>
<element name="version" value="1.0" />
<element name="authors">
<element name="Shreeni">
<element name="e-mail" value="test@test.com" />
</element>
</element>
</metadata>
</pharpackage>
</target>
Run Code Online (Sandbox Code Playgroud)
而我的intophar文件夹中的index.php是这样的:
include("api/LogUtils.inc.php");
// Other relative include statements
Run Code Online (Sandbox Code Playgroud)
我根据其他答案玩过apc标志,并设置了以下内容:
apc.include_once_override = 0
apc.canonicalize = 0
apc.stat = 0
apc.enabled=0
apc.enabled_cli=0
apc.cache_by_default = 0
Run Code Online (Sandbox Code Playgroud)
这些都没有帮助,我们无法运行我们的代码.有什么建议?
小智 5
由于各种phar文件中的存根冲突,可能会发生此问题.尝试:
<?php
include "phar://a.phar/index.php"; // Assuming that the stub is index.php
include "phar://b.phar/index.php"; // Assuming that the stub is index.php
//...
?>
Run Code Online (Sandbox Code Playgroud)