为PHP添加xcache缓冲加速模块

http://xcache.lighttpd.net/ 最新稳定版本 Ver 1.2.2

首先通过

  1. wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz

获取最新的稳定版 Ver1.2.2 源码包

然后对源码包进行编译安装

  1. tar -xzvf xcache-1.2.2.tar.gz
  2. cd xcache-1.2.2/
  3. /usr/local/php526/bin/phpize
  4. ./configure –with-php-config=/usr/local/php526/bin/php-config –enable-xcache
  5. make
  6. make install
  7. cd ../

对xcache做配置

  1. cat xcache.ini >> /usr/local/php526/conf/php.ini

或直接编辑 /usr/local/php526/conf/php.ini 添加后面的一些

  1. [xcache-common]
  2. zend_extension="/usr/local/php526/lib/php/extensions/no-debug-non-zts-20060613/xcache.so"
  3.  
  4. [xcache.admin]
  5. xcache.admin.user = "xcache"
  6. ; xcache.admin.pass = md5("password")
  7. xcache.admin.pass = "5f4dcc3b5aa765d61d8327deb882cf99"
  8.  
  9. [xcache]
  10. xcache.cacher = On
  11. xcache.shm_scheme = "mmap"
  12. xcache.size = 32M
  13. ; cpu number (cat /proc/cpuinfo |grep -c processor)
  14. xcache.count = 2
  15. xcache.slots = 8k
  16. xcache.ttl = 0
  17. xcache.gc_interval = 0
  18. xcache.var_size = 2M
  19. ; cpu number (cat /proc/cpuinfo |grep -c processor)
  20. xcache.var_count = 2
  21. xcache.var_slots = 8K
  22. xcache.var_ttl = 0
  23. xcache.var_maxttl = 0
  24. xcache.var_gc_interval = 300
  25. xcache.readonly_protection = Off
  26. 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 页面包含

  1. <?php
  2.    echo phpinfo();
  3. ?>

其中在 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

首先通过

  1. wget http://bart.eaccelerator.net/source/0.9.5.3/eaccelerator-0.9.5.3.tar.bz2

获取最新的 0.9.5.3 源码包

然后对源码包进行编译安装

  1. tar -xjvf eaccelerator-0.9.5.3.tar.bz2
  2. cd eaccelerator-0.9.5.3/
  3. /usr/local/php526/bin/phpize
  4. ./configure –with-php-config=/usr/local/php526/bin/php-config
  5. make
  6. make install
  7. cd ../

对eaccelerator做配置
编辑 /usr/local/php526/conf/php.ini 添加后面的一些

  1. zend_extension="/usr/local/php526/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
  2. eaccelerator.shm_size="16"
  3. eaccelerator.cache_dir="/var/cache/eaccelerator"
  4. eaccelerator.enable="1"
  5. eaccelerator.optimizer="1"
  6. eaccelerator.check_mtime="1"
  7. eaccelerator.debug="0"
  8. eaccelerator.filter=""
  9. eaccelerator.shm_max="0"
  10. eaccelerator.shm_ttl="0"
  11. eaccelerator.shm_prune_period="0"
  12. eaccelerator.shm_only="0"
  13. eaccelerator.compress="1"
  14. eaccelerator.compress_level="9"

对 extenstion 设置部分部分有如下一些要点:
1.如果使用Zend的线程安全方式则使用: zend_extension_ts
2.如果只是作为普通的php扩展则使用: extension
3.如果和Zend Optimizer一起使用,则必须在Zend Optimizer前加载,在php.ini中配置放在Zend Optimizer前面。

创建临时文件夹

  1. mkdir -p /var/cache/eaccelerator
  2. 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 页面包含

  1. <?php
  2.    echo phpinfo();
  3. ?>

其中在 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% [?]

Related