PHP加速器eAccelerator安装
程序说明
eAccelerator是一个自由开放源码php加速器,优化和动态内容缓存,提高了php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎为零。 它还有对脚本起优化作用,以加快其执行效率。使您的PHP程序代码执效率能提高1-10倍。eAccelerator本身的开销也是极少的。
1、程序下载###服务器上之间下载###
[root@web-yv3~]#wgethttps://github.com/eaccelerator/eaccelerator/tarball/master
[root@web-yv3~]#ll
-rw-r--r--1rootroot131579Nov2917:34master#此文件就是下载的eAccelerator的安装包,勿惊勿惊!!
###官网自行下载###
http://eaccelerator.net/
eaccelerator-eaccelerator-42067ac.tar.gz
通过rz上传或ftp上传!!
2、编译安装加速器2.1、解压程序[root@web-yv3~]#tarxfmaster#常规方式解压
[root@web-yv3~]#ls
eaccelerator-eaccelerator-42067acmaster
[root@web-yv3~]#cdeaccelerator-eaccelerator-42067ac#已经露出了庐山真面目!
2.2、查看phpizephpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块。
[root@web-yv3~]#cdeaccelerator-eaccelerator-42067ac
[root@web-yv3eaccelerator-eaccelerator-42067ac]#whereisphpize
phpize:/usr/bin/phpize/usr/share/man/man1/phpize.1.gz
2.3、执行phpize[root@web-yv3eaccelerator-eaccelerator-42067ac]#/usr/bin/phpize
Configuringfor:
PHPApiVersion:20100412
ZendModuleApiNo:20100525
ZendExtensionApiNo:220100525
2.4、查看php-config[root@web-yv3eaccelerator-eaccelerator-42067ac]#whereisphp-config
php-config:/usr/bin/php-config/usr/share/man/man1/php-config.1.gz
2.5、编译安装[root@web-yv3eaccelerator-eaccelerator-42067ac]#./configure--enable-eaccelerator=shared--with-php-config=/usr/bin/php-config
[root@web-yv3eaccelerator-eaccelerator-42067ac]#make
[root@web-yv3eaccelerator-eaccelerator-42067ac]#makeinstall
Installingsharedextensions:/usr/lib64/php/modules/##记录此安装位置
+-------------------------------------------------------+
|!!!Attention!!!|
||
|Fordiskcacheusers(usingeaccelerator.shm_only=0):|
||
|PleaseremembertoemptyyoureAcceleratordiskcache|
|whenupgrading,otherwisethingswillbreak!|
+-------------------------------------------------------+
2.6、设置配置文件[root@web-yv3eaccelerator-eaccelerator-42067ac]#vi/etc/php.ini
extension="/usr/lib64/php/modules/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/data/eaccelerator_cache"
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_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
2.7、配置文件解析extension="/usr/lib64/php/modules/eaccelerator.so"#加载eaccelerator模块
eaccelerator.shm_size="64"#用来设置分配给eAccelerator用来缓存php的最大共享内存,单位是mb,如果设置为0,就使用默认大小。
eaccelerator.cache_dir="/data/eaccelerator_cache"#用来设置硬盘缓存目录。eA用来存放预编译代码,session数据,内容和用户入口。默认值是"/tmp/eaccelerator"。
eaccelerator.enable="1"#用来设置是否启用或禁用eAccelerator,设置1为启用,设置0为禁用。
eaccelerator.optimizer="1"#开启或关闭优化,用户加速代码的执行。1为开启,0为关闭,优化仅仅在脚本被编译时候发生并且是在被缓存之前。
eaccelerator.check_mtime="1"#在每次命中的时候Eaccelerator都会检查脚本的修改时间来判断是不是脚本发生的变化来决定是否需要重新编译。在每次命中的时候Eaccelerator都会检查脚本的修改时间来判断是不是脚本发生的变化来决定是否需要重新编译。
eaccelerator.debug="0"#开启关闭debug日志。如果设置为1,将打印很多文件命中的信息到日志中。
eaccelerator.filter=""#用来决定哪个php文件被缓存。可以通过使用通配符(比如"*.php*.phtml")来匹配需要缓存的php脚本。如果以"!"开头,表示不匹配,这个参数默认是空,比如定义了"!/home"的话,那所有/home目录的脚本都不会被缓存。如果要定义多个匹配,使用空格或者制表符分开,而不是逗号。
eaccelerator.shm_max="0"#设置内存缓存可以缓存文件的最大值
eaccelerator.shm_ttl="0"#当eAcelerator没有空余的共享内存的时候,就会把最少shm_ttl设置的秒数没访问过的脚本从缓存中释放掉,默认值是0,表示eA不会释放任何缓存。
eaccelerator.shm_prune_period="0"#当没有足够的内存用来缓存的时候,eA会在上次清除缓存的时间超过了shm_prune_period设定的秒数时再次尝试清除过期的脚本。默认值为0,eA将不从缓存中清除过期的脚本。
eaccelerator.shm_only="0"#启用或者禁用磁盘缓存。这个选项对session数据和内容的缓存没效果。默认值是0,允许eA使用磁盘和内存进行缓存。
eaccelerator.compress="1"#当使用eaccelerator_content_*的api时,eA可以在缓存前对内容进行压缩。默认值为1表示启用,禁用为0。
eaccelerator.compress_level="9"#内容缓存的压缩等级。默认值为9,是最大压缩级别。
2.8、创建并授权缓存目录[root@web-yv3eaccelerator-eaccelerator-42067ac]#mkdir/data/eaccelerator_cache
[root@web-yv3eaccelerator-eaccelerator-42067ac]#chowndeploy.deployeaccelerator_cache/-R
2.9、重启PHP[root@web-yv3~]#servicephp-fpmrestart
2.10、通过phpinfo查看[root@web-yv3html]#viphpinfo.php
<?php
echophpinfo();
?>
[root@web-yv3eaccelerator_cache]#ll
drwx------18deploydeploy4096Nov2919:41500
3.2、通过内置页面管理cacheeAccelerator控制面板的地址,安装包里有一个control.php文件,把它复制到网站的任意目录,可以用它查看和管理,这个必须指定,否则查看缓存内容的时候会出错,访问时候默认的用户名是:admin,密码:eAccelerator
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。