Chinaunix首页 | 论坛 | 博客
  • 博客访问: 214019
  • 博文数量: 73
  • 博客积分: 1879
  • 博客等级: 上尉
  • 技术积分: 920
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-22 15:57
文章分类

全部博文(73)

文章存档

2012年(3)

2011年(15)

2008年(55)

分类: 系统运维

2008-08-29 09:48:57

用php加速器eaccelerator加速php脚本执行速度
eaccelerator是一个开源软件,它能加速,优化,编码与缓存php脚本,通过在php编译时缓存php脚本,能大大提高 php脚本的执行效率,这点针对纯php脚本编写的网站来说,它能明显降低web服务的负载从而使你的网页处理速度能提高1-10倍只针对php脚本的网点,你可能通过ab来测试你的web服务器在装与没装eaccelerator时进行测试。
1。软件下载地址

2。安装
export PHP_PREFIX="/usr"##php安装目录,请根据你的安装环境指定
$PHP_PREFIX/bin/phpize
./configure \
  --enable-eaccelerator=shared \
  --with-php-config=$PHP_PREFIX/bin/php-config

  make
  make install
3。修改php.ini配置文件,将下面内容添加到文件未尾
install as Zend extension:

  zend_extension="/usr/lib/php4/eaccelerator.so"
  eaccelerator.shm_size="16"###注意,这个值不能太多(可以通过更改内核配置文件来达到你要的值,具体是哪个文件我忘了,因为是外网服务器,我也不好调试,如果你知道,请告诉我,默认为16M,如果你想更改,请慢慢调试,如果更改后出现无法启动apache现象,请注意apache的错误日志,按里面的要求做。
  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.shm_prune_period="0"
  eaccelerator.shm_only="0"
  eaccelerator.compress="1"
  eaccelerator.compress_level="9"
4。建立缓存目录
  mkdir /tmp/eaccelerator
  chmod 0777 /tmp/eaccelerator

5。Configuration Options
---------------------

eaccelerator.shm_size
   共享内存大小,设为0为你操作系统默认值

eaccelerator.cache_dir
     eAccelerator存取预编php代码的目录,默认为"/tmp/eaccelerator",注意这个文件的权限

eaccelerator.enable
   是否开启aeccelerator加速引擎

eaccelerator.optimizer
   是否开启eaceelerator优化功能
eaccelerator.debug
    Enables or disables debug logging. Should be "1" for enabling or  "0"  for
    disabling. Default value is "0".

eaccelerator.check_mtime
    Enables or disables PHP file modification checking .  Should  be  "1"  for
    enabling or "0" for disabling. You should set it to "1"  if  you  want  to
    recompile PHP files after modification. Default value is "1".

eaccelerator.filter
    Determine which PHP files must be cached. You may specify  the  number  of
    patterns (for example "*.php *.phtml") which specifies to cache or not  to
    cache. If pattern starts with the character "!", it means to ignore  files
    which are matched by the following pattern. Default value is "" that means
    all PHP scripts will be cached.

eaccelerator.shm_max
    是否限制共享内存最大值,0是不限制

eaccelerator.shm_ttl
    When eaccelerator fails to get shared memory for new script it removes all
    scripts which were not accessed  at  last "shm_ttl"  seconds  from  shared
    memory. Default value is "0" that means -  don't  remove  any  files  from
    shared memory.

eaccelerator.shm_prune_period
    When eaccelerator fails to get shared memory for new script  it  tryes  to
    remove  old  script   if   the   previous   try   was   made   more   then
    "shm_prune_period" seconds ago. Default value is "0" that  means  -  don't
    try to remove any files from shared memory.
                                                           eaccelerator.shm_only
    Enables or disables caching of compiled scripts on disk. It has  no  effect
    on session data and content caching. Default value is "0" that means -  use
    disk and shared memory for caching.

eaccelerator.compress
    Enables or disables cached content compression. Default value is  "1"  that
    means enable compression.

eaccelerator.compress_level
    Compression level used for content caching.  Default value is "9" which  is
    the maximum value

eaccelerator.name_space
    A string that's prepended to all keys. This allows two applications that
    use the same key names to run on the same host by setting this in .htaccess
    or in the main configuration file for the whole webserver.

eaccelerator.keys
eaccelerator.sessions
eaccelerator.content
    Determine where keys, session data and content will be cached. The possible
    values are:
    "shm_and_disk" - cache data in shared memory and on disk (default value)
    "shm"          - cache data in shared memory or on disk if shared memory
                     is full or data size greater then "eaccelerator.shm_max"
    "shm_only"     - cache data in shared memory
    "disk_only"    - cache data on disk
    "none"         - don't cache data

eaccelerator.allowed_admin_path
    The script paths that are allowed to get admin information and do admin
    controls
重启apache马上测试下,是不是快了很多

阅读(1188) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~