wget http://internap.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.4.tar.bz2
tar jxf eaccelerator-0.9.4.tar.bz2
编译:需要有autoconf支持
引用:/usr/local/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/bin/php-config
make
sudo make install
配置增加如下:sudo vi php.ini
引用:extension="/PATH/TO/eaccelerator.so"
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"
2006-06-03更新
在apache 2.2的升级过程中:发现php的相关模块都需要重新编译 需要注意包含哪个目录下的 eaccelerator.so 文件
引用:/usr/local/lib/php/extensions$ ls -1
no-debug-non-zts-20020429
no-debug-zts-20020429
否则eAccelerator会无法生效, 我测试的结果在apache 2.2下eAccelerator的效果比apache 1.3下还差一些;
创建专用的缓存目录:
引用:sudo mkdir /tmp/eaccelerator
sudo chmod 0777 /tmp/eaccelerator
重启一下apache:
引用:sudo /home/apache/bin/apachectl restart
通过phpinfo()已经可以看到:eAccelerator启用了
引用:This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
with eAccelerator v0.9.4, Copyright (c) 2004-2004 eAccelerator, by eAccelerator
用phpinfo这个脚本本身还做了一下性能对比测试:对于纯php代码(不考虑数据库瓶颈/文件IO等操作)的运行效率的确有3-5倍的效率提升;
测试:
引用:eAccelerator 启用 |eAccelerator 关闭
Document Length: 32006 bytes |Document Length: 29136 bytes
Concurrency Level: 20 |Concurrency Level: 20
Time taken for tests: 5.813 seconds |Time taken for tests: 23.896 seconds
Complete requests: 1000 |Complete requests: 1000
Failed requests: 89 |Failed requests: 109
(Connect: 0, Length: 89, Exceptions: 0) | (Connect: 0, Length: 109, Exceptions: 0)
Broken pipe errors: 0 |Broken pipe errors: 0
Total transferred: 32534962 bytes |Total transferred: 29578714 bytes
HTML transferred: 32263316 bytes |HTML transferred: 29308693 bytes
Requests per second: 172.03 [#/sec] (mean) |Requests per second: 41.85 [#/sec] (mean)
Time per request: 116.26 [ms] (mean) |Time per request: 477.92 [ms] (mean)
Time per request: 5.81 [ms] |Time per request: 23.90 [ms]
Transfer rate: 5596.93 [Kbytes/sec] received |Transfer rate: 1237.81 [Kbytes/sec] received
|
Connnection Times (ms) |Connnection Times (ms)
min mean[+/-sd] median max | min mean[+/-sd] median max
Connect: 0 19 12.1 17 72 |Connect: 0 91 58.9 89 424
Processing: 53 92 22.0 90 219 |Processing: 140 379 209.6 366 4078
Waiting: 39 89 21.9 88 218 |Waiting: 113 359 210.6 349 4076
Total: 53 111 16.4 109 251 |Total: 140 470 203.7 450 4321
|
Percentage of the requests served within a certain time (ms) |Percentage of the requests served within a certain time (ms)
50% 109 | 50% 450
66% 110 | 66% 453
75% 111 | 75% 456
80% 116 | 80% 460
90% 130 | 90% 490
95% 145 | 95% 626
98% 158 | 98% 830
99% 167 | 99% 831
100% 251 (last request) | 100% 4321 (last request)