Nginx開啓訪問日誌記錄

1. vi /etc/nginx/nginx.confhtml

2.打開 log_format 前的註釋nginx

3.Server節點中加入spa

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"';code


        location / {
            #root   html;
            #index  index.html index.htm;
        }
        access_log  logs/www_access.log  main;
}

4.重啓Nginx,會報錯,是由於沒有建立日文件所在目錄,建個目錄就能夠了orm

mkdir  -p /usr/share/nginx/logs/server

 

Enjoy :)...htm

相關文章
相關標籤/搜索