Alternative PHP Cache (APC)是一种对PHP有效的开放源高速缓冲储存器工具,他能够缓存opcode的php中间码。PHP APC提供两种缓存功能,即缓存Opcode(目标文件),我们称之为apc_compiler_cache。同时它还提供一些接口用于PHP开发人员将用户数据驻留在内存中,我们称之为apc_user_cache。
一、用yum源码方式安装apc的依赖包
[root@monseng]# yum install php-pear php-devel httpd-devel pcre-devel gcc make
示例过程:
Dependencies Resolved
==========================================
Package Arch Version Repository Size
====================
Installing:
php-devel x86_64 5.4.16-48.el7 base 602 k
php-pear noarch 1:1.9.4-22.el7 base 357 k
Installing for dependencies:
libzip x86_64 0.10.1-8.el7 base 48 k
php-cli x86_64 5.4.16-48.el7 base 2.7 M
php-common x86_64 5.4.16-48.el7 base 565 k
php-process x86_64 5.4.16-48.el7 base 56 k
php-xml x86_64 5.4.16-48.el7 base 126 k
Transaction Summary
===========================================
二、使用pecl安装apc
[root@monseng]# pecl install apc
示例过程:
Enable internal debugging in APC [no] : yes
Enable per request file info about files used from the APC cache [no] : yes
Enable spin locks (EXPERIMENTAL) [no] : yes
Enable memory protection (EXPERIMENTAL) [no] : yes
Enable pthread mutexes (default) [no] : yes
Enable pthread read/write locks (EXPERIMENTAL) [yes] : yes
三、apc扩展到配置文件
echo "extension=apc.so" > /etc/php.d/apc.ini
(注:PHP7.2会自动完成,无需手工添加)
示例过程:
Build process completed successfully
install ok: channel://pecl.php.net/APC-3.1.13
Extension apc enabled in php.ini
第二、三步可根据需要订制。