【汇总】php扩展【xhprof,eaccelerator】
环境1.php 5.3.8,使用fastcgi方式安装,安装目录/usr/local/php
2.centos 5.5
?
xhprof生成xhprof.so
#unzip -o xhprof-0.9.2.zip#cd xhprof-0.9.2#cd xhprof-0.9.2/xhprof-0.9.2/extension/#/usr/local/php/bin/phpize#./configure --with-php-config=/usr/local/php/bin/php-config#make#make install
将生成的xhprof.so放入php的extension_dir下,配置php.ini后,重启php
// 放入php的extension_dir目录下...// 配置php.ini#vi /usr/local/php/lib/php.ini---[xhprof]extension=xhprof.so;xhprof.output_dir=/var/cache/xhprof---// 重启php#pkill -o php-fpm#/usr/local/php/sbin/php-fpm// 查看phpinfo,检查xhprof是否安装成功...?
将xhprof_lib,xhprof_html移动到网站目录下
...
写php代码,使用xhprof模块
save_run($xhprof_data, $identifier); echo view xhprof ;}
?eaccelerator生成eaccelerator.so
#tar -zxvf eaccelerator-0.9.6.1.zip#cd eaccelerator-0.9.6.1#/usr/local/php/bin/phpize#./configure --with-php-config=/usr/local/php/bin/php-config#make#make install
?将生成的eaccelerator.so放入php的extension_dir下,配置php.ini后,重启php
// 放入php的extension_dir目录下 ... // 配置php.ini #vi /usr/local/php/lib/php.ini --- [eaccelerator]extension=eaccelerator.soeaccelerator.shm_size=32eaccelerator.cache_dir=/tmpeaccelerator.enable=1eaccelerator.optimizer=1eaccelerator.check_mtime=1eaccelerator.debug=0eaccelerator.filter=eaccelerator.shm_max=0eaccelerator.shm_ttl=3600eaccelerator.shm_prune_period=3600eaccelerator.shm_only=0eaccelerator.compress=1eaccelerator.compress_level=9eaccelerator.keys = disk_onlyeaccelerator.sessions = disk_onlyeaccelerator.content = disk_only--- // 重启php #pkill -o php-fpm#/usr/local/php/sbin/php-fpm // 查看phpinfo,检查eaccelerator是否安装成功...
?
eaccelerator详细配置说明
【此为转载,特此说明,转载地址:http://www.21andy.com/blog/20100207/1646.html】
---
eaccelerator.shm_size=32
eaccelerator 可以使用的共享内存的数量 (以兆为单位) . 0 是指操作系统的默认值. 默认值是 0.可根据服务器的实际情况来调整,16,32,64,128都是可以的。
eaccelerator.cache_dir=/home/php/tmp
这个目录是给磁盘缓存使用. eaccelerator 在这里储存预先编译好的代码, 进程数据, 内容以及用户的自定义内容. 同样的数据也能被储存在共享内存中 (这样可以提高访问速度). 默认的设置是 /tmp/eaccelerator.
eaccelerator.enable=1
开启或关闭 eaccelerator。1 为开启,0 为关闭。默认值为 1。
eaccelerator.optimizer=1
启或关闭内部优化器,可以提升代码执行速度。1 为开启,0 为关闭。默认值为 1。
eaccelerator.check_mtime=1
打开或者关闭 php 的文件修改检查. 1 是指打开, 0 是指关闭. 如果您在修改以后重新编译 php 的文件,那么您应当设置为 1. 默认值是 1.
eaccelerator.debug=0
开启或关闭调试日志记录。1 为开启,0 为关闭。默认值为 0。会将缓存命中得记录写入日志。
eaccelerator.filter=
判断哪些 php 文件必须缓存。您可以指定缓存和不缓存的文件类型(如 *.php *.phtml等)
如果参数以 ! 开头,则匹配这些参数的文件被忽略缓存。默认值为 ,即,所有 php 文件都将被缓存。
eaccelerator.shm_max=0
当使用 eaccelerator_put() 函数时禁止其向共享内存中存储过大的文件。该参数指定允许存储的最大值,单位:字节 (10240, 10k, 1m)。0 为不限制。默认值为 0。
eaccelerator.shm_ttl=0
当 eaccelerator 获取新脚本的共享内存大小失败时,它将从共享内存中删除所有在最后 shm_ttl 秒内没有存取的脚本缓存。默认值为 0,即:不从共享内春中删除任何缓存文件。
eaccelerator.shm_prune_period=0
当 eaccelerator 获取新脚本的共享内存大小失败时,他将试图从共享内存中删除早于shm_prune_period 秒的缓存脚本。默认值为 0,即:不从共享内春中删除任何缓存文件。
eaccelerator.shm_only=0
允许或禁止将已编译脚本缓存在磁盘上。该选项对 session 数据和内容缓存无效。默认值为 0,即:使用磁盘和共享内存进行缓存。
eaccelerator.compress=1
允许或禁止压缩内容缓存。默认值为 1,即:允许压缩。
eaccelerator.compress_level=9
指定内容缓存的压缩等级。默认值为 9,为最高等级。
eaccelerator.keys = disk_only
eaccelerator.session = disk_only
eaccelerator.content = disk_only
设置内容缓存的存放的地方,可以设置为:
shm_and_disk 在共享缓存和硬盘(默认值)
shm 默认存在共享内存,如果共享内存已满或大小超过 eaccelerator.shm_max 的值,就存到硬盘
shm_only 只存放在共享内存
disk_only 只存放在硬盘
none 不缓存数据
eaccelerator.allowed_admin_path = /var/www/html/21andy.com/eaccelerator
这是控制面板的地址
安装包里有个control.php,你把它复制到网站的任意目录,可以用它查看和管理,这个必须指定,否则查看缓存内容的时候会出错
---
?
