Windows服务器下安装Ngnix服务

网上有很多关于在windows server系统下安装Ngnix,并设置为win服务的教程,经过实践,发现了一种相对更完美的方法,记录如下:

1.进入http://nginx.org/en/docs/windows.html,下载Nginx windows版。本文使用的是1.13.5版。

2.进入https://github.com/kohsuke/winsw,下载winsw,用于将Ngnix安装为windows服务。本文使用的是winsw-v2.1.2 net4版,需要先安装.Net Frameworks  4.0。


3.下载sample-minimal.xml(见上图),内容修改如下:

<configuration>
  
  <!-- ID of the service. It should be unique accross the Windows system-->
  <id>Nginx</id>
  <!-- Display name of the service -->
  <name>Nginx Service (powered by WinSW)</name>
  <!-- Service description -->
  <description>This service is a service cratead from a minimal configuration</description>
  
  <!-- Path to the executable, which should be started -->
  <executable>%BASE%\nginx.exe</executable>
  <logpath>%BASE%\logs</logpath>
  <startarguments>-p %BASE%\nginx.exe</startarguments>
  <stopexecutable>%BASE%\nginx.exe</stopexecutable>
  <stoparguments>-s stop</stoparguments>-->

</configuration>
4.将WinSW.NET4.exe文件改名为mynginx.exe,将sample-minimal.xml文件改名为mynginx.xml。然后将这两个改名后的文件放置于Ngnix文件夹下。


5.打开CMD(管理员权限),进入Ngnix路径后输入命令:mynginx.exe install


6.查看windows服务,存在该Ngnix服务,启动和停止Ngnix服务与其他windows服务操作一样。


本文所用windows为windows server 2012 R2版,测试成功。




猜你喜欢

转载自blog.csdn.net/softwave/article/details/78091624