php eAccelerator 加速器

Kai 工作 6,664 次浏览 没有评论
PHP 加速器
  • APC (alternative PHP Cache)
  • eAccelerator
  • xCache
综合性能(速度和内存使用率)比较好的是eAccelerator
加速器原理:PHP每次访问都需要编译,所以加速器一次缓存好编译以后的网页,以后访问都不要在编译了.
安装;
# yum groupinstall -y “Development Tools” 安装开发工具一套
php开发相关的软件包 pkgs.org
# yum install -y php-devel 下载php软件包
# wget https://codeload.github.com/eaccelerator/eaccelerator/legacy.zip/master 下载加速器
# mv master master.zip 改名字
# unzip master.zip 解压缩
# cd eaccelerator-eaccelerator-42067ac/ 进入目录
# phpize 在eaccelerator-eaccelerator-42067ac 目录里面运行
# ./configure 安装
# make 编译
# make install
# cd /etc/php.d/ 进入php拓展目录
# vim eaccelerator.ini 新建eaccelerator的配置文件 ,配置文件在eaccelerator官方github上.注意;复制黏贴好检查下配置文件是否复制齐全
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.filter=”” eaccelerator.shm_ttl=”0″ eaccelerator.shm_prune_period=”0″ eaccelerator.shm_only=”0″
# mkdir /tmp/eaccelerator tmp下面新建缓存文件夹
# chmod 0777 /tmp/eaccelerator
# service httpd restart
然后在看看 http://172.16.12.204/phpinfo.php

clipboard
设置成功
测试下
# ab -c 10 -n 1000 http://172.16.12.204/index.php
clipboard2
Requests per second:上次结果是每秒钟8.3次 这次结果是19.04次.
效果非常明显.
优化apache服务器
# cd /etc/httpd/conf
# cat httpd.conf
clipboard3
重点看prefork参数.
# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# ServerLimit: maximum value for MaxClients for the lifetime of the server
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
php配置
上传限制修改
# cd/etc/
# vim/php.ini
pload_max_filesize = 2M
post_max_size = 8M
修改好要重启httpd服务
一个php脚本最多能占用的内存
memory_limit = 128M
# /etc/php.d/eaccelerator.ini
eaccelerator.shm_size=”16″ 编译的缓存大小

发表回复

Go