ImageVerifierCode 换一换
格式:DOC , 页数:17 ,大小:74KB ,
资源ID:4766030      下载积分:5 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/4766030.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(php缓存加速器eAccelerator配置详解.doc)为本站上传会员【二***】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

php缓存加速器eAccelerator配置详解.doc

1、 以下来介绍eAccelerator及eAccelerator详细配置 目录: 一、eAccelerator介绍 1、背景 2、原理 二、安装和配置 1、支持平台 2、系统要求 3、安装 4、php.ini文件配置 5、验证安装 三、使用eAccelerator开发PHP代码 1、API文档和接口说明 2、开发范例 四、附录和参考资料 一、eAccelerator介绍 1、背景 eAccelerator 是一个免费开源的PHP加速、优化、编译和动态缓存的项目,它可以通过缓存PHP代码编译后的结果来提高PHP脚本的性能,使得一向很复杂和离我们很远的

2、PHP脚本编译问题完全得到解决。通过使用eAccelerator,可以优化你的PHP代码执行速度,降低服务器负载,可以提高PHP应用执行速度最高达10倍。 eAccelerator 项目诞生于2004年,当时它是作为 Turck MMCache 项目的一个分支提出并投入开发的。 Turck MMCache 由 Dmitry Stogov 开发,是个非常优秀的PHP内存缓存加速系统,如今仍然有很大部分 eAccelerator 的代码应用到该项目中,目前该项目有很长时间没有更新了,对于最新的PHP5.x的支持还未推出。 2、原理 eAccelerator 通过把经过编译后的PHP

3、代码缓存到共享内存中,并在用户访问的时候直接调用从而起到高效的加速作用。它的效率非常高,从创建共享内存到查找编译后的代码都在非常短的时间内完成,对于不能缓存到共享内存中的文件和代码,eAccelerator还可以把他们缓存到系统磁盘上。 eAccelerator 同样还支持PHP代码的编译和解释执行,你可以通过encoder.php脚本来对php代码进行编译达到保护代码的目的,经过编译后的代码必须运行在安装了eAccelerator的环境下。eAccelerator编译后的代码不能被反编译,它不象其他一些编译工具那样可以进行反编译,这将使得代码更加安全和高效。 二、eAccele

4、rator安装配置 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

5、 3、安装 先去eAccelerator官方下载最新版的源码包:eaccelerator-0.9.5-beta.tar.bz2 #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-con

6、fig=$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.enabl

7、e="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" press="1" pre

8、ss_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" eaccelerat

9、or.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" press="1" press_level="9" 有关php.ini文件的详细配置说明,请参照源码目录的RE

10、ADME文档或者访问官方文档:ini setting 完成安装配置后,我们最后要创建缓存目录 #mkdir /tmp/eaccelerator #chmod 777 /tmp/eaccelerator 5、验证安装结果 通过浏览器访问您的phpinfo()页面或者运行 php -i 得到php配置信息,里面如果看到类似下面的信息就表示安装成功了。 This program makes use of the Zend Scripting Language Engine: Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend

11、 Technologies     with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator 我的机器上同时还安装了Zend Optimizer3.0.1,所以看到的信息如下: This program makes use of the Zend Scripting Language Engine: Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies     with eAccelerator

12、 v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator     with Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by Zend Technologies     with Zend Optimizer v3.0.1, Copyright (c) 1998-2006, by Zend Technologies 如果你打开了eAccelerator的debug选项,可以从日志中看到类似下面的信息 #tail /var/log/ht

13、tpd/eAccelerator_log EACCELERATOR hit: "/var/ EACCELERATOR hit: "/var/ EACCELERATOR hit: "/var/ EACCELERATOR hit: "/var/ EACCELERATOR hit: "/var/ 以上信息表示文件都得到了缓存和命中。 至此,我们就完成了全部的安装和配置,好好享受eAccelerator带给你的惊喜吧,根据Michael的测试,效果的确相当的好。 三、在PHP中可以使用eAccelerator的API开发 1、API和文档说明: eAcceler

14、ator提供了便捷便捷而又稳定的本机缓存实现方式,由于大部分代码实现基于共享内存,所以只能在*nix平台中使用,Windows平台Michael就暂时不知道何时有这方面的支持了。 eAccelerator提供如下的API接口和文件:(下述文件均在源码包的doc/php/目录下) 文件列表: cache.php dasm.php encoder.php info.php loader.php session.php shared_memory.php 接口列表: array eaccelerator_cached_scripts () void eaccel

15、erator_cache_output (string $key, string $eval_code, [int $ttl = 0]) void eaccelerator_cache_page (string $key, [int $ttl = 0]) void eaccelerator_cache_result (string $key, string $code, [int $ttl = 0]) void eaccelerator_caching (boolean $flag) void eaccelerator_clean () void eaccelerator_c

