Nginx开启访问日志记录
1. vi /etc/nginx/nginx.conf
2.打开 log_format 前的注释
3.Server节点中加入
access_log logs/www_access.log main;
server { listen 80; server_name localhost;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
location / { #root html; #index index.html index.htm; } access_log logs/www_access.log main; }
4.重启Nginx,会报错,是因为没有创建日文件所在目录,建个目录就可以了
mkdir -p /usr/share/nginx/logs/
Enjoy :)...