Nginx---Nginx配置静态资源

在182.61.40.184服务器根目录下创建文件夹static,里面创建html文件夹和images文件夹。存放静态资源。(文件夹名字自定义)

Nginx配置:

      nginx.conf的http块中添加server块,监听80端口。若访问路径中含有/html/,就到服务器的/static/html/下,含有/images/,就到/static/images/下。

server {
   listen       80;
   server_name  localhost;

   location /html/ {
	    root /static/;
    }

	location /images/ {
		root /static/;
	}
}

测试:

      http://182.61.40.184:80/html/xxx      http://182.61.40.184:80/images/xxx      

发布了62 篇原创文章 · 获赞 25 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_39115469/article/details/104497692