当前位置:首页 > 服务器技术 > nginx

nginx作为静态资源服务器的配置

在http模块添加:

server {
listen 80;
server_name localhost;
location /www/ {
root /data/;
index index.html index.htm;
}
location /image/ {
root /data/;
autoindex on;
}
}

创建目录,拷贝文件
mkdir -p /data/www
 
mkdir /data/image
 
cp yellow.jpg /data/image
 
cp index.html /data/www
 
nginx -s reload
 
浏览器访问:
http://localhost/www/index.html
 
http://localhost/image/yellow.jpg

原文:http://blog.51cto.com/xiaoxiaozhou/2105740


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!