学习日志运维01window服务器上nginx开机自启

4次阅读

共计 920 个字符,预计需要花费 3 分钟才能阅读完成。

1. 下载 winsw 工具

首先下载 winsw 工具 http://repo.jenkins-ci.org/re…
将 winsw 工具移动到 nginx 的安装目录, 并将 winsw 工具改名为nginx-service.exe


2. 添加配置文件

然后在安装目录下新建文件 nginx-service.exenginx-service.exe.config
我的 nginx 的安装目录为C:\develop\nginx-1.12.2

此时的目录结构如图所示

nginx-service.exe 文件内容

<service>
  <id>nginx</id>
  <name>nginx</name>
  <description>nginx</description>
  <env name="path" value="D:\nginx-1.15.9\nginx-1.15.9"/>
  <executable>C:/develop/nginx-1.12.2/nginx.exe</executable>
  <arguments>-p C:/develop/nginx-1.12.2</arguments>
  <logpath>C:/develop/nginx-1.12.2/logs/</logpath>
  <logmode>roll</logmode>
</service>

nginx-service.exe.config 文件内容
<configuration>

<startup>     
    <supportedRuntime version="v2.0.50727" />     
    <supportedRuntime version="v4.0" />   
</startup>   
<runtime>     
    <generatePublisherEvidence enabled="false"/>    
</runtime> 

</configuration>

注意相应的目录路径需要以实际路径为准, 下同

3. 安装服务

以管理员打开 cmd, 输入C:\develop\nginx-1.12.2\nginx-service.exe install, 没报错即为正常开启

4. 查看服务

打开 运行(win+R), 输入 service.msc, 然后找到 nginx 的项, 即为成功开启服务, 如图

正文完
 0