nginx启动: nginx -c nginx.conf
nginx重启:nginx -s reload
nginx关闭:nginx -s stop
游览器能够自动解析服务端响应的文件,会直接进行显示在页面中,为解决这个问题:
server{
location / {
# 跟路由相应的地址。
root /usr/share/nginx/html;
index index.html index.htm;
}
location /static/ {
# 服务器静态资源的路径
alias /var/qwp/static/;
# 加入下面三个参数,能够直接列出所有的服务器下的静态文件,文件名称,大小,时间
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
# 那些索引能够直接响应后,显示下载的界面。
if ($request_filename ~* ^.*?\(txt|log|pdf|doc|docx|xls|xlsx|ppt|pptx|rar|zip|tar.gz|tar.xz|bz2|iso)$ ) {
add_header Content-Disposition attachment;
}
}
}