代码改变世界

PHP APC安装与使用

2014-09-14 21:54  游乐场123  阅读(257)  评论(0编辑  收藏  举报

先要解决一下httpd-devel依赖库问题

yum install cyrus-sasl-devel db4-devel openldap apr apr-util apr-util-devel pcre-devel

手动安装:

官网 http://cn2.php.net/manual/zh/book.apc.php

下载http://pecl.php.net/package/APC 找最新的

 

#wget http://pecl.php.net/get/APC-3.1.9.tgz

# tar -zxvf APC-3.1.9.tgz
# cd APC-3.1.9
# phpize (生产configure文件)
# ./configure --enable-apc --enable-apc-mmap --with-apxs

./configure --enable-apc-mmap --enable-apc --enable-apc-filehits
# make
# make install

拷贝添加SO文件
# cp /usr/local/lib/php/extensions/no-debug-zts-20060613/apc.so /usr/local/php/lib/php/extensions/apc.so
# chmod 755 /usr/local/php/lib/php/extensions/apc.so
修改PHP.INI使之启动APC模块
修改 php.ini下
extension_dir = “./”
extension_dir = “/usr/local/php/lib/php/extensions”
配置/etc/php.ini 末尾加入
extension=apc.so
apc.enabled = 1
apc.cache_by_default = on
apc.shm_segments = 1
apc.shm_size = 64M
apc.ttl = 7200
apc.user_ttl = 7200
apc.num_files_hint = 1024
apc.write_lock = On
apc.gc_ttl=3600
apc.ttl=0
apc.mmap_file_mask=/tmp/apc.XXXXXX
重启apache

#/usr/local/apache2/bin/apachectl restart

 

使用APC

<?php

print_r(apc_cache_info());

?>