nginx在windows下自启动

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查看服务
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值