您好,欢迎访问一九零五行业门户网

PHP加速器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 模式:
#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 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 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选项,可以从日志中看到类似下面的信息
复制代码
eaccelerator_unlock($key) 根据 $key 释放锁
eaccelerator_cache_output($key, $eval_code, $ttl=0) 将 $eval_code 代码的输出缓存 $ttl 秒,($ttl参数同 eacclerator_put) 例如:
复制代码
eaccelerator_cache_result($key, $eval_code, $ttl=0) 将 $eval_code 代码的执行结果缓存 $ttl 秒,($ttl参数同 eacclerator_put),类似 cache_output 例如:
复制代码
eaccelerator_cache_page($key, $ttl=0) 将当前整页缓存 $ttl 秒。 例如:
复制代码
eaccelerator_rm_page($key)删除由 eaccelerator_cache_page() 执行的缓存,参数也是 $key
2、php代码中使用eaccelerator加速测试下eaccelerator强大的威力:(该代码在 cli 模式下可能无效)
pro;
$tt->func();$tt->now(time() + 86400);?>
复制代码
另外,据说在著名的vbulletin 3.60beta版里面已经集成了对eaccelerator的支持。一段来自vbulletin里面的代码
// ##############
// eaccelerator/**
* class for fetching and initializing 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 * * @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); }foreach ($this->defaultitems as $item)
{ $this->do_fetch($item); }if (is_array($itemarray))
{ foreach ($itemarray as $item) { $this->do_fetch($item); } }$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 the 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 = ''; $dataitem = $this->dbobject->query_first( select title, data from . table_prefix . datastore where title = ' . $this->dbobject->escape_string($title) .' ); if (!empty($dataitem['title'])) { $data =& $dataitem['data']; $this->build($dataitem['title'], $dataitem['data']); } } $this->register($title, $data); } /** * updates the appropriate cache file * * @param string title of the datastore item * * @return void */ function build($title, $data) { if (!function_exists('eaccelerator_put')) { trigger_error(eaccelerator not installed, e_user_error); } eaccelerator_lock($title); eaccelerator_put($title, $data); eaccelerator_unlock($title); } }
复制代码
其它类似信息

推荐信息