前面已经去优化了部分内容了:
【已解决】给Linode中的LNMP的crifan.com优化内存占用
其他方面的内容,有些也有待优化。
比如之前遇到的:
【已解决】wordpress插件Evernote Sync不工作了:502 Bad Gateway – 在路上
即fzhost中的配置是:
[global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice [www] listen = /tmp/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www pm = dynamic pm.max_children = 20 pm.start_servers = 10 pm.min_spare_servers = 10 pm.max_spare_servers = 20 request_terminate_timeout = 300 request_slowlog_timeout = 3 slowlog = var/log/slow.log |
现在也需要去改为相同的配置。
但是需要先知道,上述的配置是哪个文件。
搜:
pid = /usr/local/php/var/run/php-fpm.pid
php-fpm的安装和启动 – 作业部落 Cmd Markdown 编辑阅读器
php-fpm的配置和优化 – 作业部落 Cmd Markdown 编辑阅读器
知道了是:php-fpm.conf
搜:
lnmp php-fpm.conf
LNMP安装了哪些软件?安装目录在哪? – LNMP一键安装包
知道了lnmp中的php-fpm.conf是放在:
php-fpm配置文件:/usr/local/php/etc/php-fpm.conf
所以去看看:
[root@crifan ~]# cat /usr/local/php/etc/php-fpm.conf [global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice [www] listen = /tmp/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www pm = dynamic pm.max_children = 40 pm.start_servers = 20 pm.min_spare_servers = 20 pm.max_spare_servers = 40 request_terminate_timeout = 100 request_slowlog_timeout = 0 slowlog = var/log/slow.log [root@crifan ~]# |
所以去修改为同样的配置
不过只打算改其中两个参数:
request_terminate_timeout
和
request_slowlog_timeout
其他参数的含义,可以参考前面的帖子中的:
[root@crifan ~]# cat /usr/local/php/etc/php-fpm.conf [global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice [www] listen = /tmp/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www pm = dynamic pm.max_children = 40 pm.start_servers = 20 pm.min_spare_servers = 20 pm.max_spare_servers = 40 #request_terminate_timeout = 100 request_terminate_timeout = 300 #request_slowlog_timeout = 0 request_slowlog_timeout = 10s slowlog = var/log/slow.log |
其中:
request_slowlog_timeout = 10s
超过10秒就算是slow慢的请求-》“就会将对应的PHP调用堆栈信息完整写入到慢日志中”
request_terminate_timeout = 300
“设置单个请求的超时中止时间. 该选项可能会对php.ini设置中的’max_execution_time’因为某些特殊原因没有中止运行的脚本有用. 设置为 ‘0’ 表示 ‘Off’.当经常出现502错误时可以尝试更改此选项。”
然后去重启php-fpm
[root@crifan ~]# lnmp help +——————————————-+ | Manager for LNMP, Written by Licess | +——————————————-+ | https://lnmp.org | +——————————————-+ Usage: lnmp {start|stop|reload|restart|kill|status} Usage: lnmp {nginx|mysql|mariadb|php-fpm|pureftpd} {start|stop|reload|restart|kill|status} Usage: lnmp vhost {add|list|del} Usage: lnmp database {add|list|edit|del} Usage: lnmp ftp {add|list|edit|del|show} Usage: lnmp ssl add [root@crifan ~]# lnmp php-fpm restart +——————————————-+ | Manager for LNMP, Written by Licess | +——————————————-+ | https://lnmp.org | +——————————————-+ Gracefully shutting down php-fpm . done Starting php-fpm done |
其他方面的优化,抽空再去设置。
折腾了:
【记录】尝试Linode中的crifan.com的LNMP中去优化MySQL去优化内存占用
后,感觉:
pm.max_children等参数,最好也是保持和fzhost中的一致会比较好。
去改的和fzhost一样:
[root@crifan ~]# cat /usr/local/php/etc/php-fpm.conf [global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice [www] listen = /tmp/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www pm = dynamic pm.max_children = 20 pm.start_servers = 10 pm.min_spare_servers = 10 pm.max_spare_servers = 20 #request_terminate_timeout = 100 request_terminate_timeout = 300 #request_slowlog_timeout = 0 request_slowlog_timeout = 3 slowlog = var/log/slow.log |
重启php-fpm:
[root@crifan ~]# lnmp php-fpm restart +——————————————-+ | Manager for LNMP, Written by Licess | +——————————————-+ | https://lnmp.org | +——————————————-+ Gracefully shutting down php-fpm . done Starting php-fpm done [root@crifan ~]# |
看看效果
结果页面加载还是占用30M内存,还是没有降低。。。
暂时不去深究和继续优化了。
【后记】
后来通过:
【已解决】给Linode中的LNMP的crifan.com优化内存占用
去开启opcache后,而解决了问题。
转载请注明:在路上 » 【记录】尝试通过php-fpm去优化Linode中LNMP的wordpress网站crifan.com页面加载的内存占用