如何减少Nginx中error.log的大小?

时间:2019-01-13 20:23:28

标签: nginx

我不知道该如何解决...

2019/01/14 05:15:02 [alert] 27307#27307: *9 write() to "/var/log/nginx/access.log" failed (28: No space left on device) while logging request, client: 108.162.226.175, server: titomi.cf, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock", host: "titomi.cf"

2019/01/14 05:15:22 [error] 27307#27307: *11 FastCGI sent in stderr: "PHP message: PHP Warning:  mysqli_connect(): (HY000/2002): No such file or directory in /var/www/test/lib/common.lib.php on line 1443" while reading response header from upstream, client: 162.158.118.78, server: test.titomi.cf, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "test.titomi.cf"

我认为这是access.log错误的大小 如何减小access.log的大小?

1 个答案:

答案 0 :(得分:0)

您可能需要旋转日志来旋转日志。

sudo vim /etc/logrotate.d/nginx

    /var/log/nginx/*.log {
            daily
            missingok
            rotate 14
            compress
            notifempty
            create 0640 www-data adm
 }

每日:每天轮换日志 missingok:如果缺少日志,则不提供输出 轮播14:将保留最近的14个日志 压缩:将压缩日志文件的旧副本。

您可以运行logrotate

logrotate / var / log / nginx /