安装eaccelerator缓存加速模块
插件说明:
eAccelerator是一个自由开放源码php加速器,优化和动态内容缓存,提高了php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除。 它还有对脚本起优化作用,以加快其执行效率。使您的PHP程序代码执效率能提高1-10倍。
官网:
http://eaccelerator.net/
相关下载地址:
https://github.com/eaccelerator/eaccelerator/downloads/
实验环境:
[root@teddy ~]# cat /etc/redhat-release CentOS release 6.3 (Final) [root@teddy ~]# uname -r 2.6.32-279.el6.x86_64 [root@teddy ~]# /application/apache/bin/apachectl -v Server version: Apache/2.2.29 (Unix) Server built: Aug 25 2014 11:17:48 [root@teddy ~]# /application/php/bin/php -v PHP 5.3.29 (cli) (built: Sep 10 2014 06:58:52) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies 解决prel编译的问题: [root@teddy lib]# echo 'export LC_ALL=C'>>/etc/profile [root@teddy lib]# source /etc/profile [root@teddy lib]# echo $LC_ALL C
安装: cd /soft wget https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-0.9.6.1.zip unzip eaccelerator-0.9.6.1.zip cd eaccelerator-0.9.6.1 /application/php/bin/phpize ./configure --enable-eaccelerator=shared --with-php-config=/application/php/bin/php-config make make install cd .. 检查安装是否成功 [root@teddy eaccelerator-0.9.6.1]# ls /application/php5.3.29/lib/php/extensions/no-debug-zts-20090626/ eaccelerator.so
配置eAccelerator插件
[root@mysql lib]# mkdir -p /tmp/eaccelerator #这个目录可以用tmpfs存储,或者直接上SSD。 [root@mysql lib]# chown -R apache.apache /tmp/eaccelerator/ [root@mysql lib]# egrep "User|Group" /application/apache/conf/httpd.conf
配置eaccelerator的参数
cat >>/application/php/lib/php.ini<<EOF
[eaccelerator]
extension=”eaccelerator.so”
eaccelerator.shm_size=”32″
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=”3600″
eaccelerator.shm_prune_period=”3600″
eaccelerator.shm_only=”0″
EOF
检查是否配置成功了
[root@mysql lib]# /application/php/bin/php -v
PHP 5.3.29 (cli) (built: Dec 14 2014 07:38:28)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
改配置文件之后,要重启apache,才能生效
查看缓存目录
[root@mysql lib]# ll /tmp/eaccelerator/
total 64
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 0
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 1
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 2
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 3
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 4
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 5
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 6
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 7
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 8
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 9
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 a
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 b
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 c
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 d
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 e
drwxrwxrwx. 18 root root 4096 Dec 15 15:00 f
访问一个php页面,在查看缓存内容
tree /tmp/eaccelerator/
`– eaccelerator-0502.201751