1.创建windows服务用到一个小工具WinSW:https://github.com/kohsuke/winsw/releases(下载 .exe 文件即可,根据系统选择,Win 10 选择 .NET4 版本,以下选择 .NET2 版本)

2.把php-cgi.exe注册成windows服务除了需要用到WinSW以外,还需要用到xxfpm,用来开启 PHP-CGI 多进程,下载地址:https://github.com/78/xxfpm

3.将下载到的WinSW.NET4.exe更名为nginxservice.exe,放到nginx.exe所在的目录下,在该目录下新增文件 nginxservice.xml,修改nginxservice.xml配置如下:

<service>

 <id>nginx</id>

 <name>nginx</name>

 <description>nginx</description>

 <logpath>E:\nginx-1.12.2\</logpath>

 <logmode>roll</logmode>

 <depend></depend>

  <executable>E:\nginx-1.12.2\nginx.exe</executable>

  <stopexecutable>E:\nginx-1.12.2\nginx.exe -s quit</stopexecutable>

</service>

4.在E:\nginx-1.12.2\下执行 nginxservice.exe install,即可生成windows服务,卸载命令:nginxservice.exe uninstall

5.php的服务注册需要先下载xxfpm,将下载的xxfpm.exe 和 pthreadGC2.dll 扔进php-cgi.exe所在的目录

6.将下载到的WinSW.NET4.exe更名为phpservice.exe,放到php-cgi.exe所在的目录下,在该目录下新增文件 phpservice.xml,修改phpservice.xml配置如下

<service>
    
<id>phpservice</id>
    
<name>phpservice</name>
    
<description>phpservice</description>

<executable>xxfpm.exe</executable>
<startargument>"E:/ServerCore/php/php-cgi.exe -c E:/ServerCore/php/php.ini"</startargument>
    
<startargument>-n</startargument>
 
<startargument>1</startargument>
    
<startargument>-i</startargument>

<startargument>127.0.0.1</startargument>

<startargument>-p</startargument>

<startargument>9000</startargument>

<stopexecutable>taskkill</stopexecutable>
<stopargument>/F</stopargument>
<stopargument>/IM</stopargument>
 
<stopargument>xxfpm.exe</stopargument>
<logpath>logs</logpath>

</service>

5.在 E:/ServerCore/php\下执行 phpservice.exe install,即可生成windows服务

posted on 2018-12-07 15:42  二豆  阅读(2459)  评论(1编辑  收藏  举报