用eAccelerator(前身Truck MMCache)加速PHP

來源:互聯網
上載者:User
What is eAccelerator?
----------------------
eAccelerator is a free open source PHP accelerator, optimizer, encoder and
dynamic content cache for PHP. It increases performance of PHP scripts by
caching them in compiled state, so that the overhead of compiling is almost
completely eliminated. Also it uses some optimizations to speed up execution
of PHP scripts. eAccelerator typically reduces server load and increases the
speed of your PHP code by 1-10 times.

eAccelerator is a fork of TurckMMCache

相信很多朋友都知道MMCache,不過很久前開發人員就被Zend招安了,因此MMCache一直沒有官方的新版本...要支援最新的PHP4.3.10或者PHP5.03都需要自己編譯源碼,對於普通使用者來說無異於天方夜譚...別灰心,我們還有eAccelerator!

1.首先,我們下載編譯好了的Module

http://www.arnot.info/eaccelerator/

選擇下載對應您的系統和PHP版本的eAccelerator

2.將其重新命名為 eaccelerator.dll (win版) 或者 eaccelerator.so (linux版) 然後移至您的 php 的 extention檔案夾,其路徑定義在您系統所用的的 php.ini 中

3.根據您系統的情況,一般有兩種安裝方式,一種按照Zend的擴充,一種是PHP擴充

如果是前者,請在您的 php.ini 中加入

zend_extension="/usr/lib/php4/eaccelerator.so" //路徑根據您系統的情況而定,副檔名也是,Win系統下是dll
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_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

如果開啟了安全模式,必須使用, "zend_extension_ts" i取代 "zend_extension".

PHP擴充安裝模式,請在您的 php.ini 中加入

extension="eaccelerator.so" //路徑根據您系統的情況而定,副檔名也是,Win系統下是dll
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_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

eAccelerator可以和Zend相容,但是上面的代碼在 php.ini 必須定義與 Zend 的相關代碼之前,並且官方強烈建議,除非您必須使用Zend過的代碼,否則最好不同時使用Zend和eAccelerator

完成上面的工作以後儲存 php.ini , 然後重新啟動 apache, 看看 phpinfo 是不是不一樣了?然後看看 PHP 的執行時間是不是快了許多?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.