windows nginx安装与开机启动

打开nginx官网

http://nginx.org/en/download.html

选择一个稳定版本Stable version 下载到自己硬盘,文件夹命名为英文,比如 nginx-1.14.0

下载好后解压到文件夹里面,里面有个nginx.exe

在系统环境变量里添加上path路径

打开https://github.com/kohsuke/winsw/releases  

里面有人不断的更新WINSW,我们需要下载一个这个来注册服务

我下载的是 winsw-v2.1.2版本 WinSW.NET4.exe 这个

下载好后放到 nginx-1.14.0 文件夹下

修改名称为 nginxservice.exe

创建个文本文档 ,粘贴以下内容

以我的nginx文件夹路径为例,我的文件是在  D:WNMP/Nginx-1.14.0 下,所以下边的路径自己根据自己的修改。修改的地方一共三处

<service>

 <id>nginx</id>

 <name>nginx</name>

 <description>nginx</description>

 <logpath>D:WNMP/Nginx-1.14.0</logpath>

 <logmode>roll</logmode>

 <depend></depend>

  <executable>D:WNMP/Nginx-1.14.0 ginx.exe</executable>

  <stopexecutable>D:WNMP/Nginx-1.14.0 ginx.exe -s stop</stopexecutable>

</service>

粘贴上,修改好后,重命名文件的名称以及扩展名为xml,要和 nginxservice.exe 这个对应,nginxserviece.xml

这样子就可以安装了

以管理员权限打开cmd

进行安装  nginxservice.exe install

安装好后进入服务查看,把他启动上。

原文地址:https://www.cnblogs.com/muwu/p/8970360.html