Nginx配置静态文件服务器

nginx安装

参见:http://www.jianshu.com/p/affac5f2d56e

nginx配置静态文件服务器

  • 创建文件夹
# mkdir /data/upload
# chown nginx:nginx /data/upload
  • 配置/etc/nginx/nginx.conf,在http块中添加
http {
......
    include /etc/nginx/conf.d/*.conf;
}
  • 编写/etc/nginx/conf.d/upload.site.com.conf
server {
    client_max_body_size 4G;
    listen 8000;
    server_name upload.site.com;
    root /data/upload;

    location / {
        autoindex on;
        autoindex_exact_size on;
        autoindex_localtime on;
    }

    access_log /var/log/nginx/access_upload.site.com.log main;
}
  • 检测配置并重启nginx
# nginx -t
# /etc/init.d/nginx restart

你可能感兴趣的:(Nginx配置静态文件服务器)