1、下载Windows Service Wrapper

下载地址 http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/

2、将winsw重命名为nginx-service.exe,,并复制到nginx根目录

3、在nginx根目录编辑nginx-service.xml文件

<service>
    <id>Nginx</id>
    <name>Nginx</name>
    <description>本服务用于加载Nginx服务,请确保开机启动。</description>
    <logpath>C:\nginx\logs</logpath>
    <executable>nginx.exe</executable>
    <stopexecutable>nginx.exe</stopexecutable>
    <stopargument>-s</stopargument>
    <stopargument>stop</stopargument>
    <logmode>rotate</logmode>
</service>

4、注册nginx服务为系统服务

win+x+a 打开命令提示符(管理员)

D:\nginx\nginx-service.exe install
D:\nginx\nginx-service.exe uninstall

5、启动关闭nginx服务

net start nginx
net stop nginx

6、windows查看和杀死进程

命令提示符:

tasklist | findstr nginx
tskill PID

7、通过批处理自动注册nginx服务为系统服务(右键-》以管理员身份运行)

%~d0 ::盘符
cd %~dp0 ::定位
dtpweb-service.exe install
net start dtpweb
pause ::显示cmd弹窗
Scroll to Top