Windows下Nginx开机启动


我们可以借助Windows Service Wrapper小工具【需要.net 4.0环境】,将Nginx转换为Windows服务,这样就可以在开机时自动启动Nginx了。

 

 

下载后将该工具放入Nginx的安装目录下,并且将其重命名为 nginx-service.exe ,在该目录下新建 nginx-service.xml 文件,写入配置信息,配置好了之后就可以通过这个将Nginx注册为Windows服务。

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

以上内容配置好了之后,在nginx安装目录下以管理员运行命令:.\nginx-service.exe install 就成功将其注册为Windows服务了,然后运行 .\nginx-service.exe start 启动服务。这时我们可以在Windows任务管理器的服务中查看该是否成功启动。

 

注:

  • nginx-service.exe install 命令可注册对应的系统服务
  • nginx-service.exe uninstall 命令可删除对应的系统服务
  • nginx-service.exe stop 命令可停止对应的系统服务
  • nginx-service.exe start 命令可启动对应的系统服务

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM