| Version 19 (modified by moo, 6 months ago) (diff) |
|---|
-
Frequently Asked Questions 常见问题
- 上哪寻求帮助?
- 为什么选择 XCache?
- ./configure 在哪?
- 如何从源代码安装 XCache?
- 提示 "undefined symbol" (符号未声明) 怎么办?
- 使用大于 4M 的 cache 导致 Apache2 不断 coredump (segv faults)
- 提示 "Cannot dynamically load xcache.so"
- 为什么无论我如何增加 shm 大小, 我的 misses 总是 > 0?
- 为什么我的缓冲区定期被清空?
- 我发现管理页面的 "hits" 很神经, 数字跳来跳去/忽高忽低
- 救命啊! 一运行就提示 "XCache requires Zend Engine API version NNN"
- xcache.so: undefined symbol: OnUpdateLong?
- xcache.so: undefined symbol: core_globals_id
- 错误: * is incompatible with XCache n Unknown on line 0
- 我看到有些文章介绍说启用 xcache.optimizer 设置可以获得更多的性能. 真的吗 ?
Frequently Asked Questions 常见问题
(这是 Faq 页面对应的中文翻译)
上哪寻求帮助?
- IRC
- freenode, 房间 #lighttpd (英文, 临时)
- 邮件列表
- XCache (xcache@…)
参见 GetSupport
为什么选择 XCache?
参见 XCache 介绍
./configure 在哪?
这个问题不错... 首先你得安装 php, 他能提供给你 "phpize" 可执行脚本, 您再执行
phpize
~/src/xcache $ phpize (一些提示信息 生成 configure) ~/src/xcache $ ./configure --help ~/src/xcache $ ./configure --enable-...
如何从源代码安装 XCache?
参考 GettingSource, BuildingFromSource, InstallingAsPhpExtension
提示 "undefined symbol" (符号未声明) 怎么办?
重新编译 XCache, 您用的 php 可能与 xcache 编译时候对应的 php 版本不符合.
另外避免使用 --enable-versioning 来 configure 编译 php, 除非您知道您在干什么. php 官方提供的这个功能已经有问题. 如果实在需要 enable-versioning, 您可以把 XCache 编译为 php 的静态模.
使用大于 4M 的 cache 导致 Apache2 不断 coredump (segv faults)
php.ini 里设置 "xcache.readonly_protection = On"
提示 "Cannot dynamically load xcache.so"
如果您看到 PHP Warning: Unknown(): Cannot dynamically load xcache.so - dynamic modules are not supported in Unknown on line 0 提示, 那么您的操作系统并不支持动态库, 使用静态编译的办法来解决:
静态编译
(将 xcache 源代码挪到 php 源代码目录下) ~ $ mv xcache php-src/ext/ ~ $ cd php-src/ ~/php-src $ ./buildconf --force ~/php-src $ ./config.nice --enable-xcache --enable-xcache-coverager (or if you havn't run configure yet, use:) ~/php-src $ ./configure --enable-xcache --enable-xcache-coverager --your-options ~/php-src $ make all ~/php-src $ make install
为什么无论我如何增加 shm 大小, 我的 misses 总是 > 0?
"Misses" 是 "hits" 的反义词. 每当 cache 里没有需要的缓冲项目, 则记为 misses. 只有第一次 miss 后并且缓冲起来了, 以后访问缓冲才是算到 hits 头上. 所以至少 misses = count(cached-php).
为什么我的缓冲区定期被清空?
如果您使用 FastCGI, 启动 php-fcgi 之前应该将环境变量 PHP_FCGI_CHILDREN 设置为 1 或者更大值.
再参考下一条问题.
我发现管理页面的 "hits" 很神经, 数字跳来跳去/忽高忽低
这种现象很正常. 具体现象是: 第一次打开管理页面发现 hits=300,000, 但是第二次载入管理页面却是 hits=1 的三次可能又是 hits=312,456.
这是因为您启动了多组 php 实例, 他们之间并没有共享内存. 但请记住, 在一个组内母 php 管辖的所有子进程是可以保证使用同一个共享内存. 那么如何配置并检查确保只用了一个组呢?
检查:
正确示例
$ pstree -p
| |-supervise(4913)---lighttpd(23975)-+-php-cgi(23979)-+-php-cgi(23981)
| | | |-php-cgi(23982)
| | | |-php-cgi(23983)
| | | `-php-cgi(23984)
错误示例
$ pstree -p
| |-supervise(4913)---lighttpd(23975)-+-php-cgi(23979)-+-php-cgi(23981)
| | | |-php-cgi(23982)
| | | |-php-cgi(23983)
| | | `-php-cgi(23984)
| +-php-cgi(23980)-+-php-cgi(23985)
| | | |-php-cgi(23986)
| | | |-php-cgi(23987)
| | | `-php-cgi(23988)
配置参考:
救命啊! 一运行就提示 "XCache requires Zend Engine API version NNN"
XCache requires Zend Engine API version 220051025. The Zend Engine API version 220060519 which is installed, is newer. Contact mOo at http://xcache.lighttpd.net for a later version of XCache.
您手头上的 XCache 的"编译版本"太老了. 例如, 您的 XCache 在 php A 版本下进行编译 而后来您将 php 升级到 A+1 版本. 简单办法就是下载新编译的版本, 或者您自己重新编译.
xcache.so: undefined symbol: OnUpdateLong?
查阅上一条问题.
xcache.so: undefined symbol: core_globals_id
可能是其他各种 *_globals_id 或者 *_id. 这说明您的系统里用来编译 XCache 的 php 头文件 (*.h 文件) 版本并不符合您的 php 可执行 (或者 mod_php )文件. 显然, 解决办法就是删除那些错误版本的头文件 重新编译 XCache.
- 删除头文件 在有些系统下, php 头文件属于 php-devel 软件包. 删除/重新安装这个包即可. 如果是手工删除则参考以下指令:
手工删除 php 头文件
(updatedb 可略) # updatedb # locate include/php/main /usr/lib64/php5/include/php/main /usr/lib64/php5/include/php/main/build-defs.h /usr/lib64/php5/include/php/main/php_scandir.h /usr/lib64/php5/include/php/main/php_regex.h ...... (现在删除) # rm -rf /usr/lib64/php5/include/php/ # cd php (重新安装头文件) php # make install
- 重新编译 XCache
重新编译 XCache
$ cd xcache $ make distclean $ phpize --clean $ phpize $ ./configure --enable-... && make $ su # make install
错误: * is incompatible with XCache n Unknown on line 0
在 php.ini 里使用 zend_extension=/path/to/xcache.so 或者 zend_extension_ts, 并注意他在其他 zend_extension=* 之前 (此条信息仅 3.0 以前有效)
我看到有些文章介绍说启用 xcache.optimizer 设置可以获得更多的性能. 真的吗 ?
目前 1.x 版本只支持 "cacher" 和 "coverager" 模块, 经过严格测试并已证明能正确工作. 目前 "optimizer" 没有 起任何作用, 这个功能目前只在 XCache 2.x 里有, 现在只是个雏型阶段.

