本章节介绍如何重新打开日志文件,用于日志轮转。
sudo nginx -s reopen
创建 /etc/logrotate.d/nginx:
/var/log/nginx/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 0640 www-data adm
sharedscripts
postrotate
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
endscript
}
| 操作系统 | 日志目录 |
|---|---|
| Linux | /var/log/nginx/ |
| macOS | /usr/local/var/log/nginx/ |
| Windows | logs/ |
access.log - 访问日志error.log - 错误日志