Download winsw
Address: https://github.com/kohsuke/winsw
There are two versions winsw2.X and winsw1.X, winsw1.X has stopped updating, maintenance and repair only
winsw2.x Frameworks are divided into the .NET 2.0
and 4.0版本,选择适合自己的!
After extracting the following
Choose your own version!
There are two xml files, a simple configuration file (only the server name, description, and to be packaged into the path of the .exe),
Another detail is the detailed configuration file, as well as log files, log format, startup mode (from Kai, manual, etc.) and other configuration details
Copy WinSw.NET2.exe (or WinSw.NET4.exe) and just a nginx xml file to the root directory of the file renaming !
Rename into the same name on it!
Write configuration file
<configuration>
<!-- ID of the service. It should be unique accross the Windows system-->
<id>nginx</id>
<!-- Display name of the service -->
<name>服务的名字</name>
<!-- Service description -->
<description>描述</description>
<executable>%BASE%\nginx.exe</executable>
<!-- 日志路径-->
<logpath>%BASE%\logs\winsw</logpath>
<!--参考:https://github.com/kohsuke/winsw/blob/master/doc/loggingAndErrorReporting.md-->
<log mode="roll-by-size-time">
<sizeThreshold>10240</sizeThreshold>
<pattern>yyyyMMdd</pattern>
<autoRollAtTime>00:00:00</autoRollAtTime>
<zipOlderThanNumDays>10</zipOlderThanNumDays>
<zipDateFormat>yyyyMM</zipDateFormat>
</log>
</configuration>
Then use the command window to the administrator under nginx root directory, with the name after you execute the following command to rename
For example: nginx-install.exe install installation services
install
to install the service to Windows Service Controller. This command requires some preliminary steps described in the Installation Guide.uninstall
to uninstall the service. The opposite operation of above.start
to start the service. The service must have already been installed.stop
to stop the service.restart
to restart the service. If the service is not currently running, this command acts likestart
.status
to check the current status of the service.- This command prints one line to the console.
NonExistent
indicates the service is not currently installedStarted
to indicate the service is currently runningStopped
to indicate that the service is installed but not currently running.
- This command prints one line to the console.