官方地址:
选择下载对应您的系统和PHP版本的eAccelerator
eAccelerator 真是一个好东西(它的前身是truck-mmcache)。
本包里有非线程安全与线程安全版本。eAccelerator_ts.dll
是线程安全版本,eAccelerator_nts.dll
是非线程安全版本。该eAccelerator使用最新发布的PHP
5.2.17编译,使用前请确认自己的PHP版本。文件内含Thread
safe(线程安全)和Non Thread
Safe(非线程安全版本),请根据自己使用的PHP版本选择。
使用 eAccelerator加速PHP代码
eAccelerator 真是一个好东西(它的前身是truck-mmcache)。
简单来讲它是一套配合PHP(支持PHP5)运作的缓存系统,通过共享内存或磁盘文件方式交换数据。
它被广为使用的是PHP源码“编码”(不太贴切的称为“加密”)和缓存PHP执行的中间码以加速。关于 eA 的安装使用的文章已经很多而且也很详细了,这次我想推荐的是用它辅助程序设计缓存,它提供了一组API如下:
是一个非常便捷而又稳定的本机缓存实现方式,目前这部分设计似乎只支持于共享内存,所以只能用于 Unix -Like OS 了,windows的就没这个福气了。
1. eaccelerator_put($key, $value, $ttl=0)
将 $value 以 $key 为键名存进缓存(php4下支持对像类型,看源码好像zend2里不支持了),$ttl 是这个缓存的生命周期,单位是秒,省略该参数或指定为 0 表示不限时,直到服务器重启清空为止。
2. eaccelerator_get($key)
根据 $key 从缓存中返回相应的 eaccelerator_put() 存进去的数据,如果这项缓存已经过期或不存在那么返回值是 NULL
3. eaccelerator_rm($key)
根据 $key 移除缓存
4. eaccelerator_gc()
移除清理所有已过期的 key
5. eaccelerator_lock($key)
为 $key 加上锁定操作,以保证多进程多线程操作时数据的同步。需要调用 eaccelerator_unlock($key) 来释放这个锁或等待程序请求结束时自动释放这个锁。
例如:
<?php
eaccelerator_lock(“count”);
eaccelerator_put(“count”,eaccelerator_get(“count”)+1));
?>
6. eaccelerator_unlock($key)
根据 $key 释放锁
7. eaccelerator_cache_output($key, $eval_code, $ttl=0)
将 $eval_code 代码的输出缓存 $ttl 秒,($ttl参数同 eacclerator_put)
For Example:
<?php eaccelerator_cache_output(‘test’, ‘echo time(); phpinfo();’, 30); ?>
8. eaccelerator_cache_result($key, $eval_code, $ttl=0)
将 $eval_code 代码的执行结果缓存 $ttl 秒,($ttl参数同 eacclerator_put),类似 cache_output
For Example:
<?php eaccelerator_cache_result(‘test’, ‘ time() . “Hello”;’, 30); ?>
9. eaccelerator_cache_page($key, $ttl=0)
将当前整页缓存 $ttl 秒。
For Example:
<?php
eaccelerator_cache_page($_SERVER[‘PHP_SELF’].’?GET=’.serialize($_GET),30);
echo time();
phpinfo();
?>
10. eaccelerator_rm_page($key)
删除由 eaccelerator_cache_page() 执行的缓存,参数也是 $key
______________________________________________
(作个简单例子看看它的威力,注意在 cli 模式下可能无效!)
<?php
class test_cache {
var $pro = ‘hello’;
function test_cache() {
echo “Object Created!<br>\n”;
}
function func() {
echo ‘, the world!’;
}
function now($t) {
echo date(‘Y-m-d H:i:s’, $t);
}
}
$tt = eaccelerator_get(“test_tt”);
if (!$tt)
{
$tt = new test_cache;
eaccelerator_put(“test_tt”, $tt);
echo “no cached!<br>\n”;
}
else {
echo “cached<br>\n”;
}
echo $tt->pro;
$tt->func();
$tt->now(time() + 86400);
?>
eaccelerator加速php教程程序
2.将其重命名为 eaccelerator.dll (win版) 然后移至您的 php目录下 的 ext文件夹中
简单来讲它是一套配合PHP(支持PHP5)运作的缓存系统,通过共享内存或磁盘文件方式交换数据。
一、相关下载
以下是网友的评论:
showsa 回复于:2005-12-31 19:51:56win 也支持!
信天翁 回复于:2006-01-04 17:17:37最新版 eAccelerator 0.9.4-rc1 中有个小bug 表现为 /var/log/httpd/error_log 出现大量 [warn] (32)Broken pipe: write pipe_of_death 的错误信息 解决方法 修改 debug.c 文件 ———————————————– /** * Close the debug system. */ void ea_debug_shutdown () { fflush (F_fp); // 源语句, 关闭文件时没有检测文件句柄 //fclose (F_fp); //改为 if (F_fp != stderr) fclose (F_fp); F_fp = NULL; }
soichiro 回复于:2006-01-10 22:01:21eAccelerator/truck-mmcache太恐怖了,我现在有两个负载很高的系统,一个基于Drupal,另一个基于PostNuke,用了eAccelerator后,Drual速度提升100倍,PostNuke提升10倍,PostNuke提升比较少是因为它本身就很快.
wangyih 回复于:2006-04-08 10:48:11和使用squid比怎么样
showsa 回复于:2006-04-08 23:23:44怎么去和 squid去比啊 不一样的东西 squid是缓存页面运行结果 如果不是实时显示,squid肯定强了 但是论坛之类的,squid就不行了,用eaccelerator /memcache 可以很大程度上提升效率
Yarco 回复于:2006-04-09 10:00:43但是据说和encode过的代码有冲突啊… 不知道现在的和zend的兼容性如何?
什么是eaccelerator
3.在c:\php\建立缓存文件夹 temp 修改权限为 user组可读写
它被广为使用的是PHP源码“编码”(不太贴切的称为“加密”)和缓存PHP执行的中间码以加速。关于 eA 的安装使用的文章已经很多而且也很详细了,这次我想推荐的是用它辅助程序设计缓存,它提供了一组API如下:
eAccelerator 0.9.6.1 For PHP5.2.17(DLL)
您可能感兴趣的文章:
- php 提速工具eAccelerator
配置参数详解 - 在Windows下编译适用于PHP
5.2.12及5.2.13的eAccelerator.dll(附下载) - PHP加速
eAccelerator配置和使用指南 - 使用eAccelerator加密PHP程序
- 使用
eAccelerator加速PHP代码的方法 - 实现php加速的eAccelerator
dll支持文件打包下载 - 用windows下编译过的eAccelerator for PHP
5.1.6实现php加速的使用方法 - win2003服务器之用Zend和eAccelerator在IIS6下同时加速
概念:
eaccelerator 是一个免费开源的php加速、优化、编译和动态缓存的项目,它可以
3.根据您系统的情况,一般都是PHP 扩展 ISAPI
打开php.ini文件, 找到extension=php_zip.dll, 在下面添加
是一个非常便捷而又稳定的本机缓存实现方式,目前这部分设计似乎只支持于共享内存,所以只能用于 Unix -Like OS 了,windows的就没这个福气了。
二、安装方法
通过缓存php代码编译后的结果来提高php脚本的性能,使得一向很复杂和离我们很
zend_extension_ts=”C:\php\ext\eaccelerator.dll” //路径根据您系统的情况而定,文件扩展名也是
eaccelerator.shm_size=”64″ //根据你的系统内存来,默认16M,可以改成64M
eaccelerator.cache_dir=”C:\php\temp” //手动创建,例如C:\php\temp,确保他的权限为可读写,并且以后不要动这个目录
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″
1. eaccelerator_put($key, $value, $ttl=0)
将 $value 以 $key 为键名存进缓存(php4下支持对像类型,看源码好像zend2里不支持了),$ttl 是这个缓存的生命周期,单位是秒,省略该参数或指定为 0 表示不限时,直到服务器重启清空为止。
1、选择相应版本
远的php脚本编译问题完全得到解决。通过使用eaccelerator,可以优化你的php代
把修改好的 php.ini 放入你的php配置目录 2003好像是 c:\windows\
2. eaccelerator_get($key)
根据 $key 从缓存中返回相应的 eaccelerator_put() 存进去的数据,如果这项缓存已经过期或不存在那么返回值是 NULL
根据您的PHP线程安全版本,选择相应文件,并复制到php目录下的子目录ext中,同时改名为php_eaccelerator.dll。
码执行速度,降低服务器负载,可以提高php应用执行速度最高达10倍。
┌──────┐
│判断加速启动│
└──────┘
3. eaccelerator_rm($key)
根据 $key 移除缓存
2、设置相应参数
原理:
eaccelerator 通过把经过编译后的php代码缓存到共享内存中,并在用户访问的时
重起iis之前,的php信息 只显示zend……
加载eaccelerator.dll之后 php信息显示 zend…….with eAccelerator 说明加载成功
4. eaccelerator_gc()
移除清理所有已过期的 key
[eaccelerator]
zend_extension_ts=”d:/php5/ext/php_eaccelerator.dll”
eaccelerator.shm_size=”64″
eaccelerator.cache_dir=”d:/php5/tmp”
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″
eaccelerator.keys = “shm”
eaccelerator.sessions = “shm”
eaccelerator.content = “shm”
候直接调用从而起到高效的加速作用。它的效率非常高,从创建共享内存到查找编
您可能感兴趣的文章:
- php 提速工具eAccelerator
配置参数详解 - 在Windows下编译适用于PHP
5.2.12及5.2.13的eAccelerator.dll(附下载) - PHP加速
eAccelerator配置和使用指南 - 使用eAccelerator加密PHP程序
- 使用
eAccelerator加速PHP代码的方法 - 实现php加速的eAccelerator
dll支持文件打包下载 - 使用
eAccelerator加速PHP代码的目的 - win2003服务器之用Zend和eAccelerator在IIS6下同时加速
5. eaccelerator_lock($key)
为 $key 加上锁定操作,以保证多进程多线程操作时数据的同步。需要调用 eaccelerator_unlock($key) 来释放这个锁或等待程序请求结束时自动释放这个锁。
例如:
<?php
eaccelerator_lock(“count”);
eaccelerator_put(“count”,eaccelerator_get(“count”)+1));
?>
请编辑C:windowsphp.ini文件(根据实际情况),复制以上参数到php.ini最底部,并修改以下路径。
译后的代码都在非常短的时间内完成,对于不能缓存到共享内存中的文件和代码,
6. eaccelerator_unlock($key)
根据 $key 释放锁
zend_extension_ts=”d:/php5/ext/php_eaccelerator.dll” #您的PHP路径
eaccelerator.cache_dir=”d:/php5/tmp”
#您的PHP临时文件路径(要有user可读写权限)
eaccelerator还可以把他们缓存到系统磁盘上。
eaccelerator
同样还支持php代码的编译和解释执行,你可以通过encoder.php脚本
7. eaccelerator_cache_output($key, $eval_code, $ttl=0)
将 $eval_code 代码的输出缓存 $ttl 秒,($ttl参数同 eacclerator_put)
For Example:
<?php eaccelerator_cache_output(‘test’, ‘echo time(); phpinfo();’, 30); ?>
来对php代码进行编译达到保护代码的目的,经过编译后的代码必须运行在安装了
8. eaccelerator_cache_result($key, $eval_code, $ttl=0)
将 $eval_code 代码的执行结果缓存 $ttl 秒,($ttl参数同 eacclerator_put),类似 cache_output
For Example:
<?php eaccelerator_cache_result(‘test’, ‘ time() . “Hello”;’, 30); ?>
3、保存,重启IIS
eaccelerator的环境下。eaccelerator编译后的代码不能被反编译,它不象其他一
9. eaccelerator_cache_page($key, $ttl=0)
将当前整页缓存 $ttl 秒。
For Example:
<?php
eaccelerator_cache_page($_SERVER[‘PHP_SELF’].’?GET=’.serialize($_GET),30);
echo time();
phpinfo();
?>
在CMD中执行:IISRESET,重启IIS,并使用phpinfo查看,如果提示如下图,表示安装成功。
些编译工具那样可以进行反编译,这将使得代码更加安全和高效。
注意:在共享内存里面寻找编译好的php程序时,会在很短的时间内产生一些锁定,
10. eaccelerator_rm_page($key)
删除由 eaccelerator_cache_page() 执行的缓存,参数也是 $key
所以一个程序可以被多个进程同时执行。不适合放入共享内存的文件将被缓存到硬
______________________________________________
(作个简单例子看看它的威力,注意在 cli 模式下可能无效!)
盘上
<?phpclass test_cache { var $pro = ‘hello’; function test_cache() { echo “Object Created!<br>/n”; } function func() { echo ‘, the world!’; } function now($t) { echo date(‘Y-m-d H:i:s’, $t); }}$tt = eaccelerator_get(“test_tt”);if (!$tt){ $tt = new test_cache; eaccelerator_put(“test_tt”, $tt); echo “no cached!<br>/n”;}else { echo “cached<br>/n”;}echo $tt->pro; $tt->func();$tt->now(time() + 86400);?>
eaccelerator安装配置
您可能感兴趣的文章:
- php 提速工具eAccelerator
配置参数详解 - 在Windows下编译适用于PHP
5.2.12及5.2.13的eAccelerator.dll(附下载) - PHP加速
eAccelerator配置和使用指南 - 使用eAccelerator加密PHP程序
- 实现php加速的eAccelerator
dll支持文件打包下载 - 用windows下编译过的eAccelerator for PHP
5.1.6实现php加速的使用方法 - 使用
eAccelerator加速PHP代码的目的 - win2003服务器之用Zend和eAccelerator在IIS6下同时加速
1、支持平台
由于aaccelerator提供了大部分基于共享内存的api,所以在*nix的平台上将得到更
好的支持,虽然也发布了基于windows平台的binary版本,但我在这里就只提供基于
*nix平台的配置和说明,目前可以支持的平台包括linux, freebsd, openbsd,
mac
os x, solaris, aix en hp-ux。
2、系统要求
php4 or php5
autoconf
automake
libtool
m4
eaccelerator 只支持使用 mod_php 或者 fastcgi mode 安装的php
3、安装
先去eaccelerator官方下载最新版的源码包:
#tar -zxvf ./eaccelerator-0.9.5-beta2.tar.bz2
#cd eaccelerator-0.9.5-beta2
#export php_prefix=”/usr/local”
(把php安装目录导入到环境变量,freebsd默
认是/usr/local)
#$php_prefix/bin/phpize
#./configure –enable-eaccelerator=shared –with-php-
config=$php_prefix/bin/php-config
#make
#make install
4、ini文件配置
安装完成,下面开始配置php.ini文件,eaccelerator提供了两种配置和调用方式,
分别如下。
安装为 zend extension 模式:
zend_extension=”/usr/local/lib/php/20050922/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.log_file = “/var/log/httpd/eaccelerator_log”
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″
如果你使用了thread safe模式安装的php,你必须使用 “zend_extension_ts”
替
换第一行的 “zend_extension”.
安装为 php extension 模式:(这是大部分采用的方式)
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.log_file = “/var/log/httpd/eaccelerator_log”
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″
有关php.ini文件的详细配置说明,请参照源码目录的readme文档或者访问官方文档
:
完成安装配置后,我们最后要创建缓存目录
#mkdir /tmp/eaccelerator
#chmod 777 /tmp/eaccelerator
测试
php代码中使用eaccelerator加速
下面有一个测试的代码,你可以测试一下eaccelerator强大的威力:(该代码在
cli 模式下可能无效)
<?php
class test_cache {
var $pro = ‘hello’;
function test_cache() {
echo “object created!<br>/n”;
}
function func() {
echo ‘, the world!’;
}
function now($t) {
echo date(‘y-m-d h:i:s’, $t);
}
}
$tt = eaccelerator_get(“test_tt”);
if (!$tt)
{
$tt = new test_cache;
eaccelerator_put(“test_tt”, $tt);
echo “no cached!<br>/n”;
}
else {
echo “cached<br>/n”;
}
echo $tt->pro;
$tt->func();
$tt->now(time() + 86400);
?>