将nginx安装到Windows服务

  • 安装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

 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值