nginx实现发布静态资源的方法(nginx静态部署html文件)

admin 187 2022-07-20

阿里云服务器优惠多,折扣错,惊喜多,请咨询:www.wqiis.com

步骤

将准备好的静态资源文件放在指定文件夹 更改nginx的配置文件:nginx.conf 启动nginx服务:start nginx (一定要切换到nginx的目录下) 在浏览器中检查是否发布成功

nginx实现发布静态资源的方法(nginx静态部署html文件)

实际操作

把所发布的静态网页放入指定文件夹:

更改nginx的配置文件:

nginx.conf配置内容如下:

#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { gzip on; #静态文件 server { listen 8080; server_name localhost; location / { root D:/resources/statichtmls; } } #html文件 server { listen 8080; server_name 127.0.0.1 localhost; location / { root D:/resources/statichtmls; index index.html index.htm; } } }

启动nginx:

检查是否发布成功

如若未成功,请检查端口号或其他配置,及静态文件是否正确

关闭nginx

测试完毕后,如若不使用,记得关闭nginx

再次进入已经显示进不去了,证明nginx关闭了

上一篇:香港服务器怎么选择?选择香港服务器的技巧(怎么买香港的服务器)
下一篇:企业邮箱用哪个的好?企业邮箱的作用是什么?
相关文章

 发表评论

暂时没有评论,来抢沙发吧~