4/28/2011

加速 PHP網頁執行

eAccelerator是一套不錯開源PHP網頁加速器,基本原理將PHP程式事先編譯過快取起來,且同時將PHP程式進行優化,號稱可以提升~30%(速度是真的提升)。

官方說明

eAccelerator is a free open-source PHP accelerator & optimizer. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.

eAccelerator安裝

  1. 準備package

    sudo apt-get install build-essential php5-dev

  2. download http://eaccelerator.net/

    tar zxf eaccelerator-0.9.6.1.tar.gz

  3. 產生編譯所需的組態設定檔

    sudo phpize; sudo ./configure --enable-eaccelerator=shared;sudo make; sudo make install

  4. 使用的暫存目錄

    sudo mkdir /var/cache/eaccelerator

  5. vim /etc/php5/apache2/php.ini [code lang="conf"] zend_extension="/usr/lib/php5/20090626/eaccelerator.so" #根據需求調整 eaccelerator.shm_size="16" eaccelerator.cache_dir="/var/cache/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" [/code]
  6. 重啟apahce + test.php

尚有其他的PHP加速解決方案APCXcache

可參考下面比較:

  • http://www.ducea.com/2006/10/30/php-accelerators/l
  • http://2bits.com/articles/benchmarking-drupal-with-php-op-code-caches-apc-eaccelerator-and-xcache-compared.htmll
  • http://2bits.com/articles/benchmarking-apc-vs-eaccelerator-using-drupal.html

No comments:

Post a Comment