- 下载Nginx
http://nginx.org/ - 下载winsw-1.18-bin.exe
winsw-1.18-bin.exe 将下载的exe文件放在nginx下 - 创建nginx-service.xml
<service>
<id>nginx-start-balance</id>
<name>NginxService</name>
<description>使用nginx负载均衡</description>
<logpath>E:\Sofware\nginx\nginx-1.20.2\logs</logpath>
<log mode="roll-by-size">
<sizeThreshold>10240</sizeThreshold>
<keepFiles>8</keepFiles>
</log>
<executable>E:\Sofware\nginx\nginx-1.20.2\nginx.exe</executable>
<startarguments>-p E:\Sofware\nginx\nginx-1.20.2</startarguments>
<stopexecutable>E:\Sofware\nginx\nginx-1.20.2\nginx.exe</stopexecutable>
<stoparguments>-p E:\Sofware\nginx\nginx-1.20.2 -s stop</stoparguments>
</service>
- 创建nginx-service.exe.config
<configuration>
<startup>
<supportedRuntime version="v2.0.50727" />
<supportedRuntime version="v4.0" />
</startup>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>
- 最终文件夹中的配置
- cmd当前文件夹下
nginx-service.exe install
- 打开服务启动nginx
- 如果服务 启动失败或者更改id名称等,要删除该服务
打开注册表 win+R 输入 regedit 位置在 :计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nginx-load-balance 最后该方法也可以启动例如jar包等项目喔
|