Lnmp 环境
1 安装apc配置:
cd /usr/src && tar xzf APC-3.1.4.tgz &&cd APC-3.1.4
/usr/local/php5/bin/phpize
./configure --enable-apc --enable-apc-mmap --with-php-config=/usr/local/php5/bin/php-config
make && make install
安装完后会生成一个apc.so在/usr/local/php5/lib/php/extensions/no-debug-non-zts-2006061
2 安装memcached,使fastcGI支持memcached
首先安装libevent
tar xzf libevent-1.4.12-stable.tar.gz
cd libevent-1.4.12-stable
./configure –prefix=/usr/local/libevent
make && make install
然后安装memcached //缓存加速
tar xzf memcache-2.2.5.tar.gz
cd memcache-2.2.5
/usr/local/php5/bin/phpize
./configure –prefix=/usr/local/memcached --with-libevent=/usr/local/libevent --with-php-config=/usr/local/php5/bin/php-config
make &&make install
安装完后,会在/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/里生成一个memcache.so
3 编辑php.ini
默认的php.ini在/usr/local/php/php.ini
把下面这些添加到最后:
extension = apc.so
//这里引用缓存模块
extension = memcache.so //这里引用缓存模块
[APC]
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64M
apc.optimization = 1
apc.num_files_hint = 0
apc.ttl=7200
apc.user_ttl=7200
apc.gc_ttl = 3600
apc.cache_by_default = on
安装到此已经完成!
重新启动nginx和php-fpm ,用测试页面即可访问。