Install nginx service under windows

Download nginx

Link: https://nginx.org/en/download.html

Register nginx as a service under windows

1. Download the registration service tool, download address: http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/1.18/winsw-1.18-bin.exe, after downloading the tool, put it In the root directory of nginx

2. Create a new one in the root directory of nignx mynginx.xml(必须和前面的mynginx.exe一致)and edit the content:

<service>
 
 <id>nginx</id>
 
 <name>nginx</name>
 
 <description>nginx</description>
 
 <logpath>C:\nginx</logpath>
 
 <logmode>roll</logmode>
 
 <depend></depend>
 
  <executable>C:\nginx\nginx.exe</executable>
 
  <stopexecutable>C:\nginx\nginx.exe -s stop</stopexecutable>
 
</service>

stopexecutable, executable, the real path logpathfornignx

3. Enter the nginx root directory and execute the following command to register nginx as a system service
mynginx.exe install
and start nginx:net start nginx

Stop nginx:net stop nginx

Delete all nginx processes (can start multiple nginx.exe)
taskkill /IM nginx.exe /F

common problem

Error installing nginx service in windows

There are many tutorials for installing services using "Windows Service Wrapper", so I won't go into details here.
An error was reported during the installation process. The error message is as follows:

E:\xampp\nginx>nginx-service.exe install
WMI.WmiException: AccessDenied
in WMI.WmiRoot.ClassHandler.Invoke(Object proxy, MethodInfo method, Object[] args)
in WMI.Win32ServicesProxy.Create(String, String, String , ServiceType, ErrorControl, StartMode, Boolean, String, String, String[]) found
in winsw.WrapperService.Run(String[] _args, ServiceDescriptor descriptor)
in winsw.WrapperService.Main(String[] args)
because management is not used Run with administrator privileges, right-click mynginx.exeand select Run as administrator

Guess you like

Origin blog.csdn.net/weixin_38090079/article/details/132617206