前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >PHP5.4.36中APC与APCu的对比与感觉

PHP5.4.36中APC与APCu的对比与感觉

作者头像
星哥玩云
发布2022-07-04 14:16:37
5250
发布2022-07-04 14:16:37
举报
文章被收录于专栏:开源部署

APC全称Alternative PHP Cache,可选php缓存,包括opcache及用户变量缓存。

APCu仅包含用户变量缓存。

近段时间把服务器php从5.2.17升级到了5.4.36,apache也由2.2.22升级到了2.4.10,之前写的代码中使用了memcache、apc、zend optimization扩展,因此,想把整套都迁移到新的环境下。经过一段时间的实验,最终使用了php ts 5.4 版本,主要是为了使用ISAPI安装方式,而未使用推荐的FASTCGI。原因下面有叙述。

需要下载安装vc运行库,版本为VC9,下载地址http://www.microsoft.com/downloads/zh-cn/details.aspx?displaylang=zh-cn&FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf

VC12 为vc2013,VC11为Vc2012。

memcache顺理成章是没问题的,http://windows.php.net/downloads/pecl/releases/memcache/3.0.8/ 这个地址下载最新的windows下的memcache,php5.3、php 5.4、php 5.5、php 5.6都有对应的包,5.2对应的包已取消。

apc遇到新问题了,最新的APC http://windows.php.net/downloads/pecl/releases/apc/3.1.13/ 已经取消了5.2的支持,切已有一年多未更新版本了,看样子未来对于高版本的php支持也会成问题了,因此需要寻找新的方案。

后来发现,5.4下很多人用了这个http://windows.php.net/downloads/pecl/releases/apcu/4.0.7/ ,据说是官方新的推荐做法,不过经确认仅仅只有user caching,仅仅支持用户缓存,管理工具apc.php也有所变化。且无需配置,比APC配置简单了许多。

再次,zend optimization中也取消了5.2以上的支持,最新叫zend guard且只支持nts版本的php,只能使用fastcgi方式,支持5.3 5.4以上,也取消了5.2的支持。我想使用ts版本的php,因为在试用过程中发现,zend guard好像纯粹是为了解码新的加密代码了。可能是因为我系统的问题,导致fastcgi一直僵死,出现不定时的卡死,进程中发现很多的php-cgi.exe进程。所以后来为了解决问题,使用了新的推荐的opcache扩展,同样是官方支持php5.3、php5.4、 php5.5,这是纯粹的opcache。地址http://windows.php.net/downloads/pecl/releases/opcache/7.0.4/

需要php.ini中配置

[opcache] zend_extension = d:/wamp/php/ext/php_opcache.dll opcache.enable=1 opcache.memory_consumption = 128 opcache.interned_strings_buffer = 8 opcache.max_accelerated_files = 4000 opcache.revalidate_freq = 60 opcache.fast_shutdown = 1 opcache.enable_cli = 1

APCu默认自动配置情况下(通过apc.php查看):

Runtime Settings apc.coredump_unmap 0 apc.enable_cli 0 apc.enabled 1 apc.entries_hint 4096 apc.gc_ttl 3600 apc.preload_path  apc.rfc1867 0 apc.rfc1867_freq 0 apc.rfc1867_name APC_UPLOAD_PROGRESS apc.rfc1867_prefix upload_ apc.rfc1867_ttl 3600 apc.serializer php apc.shm_segments 1 apc.shm_size 32M apc.slam_defense 1 apc.smart 0 apc.ttl 0 apc.use_request_time 1 apc.writable /tmp

APC运行期的设置(通过apc.php查看)

[apc] apc.enabled = on apc.shm_segments = 1 apc.shm_size = 16M apc.user_entries_hint = 0 apc.user_ttl = 0 apc.cache_by_default = off apc.enable_cli = off apc.ttl = 0 apc.gc_ttl = 3600 apc.max_file_size = 1m ;apc.mmap_file_mask = apc.num_files_hint = 0 apc.optimization = 0 apc.report_autofilter = off apc.stat = off apc.write_lock = off apc.rfc1867 = off apc.canonicalize = 0 apc.use_request_time = 0 apc.filters = "" apc.slam_defense = off

Runtime Settings apc.cache_by_default  apc.canonicalize 0 apc.coredump_unmap 0 apc.enable_cli  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.num_files_hint 0 apc.preload_path  apc.report_autofilter  apc.rfc1867  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 16M apc.shm_strings_buffer 4M apc.slam_defense  apc.stat  apc.stat_ctime 0 apc.ttl 0 apc.use_request_time 0 apc.user_entries_hint 0 apc.user_ttl 0 apc.write_lock

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档