![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLicGcq5CcoB3LcBTMvwVMxAjMvw1ckF2bsBXdvwFduVGdu92YtA3dvwVbvNmLpV2duVXez9mL3d3dvw1LcpDc0RHaiojIsJye.jpg)
说明:
php安装目录:/usr/local/php5
php.ini配置文件路径:/usr/local/php5/etc/php.ini
Nginx安装目录:/usr/local/nginx
Nginx网站根目录:/usr/local/nginx/html
安装篇
1、安装编译工具
yum -y install php-devel autoconf automake m4 libtool
2、安装eaccelerator
cd /usr/local/src #进入软件包存放目录
wget http://acelnmp.googlecode.com/files/eaccelerator-0.9.6.1.tar.bz2 #下载
tar xjf eaccelerator-0.9.6.1.tar.bz2 #解压
cd eaccelerator-0.9.6.1 #进入安装目录
phpize #用phpize生成configure配置文件
./configure -enable-eaccelerator=shared --with-php-config=/usr/bin/php-config #配置
make #编译
make install #安装
安装完成之后,出现下面的界面,记住以下路径,后面会用到
file:///C:/Users/TJ/Desktop/QQ截图20150824140751.png
echo "/usr/lib64/php/modules/" >> /etc/ld.so.conf.d/php.conf
ldconfig
mkdir /tmp/eaccelerator #创建目录
chmod 777 /tmp/eaccelerator #设置目录权限为完全控制
3、配置php支持eaccelerator
vi /etc/php.ini #编辑配置文件,在最后一行添加以下内容
[eaccelerator]
zend_extension="eaccelerator.so"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.shm_size="8"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
eaccelerator.keys ="disk_only"
eaccelerator.sessions ="disk_only"
eaccelerator.content ="disk_only"
测试篇
1、/var/www/html/phpinfo.php #编辑
<?php
phpinfo();
?>
:wq! #保存退出
2、cp /usr/local/src/eaccelerator-0.9.6.1/control.php /var/www/html/ #拷贝eaccelerator配置管理文件到网站根目录
vi //etc/php.ini #编辑配置文件,在[eaccelerator]配置部分的最后一行添加以下内容
eaccelerator.allowed_admin_path = "/usr/local/nginx/html/"
:wq! #保存退出
/etc/init.d/httpd restart
3、浏览器打开phpinfo.php 如下图所示,可以看到eaccelerator相关信息
ab -dSk -c100 1n100 httpd://localhost/phpinfo.php