1.下载nginx
在 nginx.org/en/download… 官网下载 nginx
2. 解压打开nginx
打开nginx可能出现的问题:打开nginx出现闪退
- 出现的原因
- 80端口被占用
- nginx 放在含有中文的路径下
- 端口被占用解决方法
- blog.csdn.net/ytm15732625… 修改完记得重启就可以了
3. 搭建静态资源服务器
打开config 文件夹下的 nginx.conf 加入下面的代码
server {
listen 9091;
server_name resouce;
root D:/nginx/resource;
autoindex on;
location / {
add_header Access-Control-Allow-Origin *;
}
add_header Cache-Control "no-cache, must-revalidate";
}
重启nginx 打开浏览器输入 http://localhost:9091/ 就可以看到
说明静态资源服务器搭建成功