将nginx.exe添加为Windows系统服务(例如Apache)吗? [英] Add nginx.exe as Windows system service (like 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)
- 通过
Windows Service Wrapper .com/kohsuke/winsw/releases"rel =" nofollow noreferrer> github 或 nuget . - 撰写本文时,当前版本为 v2.2.0
- 由于适用于.NET2.0和.NET4.0的v2.x可执行文件-仅在需要时提供其他可执行文件.
- 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>
- 您可以在此处 和安装指南.
- You can find up to date details about the configuration on the config github page, a generic example showing all possible options here and an installation guide.
您现在将在服务"中拥有一个nginx
服务! (它设置为在启动时自动启动;如果要启动服务器,则必须手动启动服务(net start nginx
).)
You will now have an nginx
service in your Services! (It is set to start automatically on boot; if you want to start your server, you must manually start the service (net start nginx
).)
Detailed description of correctly setting up nginx as a Windows Service: http://web.archive.org/web/20150819035021/http://misterdai.yougeezer.co.uk/posts/2009/10/16/nginx-windows-service/
以上博客文章中未包含的其他信息:
Additional info not contained in above blog post:
您还可以通过以下Maven存储库找到Windows Service Wrapper的最新版本: http://repo.jenkins-ci.org
You can find the latest version of the Windows Service Wrapper also via this Maven Repository: http://repo.jenkins-ci.org
Maven + Gradle的示例:
Examples for Maven + Gradle:
<dependency>
<groupId>com.sun.winsw</groupId>
<artifactId>winsw</artifactId>
<version>2.2.0</version>
<classifier>bin</classifier>
<packaging>exe</packaging>
</dependency>
<repository>
<id>jenkinsci</id>
<name>jenkinsci-releases</name>
<url>http://repo.jenkins-ci.org/releases</url>
</repository>
compile "com.sun.winsw:winsw:2.2.0"
repositories {
mavenCentral()
maven { url http://repo.jenkins-ci.org/releases }
}
这篇关于将nginx.exe添加为Windows系统服务(例如Apache)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!