步骤
实际操作
把所发布的静态网页放入指定文件夹:
更改nginx的配置文件:
nginx.conf配置内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#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关闭了
到此这篇关于nginx实现发布静态资源的方法的文章就介绍到这了,更多相关nginx发布静态资源内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://blog.csdn.net/lolly1023/article/details/112585751