16、lear () array eaccelerator_dasm_file (mixed $filename) mixed eaccelerator_encode (mixed $src, [mixed $prefix = ''], [string $pre_content = ''], [string $post_content = ''])   void eaccelerator_gc () mixed eaccelerator_get (string $key)   array eaccelerator_info () array eaccelerator_list_key

17、s () void eaccelerator_load () boolean eaccelerator_lock (string $key) void eaccelerator_optimizer (boolean $flag)   void eaccelerator_purge () boolean eaccelerator_put (string $key, mixed $value, [int $ttl = 0]) array eaccelerator_removed_scripts () boolean eaccelerator_rm (string $key)

18、 void eaccelerator_rm_page (string $key)   boolean eaccelerator_set_session_handlers () boolean eaccelerator_unlock (string $key) 有关上述文档详细说明请参考官方文档:API Documents 下面有部分网友翻译后的接口说明: eaccelerator_put($key, $value, $ttl=0)   将 $value 以 $key 为键名存进缓存(php4下支持对像类型,看源码好像zend2里不支持了),$ttl 是这个缓存的生命

19、周期,单位是秒,省略该参数或指定为 0 表示不限时,直到服务器重启清空为止。 eaccelerator_get($key)   根据 $key 从缓存中返回相应的 eaccelerator_put() 存进去的数据,如果这项缓存已经过期或不存在那么返回值是 NULL eaccelerator_rm($key)   根据 $key 移除缓存 eaccelerator_gc()   移除清理所有已过期的 key eaccelerator_lock($key)   为 $key 加上锁定操作,以保证多进程多线程操作时数据的同步。需要调用 eaccelerator_u

20、nlock($key) 来释放这个锁或等待程序请求结束时自动释放这个锁。   例如:    eaccelerator_unlock($key)   根据 $key 释放锁 eaccelerator_cache_output($key, $eval_code, $ttl=0)   将 $eval_code 代码的输出缓存 $ttl 秒,($ttl参数同 eacclera

21、tor_put)   例如:    eaccelerator_cache_result($key, $eval_code, $ttl=0)   将 $eval_code 代码的执行结果缓存 $ttl 秒,($ttl参数同 eacclerator_put),类似 cache_output   例如:    eaccelerator_cache_page($key, $ttl=0)   将当前整页缓存 $ttl 秒。   例如:   

