【发布时间】:2012-07-26 21:37:46
【问题描述】:
我 have had this problem before on WAMP Server and PHP 5.3,现在在 Linux 上使用 PHP 5.4 面对它。
基本上,启用或禁用 APC 对性能没有影响,尽管 apc.php 中的统计数据显示。
这是一个示例测试脚本,其中包含 30 多个 Doctrine PHP 文件,并对其进行了计时:
$t = microtime(true);
include 'Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';
printf('%.3f s', microtime(true)-$t);
- Windows 上的结果(Zend Server CE,PHP 5.4):
0.001 s - Linux 上的结果(PHP 5.4 和 APC 3.1.11):
0.106 s
注意:即使上面脚本中没有显示,我实际上是在使用文件的完整路径,而不是依赖于 include_path。
无论apc.enabled是0还是1,我在Linux上得到的结果都是一样的,所以看起来操作码缓存不起作用。
但是,apc.php 说:
软件包(来自remi repository,CentOS 6.3):
php-5.4.5-1.el6.remi.x86_64
php-pecl-apc-3.1.11-1.el6.remi.1.x86_64
APC 配置:
apc.enabled=1
apc.shm_segments=1
apc.shm_size=64M
apc.num_files_hint=1024
apc.user_entries_hint=4096
apc.ttl=7200
apc.use_request_time=1
apc.user_ttl=7200
apc.gc_ttl=3600
apc.cache_by_default=1
apc.file_update_protection=2
apc.enable_cli=1
apc.max_file_size=1M
apc.stat=1
apc.stat_ctime=0
apc.canonicalize=0
apc.write_lock=1
最后一件事,是的,PHP 确实报告 APC 已启用:
var_dump(extension_loaded('apc')); // (bool) true
【问题讨论】:
-
我也遇到了同样的问题!如果有人可以提供帮助,我会很高兴。
-
关于 Stack Overflow 的一个很好的 PHP 问题?所有的支持!