PHP:启用了APC,但仍然无法运行?

时间:2012-05-23 08:29:55

标签: php apc

在我的新Xubuntubox上,我安装了lamp-server工具,phpphp-apc,将extension=apc.so行添加到php.ini并重新引导系统。 Apache和PHP似乎运行良好,但APC没有。

所以我查看了apc.php文件会说的内容:

No cache info available. APC does not appear to be running.

但是在php信息中它似乎已启用。看看php -i | grep 'apc'说的是什么:

Additional .ini files parsed => /etc/php5/cli/conf.d/apc.ini,
apc
apc.cache_by_default => On => On
apc.canonicalize => On => On
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On             <- it is enabled
apc.file_md5 => Off => Off
apc.file_update_protection => 2 => 2
apc.filters => no value => no value
apc.gc_ttl => 3600 => 3600
apc.include_once_override => Off => Off
apc.lazy_classes => Off => Off
apc.lazy_functions => Off => Off
apc.max_file_size => 1M => 1M
apc.mmap_file_mask => no value => no value
apc.num_files_hint => 1000 => 1000
apc.preload_path => no value => no value
apc.report_autofilter => Off => Off
apc.rfc1867 => Off => Off
apc.rfc1867_freq => 0 => 0
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_ttl => 3600 => 3600
apc.serializer => default => default
apc.shm_segments => 1 => 1
apc.shm_size => 32M => 32M
apc.slam_defense => On => On
apc.stat => On => On
apc.stat_ctime => Off => Off
apc.ttl => 0 => 0
apc.use_request_time => On => On
apc.user_entries_hint => 4096 => 4096
apc.user_ttl => 0 => 0
apc.write_lock => On => On

正如预期php -m | grep 'apc'也找到了apc

你知道缺少什么,我不能正确使用它吗?

1 个答案:

答案 0 :(得分:9)

两种方式来运行PHP。

您正在显示PHP的CLI配置,并且apc.php未使用它。

的确,如果您通过浏览器检查phpinfo(),则可以看到没有加载任何APC扩展程序。

解决方案:在/etc/php5/cgi/conf.d/apc.inicgi而非cli)打开并再次粘贴您的配置。重新启动Web服务器(sudo service httpd restart)和voilà!

希望这有帮助!