天天看點

linux下安裝eaccelerator加速php執行效率

linux下安裝eaccelerator加速php執行效率

說明:

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

繼續閱讀