💻

将 Nginx 安装为 Windows Service

Created
Dec 12, 2022 02:43 PM
Tags
nginx
💡
Quick way to install nginx as windows service, 5 minutes to read.

Get Nginx

  1. Latest version http://nginx.org/en/docs/windows.html

Extact to local path

I would prefer put in C drive.
C:\server\nginx

Install as service

  1. Download the latest version of Windows Service Wrapper  via github  or nuget
  1. Rename winsw-*.exe to something like nginx-service.exeand place it in nginx folder
notion image
  1. Add a nginx-service.xml in same follow as folllowing content
<!-- install command: nginx-service.exe install --> <!-- uninstall command: nginx-service.exe uninstall --> <service> <id>nginx</id> <name>nginx</name> <description>nginx</description> <executable>C:\server\nginx\nginx.exe</executable> <logpath>C:\server\nginx\</logpath> <logmode>roll</logmode> <depend></depend> <startargument>-p</startargument> <startargument>C:\server\nginx</startargument> <stopexecutable>C:\server\nginx\nginx.exe</stopexecutable> <stopargument>-p</stopargument> <stopargument>C:\server\nginx</stopargument> <stopargument>-s</stopargument> <stopargument>stop</stopargument> </service>
  1. Open an admin command window and run nginx-service install from nginx folder.
notion image
  1. Now start the nginx from service window.
notion image