Opened 12 years ago

Closed 12 years ago

Last modified 2 years ago

#209 closed enhancement (invalid)

How to Install nginx as a Service on Windows

Reported by: Johan Carstensen Owned by: somebody
Priority: minor Milestone:
Component: nginx-core Version: 1.3.x
Keywords: Cc:
uname -a:
nginx -V: 1.3.5

Description

Create service folder:

C:\Program Files\nginx-1.3.5\service

install.bat:
sc create nginxSvc binPath= "C:\Program Files\nginx-1.3.5\service\srvany.exe" start= auto DisplayName= "nginx Service"
REG ADD "HKLM\SYSTEM\CurrentControlSet\Services\nginxSvc\Parameters" /v Application /t REG_SZ /d "C:\Program Files\nginx-1.3.5\service\service.bat" /f
sc start nginxSvc

service.bat:
:LOOP
echo Starting nginx Service
C:
cd "\Program Files\nginx-1.3.5\"
"C:\Program Files\nginx-1.3.5\nginx.exe"
SLEEP 1
GOTO LOOP

uninstall.bat:
echo Stopping nginx Service
C:
cd "\Program Files\nginx-1.3.5\"
"C:\Program Files\nginx-1.3.5\nginx.exe" -s stop
sc stop nginxSvc
sc delete nginxSvc

Download srvany.exe and put it in the folder.

Br Johan Carstensen

Attachments (1)

service.zip (4.7 KB ) - added by Johan Carstensen 12 years ago.

Download all attachments as: .zip

Change History (3)

by Johan Carstensen, 12 years ago

Attachment: service.zip added

comment:1 by Maxim Dounin, 12 years ago

Resolution: invalid
Status: newclosed

There is more than one way to create user-defined services on windows, including this one, documented by Microsoft here. Though in any case this doesn't belong to nginx-core, and we certainly don't want to distribute srvany.exe (and I actually think we can't from legal point of view). Though probably deserve link somewhere in the documentation.

You may also want to provide some details/example scripts somewhere near http://wiki.nginx.org/InitScripts, much like it's already done for may other OSes. Please don't include srvany.exe though, provide a link to official download page instead.

comment:2 by Pablo Somodi, 11 years ago

Hi!
I've created a nginx installer for windows using an open source alternative to srvany.
If you want to take a look: https://github.com/InvGate/winginx

Note: See TracTickets for help on using tickets.