PHP加速器eAccelerator安裝

來源:互聯網
上載者:User

標籤:

程式說明

eAccelerator是一個自由開放源碼php加速器,最佳化和動態內容緩衝,提高了php指令碼的緩衝效能,使得PHP指令碼在編譯的狀態下,對 伺服器的開銷幾乎為零。 它還有對指令碼起最佳化作用,以加快其執行效率。使您的PHP程式碼執效率能提高1-10倍。eAccelerator本身的開銷也是極少的。

1、程式下載

###伺服器上之間下載###

[[email protected]web-yv3 ~]# wget https://github.com/eaccelerator/eaccelerator/tarball/master

[[email protected] ~]# ll

-rw-r--r-- 1 root root 131579 Nov 29 17:34 master        #此檔案就是下載的eAccelerator的安裝包,勿驚勿驚!!

###官網自行下載###

http://eaccelerator.net/

eaccelerator-eaccelerator-42067ac.tar.gz

通過rz上傳或ftp上傳!! 

2、編譯安裝加速器

2.1、解壓程式

[[email protected] ~]#tar xf master                                    #常規方式解壓

[[email protected] ~]# ls

eaccelerator-eaccelerator-42067ac master

[[email protected] ~]# cd eaccelerator-eaccelerator-42067ac            #已經露出了廬山真面目! 

2.2、查看phpize

phpize是用來擴充php擴充模組的,通過phpize可以建立php的外掛模組。

[[email protected] ~]# cd eaccelerator-eaccelerator-42067ac

[[email protected] eaccelerator-eaccelerator-42067ac]#  whereis phpize

phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz

2.3、執行phpize

[[email protected] eaccelerator-eaccelerator-42067ac]# /usr/bin/phpize

Configuring for:

PHP Api Version:        20100412

Zend Module Api No:      20100525

Zend Extension Api No:  220100525

2.4、查看php-config

[[email protected] eaccelerator-eaccelerator-42067ac]#  whereis php-configphp-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz

2.5、編譯安裝

[[email protected] eaccelerator-eaccelerator-42067ac]# ./configure --enable-eaccelerator=shared --with-php-config=/usr/bin/php-config

[[email protected] eaccelerator-eaccelerator-42067ac]# make

[[email protected] eaccelerator-eaccelerator-42067ac]# make install

Installing shared extensions:    /usr/lib64/php/modules/          ##記錄此安裝位置

+-------------------------------------------------------+

|                !!! Attention !!!                    |

|                                                      |

| For disk cache users (using eaccelerator.shm_only=0): |

|                                                      |

| Please remember to empty your eAccelerator disk cache |

| when upgrading, otherwise things will break!          |

+-------------------------------------------------------+

2.6、設定設定檔

[[email protected] eaccelerator-eaccelerator-42067ac]# vi /etc/php.ini

extension="/usr/lib64/php/modules/eaccelerator.so"

eaccelerator.shm_size="64"

eaccelerator.cache_dir="/data/eaccelerator_cache"

eaccelerator.enable="1"

eaccelerator.optimizer="1"

eaccelerator.check_mtime="1"

eaccelerator.debug="0"

eaccelerator.filter=""

eaccelerator.shm_max="0"

eaccelerator.shm_ttl="0"

eaccelerator.shm_only="0"

eaccelerator.compress="1"

eaccelerator.compress_level="9"

2.7、設定檔解析

extension="/usr/lib64/php/modules/eaccelerator.so"        #載入eaccelerator模組

eaccelerator.shm_size="64"                                #用來設定分配給eAccelerator用來緩衝php的最大共用記憶體,單位是mb,如果設定為0,就使用預設大小。

eaccelerator.cache_dir="/data/eaccelerator_cache"      #用來設定硬碟緩衝目錄。eA用來存放先行編譯代碼,session資料,內容和使用者入口。預設值是"/tmp/eaccelerator"。

eaccelerator.enable="1"                                    #用來設定是否啟用或禁用eAccelerator,設定1為啟用,設定0為禁用。

eaccelerator.optimizer="1"                                #開啟或關閉最佳化,使用者加速代碼的執行。1為開啟,0為關閉,最佳化僅僅在指令碼被編譯時間候發生並且是在被緩衝之前。

eaccelerator.check_mtime="1"                              #在每次命中的時候Eaccelerator都會檢查指令碼的修改時間來判斷是不是指令碼發生的變化來決定是否需要重新編譯。在每次命中的時候 Eaccelerator都會檢查指令碼的修改時間來判斷是不是指令碼發生的變化來決定是否需要重新編譯。

eaccelerator.debug="0"                                    #開啟關閉debug日誌。如果設定為1,將列印很多檔案命中的資訊到日誌中。

eaccelerator.filter=""                                    #用來決定哪個php檔案被緩衝。可以通過使用萬用字元(比如"*.php *.phtml")來匹配需要緩衝的php指令碼。如果以"!"開頭,表示不匹配,這個參數預設是空,比如定義了"!/home"的話,那所有/home目 錄的指令碼都不會被緩衝。如果要定義多個匹配,使用空格或者定位字元分開,而不是逗號。

eaccelerator.shm_max="0"                                  #設定記憶體緩衝可以快取檔案的最大值

eaccelerator.shm_ttl="0"                                  #當eAcelerator沒有空餘的共用記憶體的時候,就會把最少shm_ttl設定的秒數沒訪問過的指令碼從緩衝中釋放掉,預設值是0,表示eA不會釋放 任何緩衝。

eaccelerator.shm_prune_period="0"                          #當沒有足夠的記憶體用來緩衝的時候,eA會在上次清除緩衝的時間超過了shm_prune_period設定的秒數時再次嘗試清除到期的指令碼。預設值為 0,eA將不從緩衝中清除到期的指令碼。

eaccelerator.shm_only="0"                                  #啟用或者禁用磁碟緩衝。這個選項對session資料和內容的緩衝沒效果。預設值是0,允許eA使用磁碟和記憶體進行緩衝。

eaccelerator.compress="1"                                  #當使用eaccelerator_content_* 的api時,eA可以在緩衝前對內容進行壓縮。預設值為1表示啟用,禁用為0。

eaccelerator.compress_level="9"                            #內容緩衝的壓縮等級。預設值為9,是最大壓縮層級。

2.8、建立並授權緩衝目錄

[[email protected] eaccelerator-eaccelerator-42067ac]# mkdir /data/eaccelerator_cache[[email protected] eaccelerator-eaccelerator-42067ac]# chown deploy.deploy eaccelerator_cache/ -R

2.9、重啟PHP

[[email protected] ~]# service php-fpm restart

2.10、通過phpinfo查看

[[email protected] html]# vi phpinfo.php

 

echo phpinfo();

?>

3、管理緩衝

3.1、通過伺服器管理cache

[[email protected] eaccelerator_cache]# lldrwx------ 18 deploy deploy 4096 Nov 29 19:41 500

3.2、通過內建頁面管理cache

eAccelerator控制台的地址,安裝包裡有一個control.php檔案,把它複製到網站的任意目錄,可以用它查看和管理,這個必須指定,否則查看緩衝內容的時候會出錯,訪問時候預設的使用者名稱是:admin,密碼:eAccelerator

  • 本文來自:Linux教程網

PHP加速器eAccelerator安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.