Nginx配置文件路径:/etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr -
r
e
m
o
t
e
u
s
e
r
[
remote_user [
remoteuser[time_local] “KaTeX parse error: Double superscript at position 34: … '̲status
b
o
d
y
b
y
t
e
s
s
e
n
t
"
body_bytes_sent "
bodybytessent"http_referer” ’
‘“
h
t
t
p
u
s
e
r
a
g
e
n
t
"
"
http_user_agent" "
httpuseragent""http_x_forwarded_for”’;
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
# 配置logrotate
# 创建一个新的logrotate配置文件,例如 /etc/logrotate.d/nginx
# 并添加以下内容:
#关键的logrotate配置位于/etc/logrotate.d/nginx文件中。这个配置指定了每天轮转一次日志文件,保留30天的日志文件,以日期格式命名日志文件,并在轮转后使用kill -USR1命令通知Nginx重新打开日志文件,以便新的日志可以写入。
logrotate /etc/logrotate.d/nginx {
daily
rotate 30
missingok
notifempty
dateext
dateformat -%Y%m%d
create 0640 nginx nginx
sharedscripts
postrotate
[ -f /var/run/nginx.pid ] && kill -USR1 cat /var/run/nginx.pid
endscript
}
}