1,下载nginx,http://nginx.org/en/download.html, 放在c盘 c:/nginx1.10.3
2,下载nssm,https://nssm.cc/,解压后进入相对应的操作系统位数(32位或64位)的文件夹
3,在nssm-2.24/win64路径下运行命令行(若运行nginx,建议先退出)
nssm.exe install nginx
4,在弹出的操作框中操作:
1> Application 标签页的Path输入框输入nginx程序路径,c:/nginx1.10.3/nginx.exe
2> Application 标签页的Startup directory 输入 c:/nginx1.10.3
3> I/O 标签页的 Input(stdin) 输入 start nginx
4> I/O 标签页的 Output(stdout) 输入 c:/nginx1.10.3/logs/service.out.log
5> I/O 标签页的 Error(stderr) 输入 c:/nginx1.10.3/logs/service.err.log
6> 点击Install service
5,打开服务窗口,启动nginx服务
参考链接:
https://stackoverflow.com/questions/40846356/run-nginx-as-windows-service