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