- A+
所属分类:linux技术
一、下载nginx
地址:http://nginx.org/en/download.html (稳定版)
解压到相应的磁盘,本文是:E:nginxnginx-1.18.0
二、添加服务
需要借助"Windows Service Wrapper"小工具,下载地址: http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/
本文选择:http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/2.9.0/winsw-2.9.0-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>E:nginxnginx-1.18.0logs</logpath> <log mode="roll-by-size"> <sizeThreshold>10240</sizeThreshold> <keepFiles>8</keepFiles> </log> <executable>E:nginxnginx-1.18.0nginx.exe</executable> <startarguments>-p E:nginxnginx-1.18.0</startarguments> <stopexecutable>E:nginxnginx-1.18.0nginx.exe</stopexecutable> <stoparguments>-p E:nginxnginx-1.18.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目录安装服务
卸载服务命令: sc delete 服务名