将nginx.exe添加为Windows系统服务(例如Apache)吗? [英] Add nginx.exe as Windows system service (like Apache)?

查看:432
本文介绍了将nginx.exe添加为Windows系统服务(例如Apache)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将NGINX设置为静态内容的前端服务器,而将Apache用作其他内容的后端服务器.

I set up NGINX as a front end server for static content and I use Apache as a back-end server for other thing.

问题是我找不到使我能够将nginx.exe用作Windows系统服务(例如我的Apache)的逻辑答案.

The thing is I can't find a logical answer that allows me to make nginx.exe a Windows system service (like my Apache).

有人碰到这个答案吗?

推荐答案

如何使用 Windows Service Wrapper

(注意:到目前为止,还有其他更容易的选择-另请参见下面使用Chocolatey软件包管理器所述的解决方案, suneg 直接使用NSSM 来自 Adamy )

(Note: There are easier alternatives by now - see also solutions described here below using chocolatey package manager by suneg and using NSSM directly from Adamy)

  1. 通过 Windows Service Wrapper .com/kohsuke/winsw/releases"rel =" nofollow noreferrer> github 或 nuget .
    • 撰写本文时,当前版本为 v2.2.0
    • 由于适用于.NET2.0和.NET4.0的v2.x可执行文件-仅在需要时提供其他可执行文件.
  1. Download the latest version of Windows Service Wrapper via github or nuget.
    • Current version as of this writing is v2.2.0
    • Since v2.x executables for .NET2.0 and .NET4.0 are available - others only on demand.
  • 这是将为拥有您的nginx进程的进程显示的名称.

在exe旁边放置一个具有相同基本名称的XML文件,例如nginxservice.xml.内容应如下所示(验证您的nginx位置).

Place an XML file next to the exe with the same base name, e.g. nginxservice.xml. The contents should be like below (verify your nginx location).

<service>
  <id>nginx</id>
  <name>nginx</name>
  <description>nginx</description>
  <executable>c:\nginx\nginx.exe</executable>
  <logpath>c:\nginx\</logpath>
  <logmode>roll</logmode>
  <depend></depend>
  <startargument>-p</startargument>
  <startargument>c:\nginx</startargument>
  <stopexecutable>c:\nginx\nginx.exe</stopexecutable>
  <stopargument>-p</stopargument>
  <stopargument>c:\nginx</stopargument>
  <stopargument>-s</stopargument>
  <stopargument>stop</stopargument>
</service>

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