- 安装nginx不做赘述
nginx官网http://nginx.org/en/download.html
- 下载winsw
将下载到的可执行程序文件放到nginx安装目录,重命名为nginxservice.exe
附上地址:https://download.csdn.net/download/april_moon/11177584
新建配置文件命名为:nginxservice.xml,内容:
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>D:\Program Files\nginx-1.15.5\logs\</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>D:\Program Files\nginx-1.15.5\nginx.exe</executable>
<stopexecutable>D:\Program Files\nginx-1.15.5\nginx.exe -s stop</stopexecutable>
</service>
<!-- - name为服务名
- logpath指定nginx日志文件地址
- D:\Program Files\nginx-1.15.1\nginx.exe为nginx可执行应用程序文件位置
-->
- 开始安装
管理员身份打开cmd,进入nginx目录,执行命令:
nginxservice.exe install //其中nginxservice为上面链接中winsw-1.18-bin手动改名而来)
其中:
nginx-service.exe uninstall //命令可删除对应的系统服务
nginx-service.exe stop //命令可停止对应的系统服务
nginx-service.exe start //命令可启动对应的系统服务
完整命令nginxservice.exe -h
Available commands:
- 'install' - install the service to Windows Service Controller
- 'uninstall' - uninstall the service
- 'start' - start the service (must be installed before)
- 'stop' - stop the service
- 'restart' - restart the service
- 'restart!' - self-restart (can be called from child processes)
- 'status' - check the current status of the service
- 'test' - check if the service can be started and then stopped
- 'version' - print the version info
- 'help' - print the help info (aliases: -h,--help,-?,/?)
Extra options:
- '/redirect' - redirect the wrapper's STDOUT and STDERR to the specified file