Windows-server-2012 installing nginx service starts automatically

Time:2021-1-24

1. Download nginx
1.1 mainline version or stable version
Windows-server-2012 installing nginx service starts automatically
2. Download winsw
Download winsw
2.1 rename winsw-2.2.0- bin.exe (user defined name, use nginx here)- service.exe (for example)
2.2 adding an XML file must have the same name as an EXE file

Windows-server-2012 installing nginx service starts automatically

<?xml version="1.0" encoding="UTF-8" ?>

<service>

<id>nginx</id>

<name>nginx</name>

<description>Nginx Startup</description>

<logpath>C:/Program Files/nginx-1.17.7/logs/winsw</logpath>

<logmode>roll</logmode>

<executable>C:/Program Files/nginx-1.17.7/nginx.exe</executable> 

<startargument>-p</startargument>

<startargument>C:/Program Files/nginx-1.17.7</startargument>

<stopargument>-p</stopargument>

<stopargument>C:/Program Files/nginx-1.17.7</stopargument>

<stopargument>-s</stopargument>

<stopargument>stop</stopargument>

</service>

Remember to separate the instructions, otherwise the system will report 1067 error when starting the service
2.3 input command nginx under file path- service.exe install
2.4 after successful installation
Enter the start command net start nginx
Stop command net stop nginx
Windows-server-2012 installing nginx service starts automatically