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 :)...