Install Nginx and create it as a Windows service

Install Nginx

Download the Windows version of nginx (http://nginx.org/download/nginx-1.10.0.zip), and then unzip it to the desired location (D:\xampp\nginx)

Set up Nginx as a Windows service

Need to use "Windows Service Wrapper" gadget, project address:  https://github.com/kohsuke/winsw

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 Nginx installation directory, rename it to nginx-service.exe, and create a configuration file nginx-service.xml (the name should be the same as the tool name),

Create nginx-service.exe.config (to support NET 4.0 runtime, only NET 2.0 runtime is supported by default)

The file structure is as follows:

The content of nginx-service.xml is as follows:

 

<service>
  <id>nginx</id>
  <name>Nginx Service</name>
  <description>High Performance Nginx Service</description>
  <logpath>D:\xampp\nginx\logs</logpath>
  <log mode="roll-by-size">
    <sizeThreshold>10240</sizeThreshold>
    <keepFiles>8</keepFiles>
  </log>
  <executable>D:\xampp\nginx\nginx.exe</executable>
  <startarguments>-p D:\xampp\nginx</startarguments>
  <stopexecutable>D:\xampp\nginx\nginx.exe</stopexecutable>
  <stoparguments>-p D:\xampp\nginx -s stop</stoparguments>
</service>

 

<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727" />
    <supportedRuntime version="v4.0" />
  </startup>
  <runtime>
    <generatePublisherEvidence enabled="false"/>
  </runtime>
</configuration>

 

Run the following command in cmd to install the windows service

D:\xampp\nginx\nginx-service.exe install

After that you can start the service in the Windows Services panel

It can be accessed normally in the browser

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326118328&siteId=291194637