Windows环境
Nginx (engine x)
下载
解压
image.png
运行nginx.exe
image.png
浏览器访问
image.png
nginx.exe无法启动,闪退
netstat -aon|findstr "80" 查看端口信息,并记下对应的pid
打开任务管理器 找到对应的服务
image.png
停止该服务
1.以管理员身份打开cmd
net stop http 命令后 y 同意
相关命令
start nginx.exe 启动服务器
nginx -s reload 重新载入配置文件
nginx -s stop 停止 Nginx
nginx -s reopen 重启 Nginx
配置示例
server {
listen 80;
server_name localhost;
location / { #浏览器访问http://localhost/ 时会访问nginx安装目录/html/index.html
root html;
index index.html index.htm;
}
location /tools/ { #浏览器访问http://localhost/tools/ 时会访问电脑D盘
alias D:/;
allow all;
autoindex on;
}
}
image.png
nginx -s stop 不起作用:
执行命令后,若还是能访问,
1.查看任务管理器,结束进程
2.浏览器缓存问题,刷新
本文详细介绍了在Windows系统中如何下载、解压并运行Nginx,包括如何检查端口占用、停止相关服务以及配置Nginx服务器。通过示例配置文件展示了如何设置服务器以响应不同URL请求,并提供了遇到问题时的解决步骤,如Nginx服务无法启动和端口占用的处理方法。

2760

被折叠的 条评论
为什么被折叠?



