使用nginx訪問伺服器log日誌
1,修改nginx mime.types,為text/plain 新增log型別檔案
2,修改nginx.conf,新增服務監聽
server {
listen 8888;
server_name localhost;
access_log /home/logs/nginx-log.log main;
location / {
alias /home/logs/; #log日誌存放目錄
autoindex on;
#開啟目錄瀏覽功能
autoindex_exact_size off;
#預設為on,顯示出檔案的確切大小,單位是bytes
#顯示出檔案的大概大小,單位是kB或者MB或者GB
autoindex_localtime on;
#預設為off,顯示的檔案時間為GMT時間。
#改為on後,顯示的檔案時間為檔案的伺服器時間
add_header Cache-Control no-store;
add_header Content-Type "text/plain;charset=utf-8";
#定義文件型別以及編碼格式防止亂碼
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
3,重啟nginx
./nginx -s reload