安装没有问题,但是不能加载。到Apache的日志目录,查看error日志。可以看到一些报错信息:
QUOTE:
PHP Warning: Zend Optimizer does not support this version of PHP - please upgrade to the latest version of Zend Optimizer in Unknown on line 0
[Sat Apr 28 17:56:47 2007] [notice] Apache configured -- resuming normal operations
[Sat Apr 28 18:00:01 2007] [notice] SIGUSR1 received. Doing graceful restart
Failed loading /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: undefined symbol: compiler_globals
Failed loading /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: undefined symbol: compiler_globals
[Sat Apr 28 18:00:01 2007] [notice] Digest: generating secret for digest authentication ...
[Sat Apr 28 18:00:01 2007] [notice] Digest: done
[Sat Apr 28 18:00:01 2007] [notice] Apache configured -- resuming normal operations
[Sat Apr 28 18:04:15 2007] [notice] SIGUSR1 received. Doing graceful restart
Failed loading /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: undefined symbol: compiler_globals
Failed loading /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: undefined symbol: compiler_globals
Failed loading /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: undefined symbol: compiler_globals
Failed loading /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: undefined symbol: compiler_globals
[Sat Apr 28 18:04:16 2007] [notice] Digest: generating secret for digest authentication ...
[Sat Apr 28 18:04:16 2007] [notice] Digest: done
[Sat Apr 28 18:04:16 2007] [notice] Apache configured -- resuming normal operations
其中最突出的一条记录是:
QUOTE:
PHP Warning: Zend Optimizer does not support this version of PHP - please upgrade to the latest version of Zend Optimizer in Unknown on line 0
还有一条突出的是:
QUOTE:
/usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so: undefined symbol: compiler_globals
Failed loading /usr/local/Zend/lib/Optimizer_TS-3.2.6/php-5.2.x/ZendOptimizer.so:
原因分析
老实说,这个问题以前也没有遇到过。安装配置过不少Apache2+PHP5+ZendOptimizer,但是没有遇到这个情况。于是以compiler_globals作为关键字,在google上搜索,找答案。
后来找到一个来自Zend.com上的链接,进去后,得到了解答。
原文连接:
QUOTE:
http://www.zend.com/forums/index.php?t=msg&goto=9604&S=
其中有一位朋友的留言,说明了问题:
QUOTE:
i just notice that Zend Optimizer only support prefork mode.
Supported Web Servers:
Apache 1.3.x
Apache 2.0.x (Prefork mode only)
Apache 2.2.x (Prefork mode only)
IIS 5, 6
if you want to install Zend Optimizer ,hope this help you.
也就是说,导致加载ZendOptimizer失败的原因,是因为编译安装Apache2的时候,指定了worker模式 --with-mpm=worker ,Apache2运行在线程模式下。而ZendOptimizer只支持进程模式。也就是Apache2的prefork模式 --with-mpm=prefork 。
于是查看当前的Apache2是否支持了worker模式:
QUOTE:
# httpd -l
Compiled in modules:
core.c
worker.c
http_core.c
mod_so.c
果然,是支持worker模式。
解决办法
其实解决的办法很简单,只需要按照下面三个步骤进行,就可以了:
- 以 --with-mpm=prefork 参数重新编译安装Apache2
- 重新编译安装PHP
- 重新安装ZendOptimizer
在程序都重新编译安装完后,重启Apache,就可以了。
一些思考
所谓“鱼肉与熊掌,两者不可兼得”,目前Apache2+PHP,ZendOptimizer就只支持prefork模式。两者之间只能由使用者自己根据自己的实际需求来抉择了。
希望zend尽快开发出支持Apache worker模式的ZendOptimizer吧。