PHP加速器eAccelerator

1.介绍

eAccelerator 是一个免费开源的PHP加速、优化、编译和动态缓存的项目,它可以通过缓存PHP代码编译后的结果来提高PHP脚本的性能,使得一向很复杂和离我们很远的PHP脚本编译问题完全得到解决。通过使用eAccelerator,可以优化PHP代码执行速度,降低服务器负载,可以提高PHP应用执行速度最高达10倍。

2.安装

# wget http://sourceforge.net/projects/eaccelerator/files/latest/download/eaccelerator-0.9.6.1.zip
# unzip eaccelerator-0.9.6.1.zip
# cd eaccelerator-0.9.5.6.1
# /usr/local/php/bin/phpize
# ./configure -enable-eaccelerator=shared -with-php-config=/usr/local/php/bin/php-config
# make && make install
# cp /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so /usr/local/php5/lib/php/extensions/

3.配置

1)创建缓存目录

# mkdir /tmp/eaccelerator
# chmod 777 /tmp/eaccelerator
2)在php配置文件php.ini末尾加入:

[eAccelerator]
extension = eaccelerator.so
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)重启apache。

4.验证

创建一个php文件,内容如下:

<?php
  phpinfo();
  ?>

启动PHP并访问该网页,查看其中的Zend Engine部分的信息,如下:

This program makes use of the Zend Scripting Language
 Engine:Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend 
Technologieswith eAccelerator v0.9.6.1, Copyright (c) 
2004-2010 eAccelerator, by eAccelerator

从Engine的信息很明显可以看到已经使用了eAccelerator,如此可验证安装成功。

你可能感兴趣的:(eaccelerator)