eAccelerator的PHP平台预编译加速。
备忘如下:
获得源代码:
wget http://bart.eaccelerator.net/source/0.9.5.1/eaccelerator-0.9.5.1.tar.bz2
tar jxf eaccelerator-0.9.5.1.tar.bz2
编译:需要有autoconf支持
/usr/local/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/bin/php-config
make
cp /usr/local/src/eaccelerator-0.9.5.1/modules/eaccelerator.so /usr/local/php/ext/
使用tmpfs:
mkdir /dev/shm/eAccelerator_cache
chmod 777 /dev/shm/eAccelerator_cache
把上面两行写到/etc/rc.local里面.
配置增加如下:
vi php.ini
[eaccelerator]
zend_extension="/usr/local/php/ext/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/dev/shm/eAccelerator_cache"
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"
创建专用的缓存目录:
sudo mkdir /tmp/eaccelerator
sudo chmod 0777 /tmp/eaccelerator
重启一下apache或者gninx和php-fpm:
/usr/local/apache2/bin/apachectl restart
通过phpinfo()已经可以看到:eAccelerator启用了
eAccelerator support enabled Version 0.9.5.1 Caching Enabled true Optimizer Enabled true Memory Size 16,777,180 Bytes Memory Available 11,677,492 Bytes Memory Allocated 5,099,688 Bytes Cached Scripts 120 Removed Scripts 0 Cached Keys 0