阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

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

97次阅读
没有评论

共计 3210 个字符,预计需要花费 9 分钟才能阅读完成。

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

CentOS 6.3 安装 LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm

在部署 LNMP 的时候遇到 Nginx 启动失败的 2 个问题 http://www.linuxidc.com/Linux/2013-03/81120.htm

Ubuntu 安装 Nginx php5-fpm MySQL(LNMP 环境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm

《细说 PHP》高清扫描 PDF+ 光盘源码 + 全套教学视频 http://www.linuxidc.com/Linux/2014-03/97536.htm

CentOS 6 中配置 PHP 的 LNMP 的开发环境  http://www.linuxidc.com/Linux/2013-12/93869.htm

PHP 的详细介绍 :请点这里
PHP 的下载地址 :请点这里

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计3210字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中