WenRou's Blog
Windows下Nginx以服务的方式运行
2013-9-27 温柔哥

假设nginx安装在c:\nginx\下:


1.下载微软服务注册工具srvany.exe, instsrv.exe

, srvany-instsrv存放到c:\nginx\目录下


2.安装Nginx服务, 将命令行切换到c:\nginx\,执行下列命令


instsrv NGINX c:\nginx\srvany.exe


3.在c:\nginx\下,新建一个nginx.reg文件,输入一下内容:


Windows Registry Editor Version 5.00


[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NGINX\Parameters]
"Application"="C:\\nginx\\nginx.exe"
"AppParameters"=""
"AppDirectory"="C:\\nginx\\"


5.让服务与程序关联起来, 命令行执行


regedit /s nginx.reg


6.编辑启动nginx脚本start-nginx.bat(关闭脚本不用变), 让程序以服务方式运行


@ECHO OFF
net stop nginx
net start nginx
EXIT


完成~


发表评论:
昵称

邮件地址 (选填)

个人主页 (选填)

内容