22、lize($_GET),30);     echo time();     phpinfo();   ?> eaccelerator_rm_page($key)   删除由  eaccelerator_cache_page() 执行的缓存,参数也是 $key 2、PHP代码中使用eAccelerator加速 下面有一个测试的代码,你可以测试一下eAccelerator强大的威力:(该代码在 cli 模式下可能无效) class test_cache {   var $pro = 'hello';   function test_cache() {   

23、  echo "Object Created! \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! \n"; } else

24、 {   echo "cached \n"; } echo $tt->pro; $tt->func(); $tt->now(time() + 86400); ?> 另外,据说在著名的vBulletin版里面已经集成了对eAccelerator的支持,下面是一段来自vBulletin里面的代码 // ############################################################################# // eAccelerator /** * Class for fetching and initi

25、alizing the vBulletin datastore from eAccelerator * * @package    vBulletin * @version    $Revision: 0.1 $ * @date        $Date: 2005/06/12 13:14:18 $ */ class vB_Datastore_eAccelerator extends vB_Datastore {     /**     * Fetches the contents of the datastore from eAccelerator  

26、   *     * @param    array    Array of items to fetch from the datastore     *     * @return    void     */     function fetch($itemarray)     {         if (!function_exists('eaccelerator_get'))         {             trigger_error("eAccelerator not installed", E_USER_ERROR);     

27、    }         foreach ($this->defaultitems AS $item)         {             $this->do_fetch($item);         }         if (is_array($itemarray))         {             foreach ($itemarray AS $item)             {                 $this->do_fetch($item);             }         }

28、         $this->check_options();         // set the version number variable         $this->registry->versionnumber =& $this->registry->options['templateversion'];     }     /**     * Fetches the data from shared memory and detects errors     *     * @param    string    title of t

29、he datastore item     *     * @return    void     */     function do_fetch($title)     {         $data = eaccelerator_get($title);         if ($data === null)         { // appears its not there, lets grab the data, lock the shared memory and put it in             $data = '';     

30、        $dataitem = $this->dbobject->query_first("                 SELECT title, data FROM " . TABLE_PREFIX . "datastore                 WHERE title = '" . $this->dbobject->escape_string($title) ."'             ");             if (!empty($dataitem['title']))             {                

31、 $data =& $dataitem['data'];                 $this->build($dataitem['title'], $dataitem['data']);             }         }         $this->register($title, $data);     }     /**     * Updates the appropriate cache file     *     * @param    string    title of the datastore it

32、em     *     * @return    void     */     function build($title, $data)     {         if (!function_exists('eaccelerator_put'))         {             trigger_error("eAccelerator not installed", E_USER_ERROR);         }         eaccelerator_lock($title);         eaccelerator_put

33、title, $data);         eaccelerator_unlock($title);     } } 配置说明: eaccelerator.shm_size This setting will allow you to control the amount of shared memory eAccelerator should allocate to cache PHP scripts. The number sets the amount of memory in megabytes. Setting this value to 0 will

34、 use the default size. eaccelerator.shm_size = "0" On Linux the maximum amount of memory a process can allocate is limited by the number set in /proc/sys/kernel/shmmax. Allocating more than this value will result in eAccelerator failing to initialise. The size in this file is given in bytes. You

35、can raise this amount with: echo value > /proc/sys/kernel/shmmax Where value is the size in bytes you want to use. This value is reset to the default value evertime you reboot, but you can raise it permanently by adding the amount you need in /etc/sysctl.conf. This is done by adding: kernel.shm

36、max = value eaccelerator.cache_dir This directory is used for the disk cache. eAccelerator stores precompiled code, session data, content and user entries here. The same data can be stored in shared memory (for quicker access). The default value is "/tmp/eaccelerator". eaccelerator.cache_dir = "

37、/tmp/eaccelerator" This is easy because that directory is easily writable to everyone, and mounted with noexec. However, it isn't the best because on a lot of systems this directory is cleared on reboot. A better place is /var/cache/eaccelerator. Create the directory and make sure it's writable to

38、the process eAccelerator runs under. A safe bet is making it world writeable, a safer and cleaner way is making the user php runs under (most of the time the same user as apache or lighttpd) the owner and set 0644 permissions. The lazy way: mkdir /tmp/eaccelerator chmod 0777 /tmp/eaccelerator

39、 eaccelerator.enable With this setting you can enable or disable eAccelerator. This may seem like a pretty stupid setting, but it can be very useful. For example this setting can also be used in the vhost section of the Apache configuration. It allows you to disable eAccelerator for a certian vhos

40、t by placing php_admin_value eaccelerator.enable 0 in the vhost section. Setting this value to "1" enables eAccelerator, which is also the default value. Setting it to "0" will disable eAccelerator. eaccelerator.enable = "1" eaccelerator.optimizer Enables or disables the optimizer which may sp

41、eed up code execution. Setting it "1" will enable eAccelerator, "0" disables it. By default the optimizer is enabled. The optimizer will only run when the script is compiled before it's cached. eaccelerator.optimizer = "1" eaccelerator.debug Enables or disables debug logging. Setting this to 1 w

42、ill print information to the log file about the cache hits of a file. This is only useful when debugging eAccelerator for bug reports. eaccelerator.debug = 0 eaccelerator.log_file Set the log file for eaccelerator. When this option isn't set then the data will be logged to stderr, when using PHP

43、 with Apache these lines will be added to the Apache error log. eaccelerator.log_file = "/var/log/httpd/eaccelerator_log" eaccelerator.name_space When using the user cache api for storing data in shared memory, all keys are prepended by the hostname used for the current request. This hostname eq

44、uals the ServerName? set in the vhost section of apache. This is done to avoid duplicate keys between vhosts. Sometimes this behaviour is desired to share data between vhosts. When setting this option this namespace is used to prepend to each key. By default this is set to "" which instructs eAccele

45、rator to use the hostname as namespace. When setting this in the main PHP configuration file this namespace will be used by all vhosts. This value can also be set in the vhost section or even in a .htaccess file to allow sharing of data between only two vhosts. eaccelerator.name_space = "" eacc

46、elerator.check_mtime On every hit eAccelerator will check the modification time of a script to see if it changed and needs to be recompiled. Although this is a lot faster then opening the file and compiling it, this still adds some overhead because a stat call needs to be done every time. This sett

47、ing allows you to disable this check. The downside of disabling this check is that you need to manually clean the eAccelerator cache when you update a file. By default this check is enabled. eaccelerator.check_mtime = "1" eaccelerator.filter Determine which PHP files can be cached. You can spe

48、cify the pattern (for example "*.php *.phtml") the PHP script filename needs to match. If a pattern starts with "!", the files that match that pattern are excluded from the cache. Default value is "" which will cache all scripts PHP compiles. Please note that eaccelerator.filter doesn't work on a

49、URL basis but rather on the absolute filesystem path, so a filter of !/home* would exclude all scripts in /home from being cached. Multiple patterns need to be seperated by spaces or tabs, but not commas. eaccelerator.filter = "" eaccelerator.shm_max By default there is no limit on the maximum size a user can put in shared memory w

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服