为PHP添加xcache缓冲加速模块
http://xcache.lighttpd.net/ 最新稳定版本 Ver 1.2.2
首先通过
-
wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz
获取最新的稳定版 Ver1.2.2 源码包
然后对源码包进行编译安装
-
tar -xzvf xcache-1.2.2.tar.gz
-
cd xcache-1.2.2/
-
/usr/local/php526/bin/phpize
-
./configure –with-php-config=/usr/local/php526/bin/php-config –enable-xcache
-
make
-
make install
-
cd ../
对xcache做配置
-
cat xcache.ini >> /usr/local/php526/conf/php.ini
或直接编辑 /usr/local/php526/conf/php.ini 添加后面的一些
-
[xcache-common]
-
zend_extension="/usr/local/php526/lib/php/extensions/no-debug-non-zts-20060613/xcache.so"
-
-
[xcache.admin]
-
xcache.admin.user = "xcache"
-
; xcache.admin.pass = md5("password")
-
xcache.admin.pass = "5f4dcc3b5aa765d61d8327deb882cf99"
-
-
[xcache]
-
xcache.cacher = On
-
xcache.shm_scheme = "mmap"
-
xcache.size = 32M
-
; cpu number (cat /proc/cpuinfo |grep -c processor)
-
xcache.count = 2
-
xcache.slots = 8k
-
xcache.ttl = 0
-
xcache.gc_interval = 0
-
xcache.var_size = 2M
-
; cpu number (cat /proc/cpuinfo |grep -c processor)
-
xcache.var_count = 2
-
xcache.var_slots = 8K
-
xcache.var_ttl = 0
-
xcache.var_maxttl = 0
-
xcache.var_gc_interval = 300
-
xcache.readonly_protection = Off
-
xcache.mmap_path = "/dev/zero"
验证xcache安装
1. 通过 /usr/local/php526/bin/php -v 查看有如下信息
PHP 5.2.6 (cli) (built: Jul 11 2008 00:02:23)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2006, by mOo
2. 重新启动 phpfastcgi 进程,在网站下面做一个 php 页面包含
-
<?php
-
echo phpinfo();
-
?>
其中在 php credits 前面可以看到 有 eaccelerator 加载的标志。
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with XCache v1.2.2, Copyright (c) 2005-2006, by mOo
xcache 和 前面文章中介绍安装的 eaccelerator 功效差不多。
网上有人做了这两个缓冲器的对比,php缓冲器:eaccelerator与xcache性能测试对比 显示结果相差不大,可以按照自己的喜好使用其中一个。
Popularity: 4% [?]
Related
为php添加eaccelerator代码缓冲加速器
php每次都是加载文件进行分析解释执行,这当中浪费了很多资源,于是就有人想到,可不可以在php加载了文件后将分析后的op代码缓冲起来,以此来加快php代码的装载执行速度,这样就有了eaccelerator这样的产品诞生了。
http://www.eaccelerator.net/ 最新版本 0.9.5.3
首先通过
-
wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2
获取最新的 0.9.5.3 源码包
然后对源码包进行编译安装
-
tar -xjvf eaccelerator-0.9.5.3.tar.bz2
-
cd eaccelerator-0.9.5.3/
-
/usr/local/php526/bin/phpize
-
./configure –with-php-config=/usr/local/php526/bin/php-config
-
make
-
make install
-
cd ../
对eaccelerator做配置
编辑 /usr/local/php526/conf/php.ini 添加后面的一些
-
zend_extension="/usr/local/php526/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
-
eaccelerator.shm_size="16"
-
eaccelerator.cache_dir="/var/cache/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.shm_prune_period="0"
-
eaccelerator.shm_only="0"
-
eaccelerator.compress="1"
-
eaccelerator.compress_level="9"
对 extenstion 设置部分部分有如下一些要点:
1.如果使用Zend的线程安全方式则使用: zend_extension_ts
2.如果只是作为普通的php扩展则使用: extension
3.如果和Zend Optimizer一起使用,则必须在Zend Optimizer前加载,在php.ini中配置放在Zend Optimizer前面。
创建临时文件夹
-
mkdir -p /var/cache/eaccelerator
-
chmod 0777 /var/cache/eaccelerator
验证eaccelerator安装
1. 通过 /usr/local/php526/bin/php -v 查看有如下信息
PHP 5.2.6 (cli) (built: Jul 11 2008 00:02:23)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
2. 重新启动 phpfastcgi 进程,在网站下面做一个 php 页面包含
-
<?php
-
echo phpinfo();
-
?>
其中在 php credits 前面可以看到 有 eaccelerator 加载的标志。
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with eAccelerator v0.9.5.3, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
Popularity: 4% [?]