1,修改nginx mime.types,为text/plain 添加log类型文件

        image.png


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;
                if (-f $request_filename){
                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