Windows中将nginx添加到服务
下载安装nginx
http://nginx.org/en/download.html
下载后解压到C盘 C:\nginx-1.14.0
添加服务
需要借助"Windows Service Wrapper"小工具,下载地址: http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/1.18/winsw-1.18-bin.exe
下载后放在nginx目录下,并修改名字为nginx-service.exe
创建配置文件nginx-service.exe.config 和 nginx-service.xml
nginx-service.xml的内容如下:
<service> <id>nginx</id> <name>Nginx Service</name> <description>High Performance Nginx Service</description> <logpath>C:\nginx-1.14.0\logs</logpath> <log mode="roll-by-size"> <sizeThreshold>10240</sizeThreshold> <keepFiles>8</keepFiles> </log> <executable>C:\nginx-1.14.0\nginx.exe</executable> <startarguments>-p C:\nginx-1.14.0</startarguments> <stopexecutable>C:\nginx-1.14.0\nginx.exe</stopexecutable> <stoparguments>-p C:\nginx-1.14.0 -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目录安装服务
最后分享一个删除服务的命令 在cmd命令输入 sc delete 服务名