APC文件缓存不工作,但用户缓存是好的


APC File Cache not working but user cache is fine

摘要:我有PHP(5.3.8)安装为Apache模块,并通过PECL安装APC。用户缓存工作正常,但文件缓存不工作(我有apc。Cache_by_default设置为1,所以这不是问题)

细节:我刚刚得到了一个VPS(与cPanel/WHM)来测试我可以在使用apc文件缓存和用户缓存的应用程序中获得什么收益。

所以我得到了PHP 5.3编译为DSO (apache模块)。

然后通过SSH通过PECL安装APC。(首先,我尝试使用WHM模块安装程序,它也有同样的问题,所以我尝试通过ssh)

一切正常,phpinfo显示apc已加载并启用。

然后我检查了apc.php。

但是当我开始测试我的php应用程序时,apc中文件缓存信息状态的统计:

Cached Files    0 ( 0.0 Bytes)  
Hits    1  
Misses  0  
Request Rate (hits, misses) 0.00 cache requests/second  
Hit Rate    0.00 cache requests/second  
Miss Rate   0.00 cache requests/second  
Insert Rate 0.00 cache requests/second  
Cache full count    0  

这意味着没有PHP文件被缓存,即使我已经浏览了超过10个PHP文件有多个包含。所以一定有一些缓存文件。

但是用户缓存运行正常。

User Cache Information  
Cached Variables    0 ( 0.0 Bytes)  
Hits    1000  
Misses  1000  
Request Rate (hits, misses) 0.84 cache requests/second  
Hit Rate    0.42 cache requests/second  
Miss Rate   0.42 cache requests/second   
Insert Rate 0.84 cache requests/second  
Cache full count    0

上面的用户缓存输出来自APC缓存测试脚本,它试图检索和存储1000个条目并给我时间。一种简单的基准。

有谁能帮我一下吗?
尽管apc。Cache_by_default = 1,没有PHP文件被缓存

我的apc配置

Runtime Settings  
apc.cache_by_default    1  
apc.canonicalize    1  
apc.coredump_unmap  0  
apc.enable_cli  0  
apc.enabled 1  
apc.file_md5    0  
apc.file_update_protection  2  
apc.filters   
apc.gc_ttl  3600  
apc.include_once_override   0  
apc.lazy_classes    0  
apc.lazy_functions  0  
apc.max_file_size   1M  
apc.mmap_file_mask    
apc.num_files_hint  1000  
apc.preload_path    
apc.report_autofilter   0  
apc.rfc1867 0
apc.rfc1867_freq    0  
apc.rfc1867_name    APC_UPLOAD_PROGRESS  
apc.rfc1867_prefix  upload_  
apc.rfc1867_ttl 3600  
apc.serializer  default  
apc.shm_segments    1  
apc.shm_size    32M  
apc.slam_defense    1  
apc.stat    1  
apc.stat_ctime  0  
apc.ttl 0  
apc.use_request_time    1  
apc.user_entries_hint   4096    
apc.user_ttl    0    
apc.write_lock  1

大多数php文件都在20KB以下,因此,apc。max_file_size = 1M不是原因

我试着遵循这些方法,但都没有成功。

  1. 使用'apc_compile_file '强制一些文件进入操作码缓存,没有运气。
  2. 重新安装APC并启用调试,但error_log
  3. 中没有显示任何内容
  4. 设置mmap_file_mask为/dev/zero和/tmp/apc。xxxxxx,我还把/tmp权限设置为777,但无济于事
  5. 设置apc。enable_cli = 1并且从cli
  6. 运行脚本
  7. 设置apc。max_file_size = 5M(以防万一)
  8. 将php处理程序从dso切换到FastCGI在WHM(然后切换回dso,因为它没有解决问题)
  9. 尝试重新启动容器

有线索吗?

注意:我已经在serverfault.com上发布了这个问题,但没有得到太多的观点或答案,所以我在这里发布(因为stackoverflow似乎更活跃,我只有1个月来测试我的VPS,看看它是否有任何使用超过共享)

问题似乎出在SourceGuardian上。
注释掉extension="ixed.5.3 "后,文件缓存现在工作正常。Lin"来自php.ini。

这是由我的主机提供商的支持发现的,所以为这样的支持点赞。我几天后才会发现问题。

我觉得应该把答案贴出来,以防别人碰到这个问题。