首 页   · 站长博客 · 用户注册 · 会员登陆  · 会员排行  ·最新主题  ·最近回复  精华区  版权声明  ·论坛管理
  当前登录身份:游客,请先登录。  笔名: 口令: 验证码:   
楼 主  index »  PHP相关资源下载区 » [原创]PHP 缓冲的免费实现方法  


  作者:lather
  注册时间:2005-04-21
  主题/回复:37/63
  积分:1079
  等级:★★★☆(七级)
  称号:论坛贤士

  lather@lather.co..
  66584152
  www.ent.bj.cn/

 

 发表:2005-04-26 08:42:53 阅读 2024 次 回复 0 次 得分0  |   字号 字色
[原创]PHP 缓冲的免费实现方法
我们知道 Zend 有免费的优化引擎针对 PHP 而作,但是 FreeLAMP 这次采用的是一个叫做 PHP Accelerator 的缓冲产品。 

我们在 “LAMP 加速” 这篇文章中阐述过加速的几种办法,其中提到了 PHP Accelerator,它的安装方法十分简单,但是需要去他的网站获取一个激活键。 

一、下载: 

http://www.php-accelerator.co.uk/download.php 

二、获取激活键并安装: 

http://www.php-accelerator.co.uk/activate.php 

注册自己的 SERVER_NAME 后,你会得到下面的提示: 

Your key for www.freelamp.com is 8edfd13946c96309244fcca309415902 

Now you must set the key for www.freelamp.com in your site configuration. 

For single domains not using virtual hosts 

The key can be set in the php.ini file as follows: 

# PHPA key for www.freelamp.com 



phpa.registration_key = 8edfd13946c96309244fcca309415902 

For domains setup as a virtual host 

Add the key to the domain specific section for your web server. 

# www.freelamp.com VHost entry 



<VirtualHost 10.20.30.40> 

ServerName www.freelamp.com 

# ... (other vhost specific config) 

# php settings 

php_value phpa.registration_key 8edfd13946c96309244fcca309415902 

# also enable phpa if set to off in the php.ini (the default is on) 

php_value phpa 1 

</VirtualHost> 

</code> 

具体的 phpa 值的设置,可以参考软件随带的 CONFIGURATION 文件的配置。 

由于大多数网站是虚拟主机配置,所以,建议采用 php_value phpa. 的方式设置。 

例如: 

php_value phpa.tweaks off 

php_value phpa.cache_dir /tmp 

php_value phpa.file_perms 400 

php_value phpa.ignore_files "/index.php, /a/test.php" 

# php_value phpa.ignore_dirs "/data/WWW/site1/,/cache/" 

php_value phpa.shm_size 8 

php_value phpa.shm_key 0xc0deb00 

php_value phpa.shm_perms 664 

三、设置 php.ini 

假设我们把下载后的文件解开到 /usr/local/php ,那么在 php.ini 中加入: 

zend_extension=/usr/local/php/php_accelerator_1.2p2.so 

并注释掉原来的 Zend 优化引擎: 

# zend_extension=/usr/local/Zend/lib/ZendOptimizer.so 

重新启动 Apache ,用浏览器浏览一个任意 PHP 页面可以看到 /tmp 下面生成了一些 phpa 开头的文件。另外一个检查缓冲是否起作用的办法是看 phpinfo() 的输出,原来的 Zend 优化引擎的说明部分,已经被显示成: 

This program makes use of the Zend Scripting Language Engine: 

Zend Engine v1.1.1, Copyright (c) 1998-2001 Zend Technologies 

with the PHP Accelerator v1.2p2, Copyright (c) 2001-2002, by Nick Lindridge 

需要说明的是,安装 INSTALL 安装说明上的办法,其中的 .so 文件和真实的 .so 文件有差异,所以,你在安装的时候需要注意到这个区别。 

四、调整缓冲大小 

PHP Accelerator 提供了缓冲管理命令: 

phpa_cache_admin -mv 观察内存的缓冲情况 

phpa_cache_admin -fv 观察文件的缓冲情况 

phpa_cache_admin -k 设置缓冲大小 

五、总结 

该软件提供的 INSTALL 文件阐述了关于性能上的一些说法,笔者不在这里赘述。 

需要说明的是,FreeLAMP.com 的文章目前不是 PHP 架构的,但是论坛系统是 PHP 架构的,所以性能上的提升只会是论坛系统的提升。
 
  页数1/1首页 « 1 » 末页
  发表回复:您还没有登陆,无法发表回复。请先[登陆]

一起PHP技术联盟 主办:一起PHP 联系方式:站长QQ:4304410 QQ群:8423742 20159565 站长博客 E-mail: nqp@nqp.me 执行时间:0.003sec
SimsmaBBS 2008 (v6.0) Developed by 17php.com,Copyright(C)2003-2010 All rights reserved. 副本授权:一起PHP官方专用版