nginx在windows下自启动
1.下载nginx(http://nginx.org/en/download.html)
2.下载winsw(https://repo.jenkins-ci.org/artifactory/releases/com/sun/winsw/winsw/2.1.2/)
3.将winsw-2.1.2-bin.exe复制到nginx目录下(保证nginx的目录不含空格并不为中文),并重命名为nginx-service.exe
4.在nginx目录下新建文件nginx-service.conf
<configuration>
<startup>
<supportedRuntime version="v2.0.50727" />
<supportedRuntime version="v4.0" />
</startup>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>
5.在nginx目录下新建文件nginx-service.xml
<service>
<id>nginx</id>
<name>Nginx Service</name>
<description>High Performance Nginx Service</description>
<logpath>D:\java\nginx\logs</logpath>
<log mode="roll-by-size">
<sizeThreshold>10240</sizeThreshold>
<keepFiles>8</keepFiles>
</log>
<executable>D:\java\nginx\nginx.exe</executable>
<startarguments>-p D:\java\nginx</startarguments>
<stopexecutable>D:\java\nginx\nginx.exe</stopexecutable>
<stoparguments>-p D:\java\nginx -s stop</stoparguments>
</service>
注:将路径改为自己的路径
6.文件结构
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210629174404670.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyOTIzNTM2,size_16,color_FFFFFF,t_70#pic_center)
7.在nginx目录下已管理员身份打开cmd,输入命令:$ nginx-service.exe install
8.WIN+R输入services.msc查看服务