宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应
您当前的位置: > 博客2 > nginx教程

[nginx]安装Nginx做为Windows的服务实现自动启动

2016-10-13 00:16:48 点击量:27 标签: 收藏本文

安装目标系统是windows 7

首先看了这篇文章:http://blog.csdn.net/defonds/article/details/7906005

里面推荐winsw作为注册服务的工具,的确不错。该项目主页在:https://github.com/kohsuke/winsw

使用方法很简单,下载exe文件,重命名为install.exe,然后创建一个install.xml文件,根据主页上介绍的填好设置。

运行后的确成功。但是不能在newlisp程序的exec中调用,始终报下面的错误

  1. annot start service from the command line or a debugger ...  

然后试用.net带来的intallutil.exe,不行,始终报找不到assembly的错误:

 
  1. Exception occurred while initializing the installation:  
  2. System.BadImageFormatException: Could not load file or assembly 'file:///c:\clou  
  3. d_engine\nginx\nginx.exe' or one of its dependencies. The module was expected to  
  4.  contain an assembly manifest..  


最后找到这个:http://ng-srvinst.attron.org/

下载压缩包,解压后看一下read.me, 非常简单。

不过要注意ng_srv.xml文件最后的两项配置:

  1. <service>    
  2.   <id>nginx</id>    
  3.   <name>nginx</name>    
  4.   <description>nginx</description>    
  5.   <executable>cloud-engine-home\nginx\nginx.exe</executable>  
  6.   <logpath>cloud-engine-home\nginx\logs\</logpath>  
  7.   <logmode>roll</logmode>  
  8.   <depend></depend>  
  9.   <startargument>-p cloud-engine-home\nginx</startargument>  
  10.   <stopargument>-p cloud-engine-home\nginx -s stop</stopargument>  
  11. </service>  


-p 后面是Nginx目录,如果写成nginx.exe路径就错了,会造成nginx 服务无法启动。现在newlisp中通过exec调用成功了。

ABOUT US
宜昌农人网络科技有限公司

我们是一家提供综合软件外包与弱电工程服务的技术公司。

业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。

公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室