Register nginx as a service and start automatically under Windows Environment

Time:2021-10-12

1. Download nginxnginx
2. Download Windows Service Wrapper
GitHub download address

Network disk download address

3. Change the name of the downloaded winsw tonginx-service.exePlace inningxDirectory
Register nginx as a service and start automatically under Windows Environment

4. Create a new filenginx-service.xmlThe contents are as follows (also placed innginxDirectory:

<!-- nginx-service.xml -->
<service>
<id>nginx</id>
<name>nginx</name>
<description>nginx</description>
<logpath>D:\SoftRepository\DevelopmentTools\nginx-1.16.1</logpath>
<logmode>roll</logmode>
<depend></depend>
<executable>D:\SoftRepository\DevelopmentTools\nginx-1.16.1\nginx.exe</executable>
<stopexecutable>D:\SoftRepository\DevelopmentTools\nginx-1.16.1\nginx.exe -s stop</stopexecutable>
</service>

amonglogpath,executable,executableModify the path in to your own nginx path

Register nginx as a service and start automatically under Windows Environment

5. Then we register the service in the windows system on the command line (administrator mode, otherwise the permission is insufficient):

nginx-service install

6. View Task Manager
!Register nginx as a service and start automatically under Windows Environment
There are already nginx services. Click start

7. After shutdown and restart, you will find that nginx has been started without the command line