Linux系统环境
[root@lnmp ~]#cat /etc/redhat-release #==》系统版本
CentOS release 6.7 (Final)
[root@lnmp ~]#uname –r #==》内核版本
2.6.32-573.el6.x86_64
[root@lnmp ~]#uname -m #==》系统架构
x86_64
[root@lnmp ~]#echo $LANG #==》系统字符集
en_US.UTF-8
[root@lnmp ~]# mysql -uroot -p123456 #==》mysql版本
Server version: 5.5.32 MySQL Community Server (GPL)
[root@lnmp ~]# /application/nginx/sbin/nginx -v #==》nginx版本
nginx version: nginx/1.16.0
[root@lnmp ~]# /application/php/bin/php –v #==》PHP版本
PHP 5.3.27 (cli) (built: Jul 9 2019 14:54:53)
[root@lnmp ~]# ip a | awk -F "[ /]+" 'NR==8{print $3}' #==》IP地址
10.0.0.8
一、配置eaccelerator扩展模块生效
注意事项:如果使用Zend扩展缓存模块,[eaccelerator]段配置要放在Zend的 内容配置前,否则会报错
#==》创建eaccelerator缓存目录,此目录可以用tmpfs内存文件系统存储或SSD固态硬盘
[root@lnmp ~]# mkdir -p /tmp/eaccelerator
[root@lnmp ~]# ls -ld /tmp/eaccelerator/
drwxr-xr-x 2 nginx nginx 4096 Jul 10 17:02 /tmp/eaccelerator/
[root@lnmp ~]# grep "nginx" /application/nginx/conf/nginx.conf
user nginx;
[root@lnmp ~]# chown -R nginx.nginx /tmp/eaccelerator/ #==》必须赋予nginx虚拟用户权限,否则会出现权限问题
[root@lnmp ~]# ls -ld /tmp/eaccelerator/
drwxr-xr-x 2 nginx nginx 4096 Jul 10 17:02 /tmp/eaccelerator/
[root@lnmp ~]#cat >> /application/php/lib/php.ini << EOF
[eaccelerator]
extension=eaccelerator.so
eaccelerator.shm_size="64"
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"
eaccelerator.compress="1"
eaccelerator.compress_level="1"
EOF
[root@lnmp ~]# tail -15 /application/php/lib/php.ini
[eaccelerator]
extension=eaccelerator.so
eaccelerator.shm_size="64"
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"
eaccelerator.compress="1"
eaccelerator.compress_level="1"
#==》仅检查eaccelerator插件情况配置,可以不重启PHP服务,但如果使其生效,还需重启PHP服务
[root@lnmp ~]# /application/php/bin/php –v
PHP 5.3.27 (cli) (built: Jul 9 2019 14:54:53)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
with eAccelerator v0.9.6, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
[root@lnmp ~]# find /tmp/eaccelerator/ -type f #==》没重启PHP服务,eaccelerator插件没生效
[root@lnmp ~]# ps -ef | grep php-fpm | grep -v grep | awk '{print "kill",$2}'|bash
[root@lnmp ~]# ps -ef | grep php-fpm | grep -v grep
[root@lnmp ~]# /application/php/sbin/php-fpm #==》启动PHP服务
[root@lnmp ~]# curl 10.0.0.8/index.php #==》访问动态网页才会生成缓存文件
[root@lnmp ~]# find /tmp/eaccelerator/ -type f #==》查检
/tmp/eaccelerator/4/d/eaccelerator-1502.659451
网友评论