在php5.2.5上安装了eaccelerator-0.9.5.3
CODE: export PHP_PREFIX="/opt/php"
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
make && make install
然后把eaccelerator.so拷贝到/opt/php/lib/php/extensions/目录下
在php.ini里面加上以下参数
CODE: extension_dir = "/opt/php/lib/php/extensions/"
extension="eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="512"
eaccelerator.shm_ttl="1024"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
另外APC-3.0.19的也装了测试,效果和eaccelerator差不多
CODE: export PHP_PREFIX="/opt/php"
$PHP_PREFIX/bin/phpize
./configure --enable-apc --enable-apc-mmap --with-apxs=/opt/apache/bin/apxs --with-php-config=/opt/php/bin/php-config
make && make install
然后把apc.so拷贝到/opt/php/lib/php/extensions/目录下
CODE: extension_dir="/opt/php/lib/php/extensions/"
extension="apc.so"
apc.enabled="1"
apc.shm_size="128"
apc.mmap_file_mask=/tmp/apc.XXXXXX
tmp目录并没有/tmp/apc.的文件,奇怪了
我运行的效果只提升了一点性能,跟网上一些评测说提升3倍以上的性能相差太多了
测试结果(用sar看的)
========================== use eaccelerator ========================
CPU %user %nice %system %iowait %idle
Average: 0 20.76 0.00 4.73 0.04 74.47
============================== use APC =============================
CPU %user %nice %system %iowait %idle
Average: 0 20.46 0.00 5.39 0.03 74.12
============================ no PHP Cache ==========================
CPU %user %nice %system %iowait %idle
Average: 0 27.43 0.00 5.29 0.02 67.27
文章来源于领测软件测试网 https://www.ltesting.net/