服务器 发布日期:2025/10/26 浏览次数:1
把所发布的静态网页放入指定文件夹:
更改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关闭了