apc xcache eaccelerator 安装配置

apc xcache eaccelerator 安装配置

1
<!-- ALL ADSENSE ADS DISABLED -->

三大php加速器安装配置,APC、eAccelerator、XCache ,我们来了解一下加速器的安装配置。apc xcache eaccelerator 安装配置:
一、Eaccelerator安装配置:

1、下载所需源码包:

http://blog.mgcrazy.com/download/eaccelerator-0.9.6.1.tar.bz2

我们开始编译安装:如下:
cd /usr/src && wget http://blog.mgcrazy.com/download/eaccelerator-0.9.6.1.tar.bz2 && tar jxvf eaccelerator-0.9.6.1.tar.bz2 && cd eaccelerator-0.9.6.1 && /usr/local/php/bin/phpize && ./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config &&make &&make test &&make install
安装完毕后会在/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/ 下生成一个eaccelerator.so模块文件。

2、修改php.ini配置在末尾加入如下:确保extension_dir为如下:
extension_dir=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626″
extension = eaccelerator.so
[eAccelerator]
eaccelerator.shm_size = “16″
eaccelerator.cache_dir = “/tmp/eaccelerator”
eaccelerator.enable = “1″
eaccelerator.optimizer = “1″
eaccelerator.check_mtime = “1″
eaccelerator.debug = “0″
eaccelerator.filter = “”
eaccelerator.shm_max = “0″
eaccelerator.shm_ttl = “0″
eaccelerator.prune_period = “0″
eaccelerator.shm_only = “0″
eaccelerator.compress = “1″
eaccelerator.compress_level = “9″

3、配置完毕后:
新建缓存文件夹: mkdir -p /tmp/eaccelerator &&chmod 777 /tmp/eaccelerator 即可。
重新加载php。 /etc/init.d/php-fpm reload ;或者重启apache、nginx。

可以查看phpinfo检查缓存模块是否已经加载上。

二、xcache 安装配置
Xcache是一个开源的操作码缓存器/优化器,它通过把解析/转换PHP后的操作码缓存到文件(直到原始代码被修改)从而避免重复的解析过程,提高了代码的执行速度
1、下载xcache目前稳定版本1.3.1
cd /usr/src && wget http://blog.mgcrazy.com/download/xcache-1.3.1.tar.gz && tar xzf xcache-1.3.1.tar.gz && cd xcache-1.3.1 && /usr/local/php/bin/phpize &&./configure –enable-xcache –enable-xcache-coverager –enable-xcache-optimizer –with-php-config=/usr/local/php/bin/php-config &&make && make install
安装完后会在=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/下生成一个xcache.so模块。

2、修改php.ini
默认的php.ini在/usr/local/php/lib/php.ini 你也可以指定:
extension_dir = “./”
修改为
extension_dir=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626″
把下面这些添加到最后:

[xcache-common]
extension = xcache.so
xcache.admin.auth = On
xcache.admin.user = “mz”
; xcache.admin.pass = md5($your_password) md5加密的密码
xcache.admin.pass = “password”
xcache.shm_scheme = “mmap”

xcache.size = 64M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
xcache.count = 8
; just a hash hints, you can always store count(items) > slots
xcache.slots = 8K
; ttl of the cache item, 0=forever
xcache.ttl = 0
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval = 0
; same as aboves but for variable cache
xcache.var_size = 250k
xcache.var_count = 1
xcache.var_slots = 8K
; default ttl
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = Off
xcache.mmap_path = “/tmp/xcache”
xcache.coredump_directory = “/tmp/phpcore/”
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off
[xcache.coverager]

xcache.coverager = Off
xcache.coveragedump_directory = “”

配置中可以参考:http://flash520.blog.163.com/blog/static/344144752007111555926809/
3、生成xcache文件
生成Xcache缓存文件
touch /tmp/xcache &&chmod 777 /tmp/xcache

生成Xcache管理员的秘密(MD5密文)

echo -n “123456″ | md5sum

e10adc3949ba59abbe56e057f20f883e

然后将上述生成的MD5密文粘贴到php.ini文件中xcache.admin.pass = “”选项,xcache.admin.pass = “e10adc3949ba59abbe56e057f20f883e”

拷贝Xcache管理程序到网站根目录下
cp -a /tmp/xcache-1.3.0/admin/ /usr/local/nginx/html/

然后重新启动PHP,然后访问http://localhost/admin ,用户名为xcache 密码为123456;另外,还可以通过phpinfo来验证PHP是否支持Xcache。

本文参考 :

http://flash520.blog.163.com/blog/static/344144752007111555926809/

http://blog.luwenju.com/79.html

三、apc安装配置:

1.首先下载好需要的安装包:前提是你的网站已经运行于php,也就是有php安装环境。
cd /usr/src && tar xzf APC-3.1.7.tgz &&cd APC-3.1.7 && /usr/local/php5/bin/phpize && ./configure –enable-apc –enable-apc-mmap –with-php-config=/usr/local/php/bin/php-config &&make&& make install

安装完后会生成一个apc.so在/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/里面。

2、接下来修改php.ini
默认的php.ini在/usr/local/php5/lib/php.ini 你也可以指定:
extension_dir = “./”
修改为
extension_dir=”/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626″
把下面这些添加到最后:
extension = apc.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

三大php加速软件配置完毕,apc xcache eaccelerator 安装配置完毕!

 

 

http://blog.mgcrazy.com/thread-1024-1.html  更多精彩文章!

你可能感兴趣的:(PHP,nginx,cache,配置管理,Blog)