nginx for windows安装为服务运行

下载winsw

地址:https://github.com/kohsuke/winsw

有两个版本winsw2.X 和 winsw1.X ,winsw1.X已经停止更新了,只做维护和修复

winsw2.x又分为.NET Frameworks 2.0 and 4.0版本,选择适合自己的!

解压以后如下

nginx for windows安装为服务运行_第1张图片

选择适合自己的版本 !

有两个xml文件,一个是简单配置文件(只有server的名字,描述,以及要包装成的.exe路径),

另一个是明细详细配置文件,还有日志文件,日志格式,启动模式(自启,手动等)等明细配置

将WinSw.NET2.exe (或WinSw.NET4.exe)和随便一个xml文件拷贝到nginx根目录,将文件重命名!

 nginx for windows安装为服务运行_第2张图片

重命名成一样的名字就可以了!

编写配置文件


  
  
  nginx
  
  服务的名字
  
  描述
  
 
  %BASE%\nginx.exe

  %BASE%\logs\winsw
    
  
      10240
      yyyyMMdd
      00:00:00
      10
      yyyyMM
  

 然后使用管理员命令窗口到nginx根目录下,用你重命名后的名字去执行以下命令

例如:nginx-install.exe install   安装服务

  • install to install the service to Windows Service Controller. This command requires some preliminary steps described in the Installation Guide.
  • uninstall to uninstall the service. The opposite operation of above.
  • start to start the service. The service must have already been installed.
  • stop to stop the service.
  • restart to restart the service. If the service is not currently running, this command acts like start.
  • status to check the current status of the service.
    • This command prints one line to the console.
      • NonExistent indicates the service is not currently installed
      • Started to indicate the service is currently running
      • Stopped to indicate that the service is installed but not currently running.

你可能感兴趣的:(nginx)