2019-01-21 把nginx和php-cgi.exe注册成windows服务

  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配置如下:

 nginx
 nginx
 nginx
 E:\nginx-1.12.2\
 roll
 
  E:\nginx-1.12.2\nginx.exe
  E:\nginx-1.12.2\nginx.exe -s quit

  1. 在E:\nginx-1.12.2\下执行 nginxservice.exe install,即可生成windows服务,卸载命令:nginxservice.exe uninstall
  2. php的服务注册需要先下载xxfpm,将下载的xxfpm.exe 和 pthreadGC2.dll 扔进php-cgi.exe所在的目录
  3. 将下载到的WinSW.NET4.exe更名为phpservice.exe,放到php-cgi.exe所在的目录下,在该目录下新增文件 phpservice.xml,修改phpservice.xml配置如下

phpservice
phpservice
phpservice
xxfpm.exe
"D:/apps/php-5.6.40x64/php-cgi.exe -c D:/apps/php-5.6.40x64/php.ini"
-n
1
-i
127.0.0.1
-p
9000
taskkill
/F
/IM
xxfpm.exe
logs

  1. 在 D:\apps\php-5.6.40x64下执行 phpservice.exe install,即可生成windows服务
D:\apps\php-5.6.40x64>phpservice.exe install
2019-01-21 09:49:25,245 INFO  - Installing the service with id 'phpservice'

你可能感兴趣的:(2019-01-21 把nginx和php-cgi.exe注册成windows服务)