I set up NGINX as a front end server for static content and I use Apache as a back-end server for other thing.
The thing is I can't find a logical answer that allows me to make nginx.exe
a Windows system service (like my Apache).
Any come across an answer to this?
Nginx installation on Windows ServerDownload the latest mainline release from https://nginx.org/en/download.html. Extract the file to the location where you want to install Nginx, such as C:\nginx. Note: We recommend creating a new directory for Nginx.
Check Nginx is running or not We can verify that the Nginx is installed and running by using the following command: $ ps -ef | grep nginx.
Make a . bat file in the nginx.exe folder with the command: nginx.exe -s quit . Then make a shortcut to desktop or whereever needed.
How to do it with Windows Service Wrapper
(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)
winsw-*.exe
to something like nginxservice.exe
. 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>
nginxservice.exe install
as administrator.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:
You can find the latest version of the Windows Service Wrapper also via this Maven Repository: http://repo.jenkins-ci.org
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 } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With