在Apache的启动/重新启动后台运行的PHP脚本(在Windows Server) [英] Run PHP script in background on Apache start/restart(Windows Server)

查看:1086
本文介绍了在Apache的启动/重新启动后台运行的PHP脚本(在Windows Server)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Windows Server 2008下对本手册的说明,安装了Apache 2.4和PHP 5.4:
Apache的安装手册
阿帕奇现在作为服务运行。

I've installed Apache 2.4 with PHP 5.4 on Windows Server 2008 following instructions from this manual: Apache installing manual. Apache runs as a service now.

我的应用程序需要一个PHP的WebSocket脚本在后台运行。我与手动运行它:

My application requires a php websocket script to run in the background. I'm running it manually with:

php myscript.php

现在的问题是:是否有一个对系统(阿帕奇)重新启动

The question is: Is there a way to start a background script automatically on system(apache) restart?

我发现下面的<一个href=\"http://stackoverflow.com/questions/2992938/is-it-possible-to-launch-a-php-script-at-apache-startup\">topic,但我不知道在那里我能找到Apache启动脚本为Windows。

I found the following topic, but I didn't know where I could find an apache startup script for Windows.

任何帮助将大大appriciated。

Any help will be much appriciated.

推荐答案

我想出了一个解决方案:)


  • 创建环境变量指向你的Apache目录

    I come up with a solution :)

  • Create an environment variable pointing to your Apache directory

    APACHE_HOME = C:/PATH/TO_APACHE
    

  • 重命名 %APACHE_HOME%\\ bin中\\ httpd.exe %APACHE_HOME%\\ bin中\\ httpdVendor .EXE

  • 创建一个批处理文件,并把下面的code:

  • Rename %APACHE_HOME%\bin\httpd.exe to %APACHE_HOME%\bin\httpdVendor.exe
  • Create a batch file and put the following code :

    php myscript.php
    %APACHE_HOME%\bin\httpdVendor.exe -k runservice
    exit 0
    


  • 下载/安装免费软件 BatToExeConverter (下一步,下一步,...)

  • 打开已安装的转换器和打开您刚创建批处理文件

  • 点击按钮的生成EXE (让默认配置)

  • 保存文件:%APACHE_HOME%\\ bin中\\ httpd.exe

  • 开始您的Apache服务器

  • Download/Install the free software BatToExeConverter (next, next, ...)
  • Open the installed converter and open your freshly created batch file
  • Click on the button Build EXE (let the default configuration)
  • Save the file : %APACHE_HOME%\bin\httpd.exe
  • Start your Apache Server
  • 在测试了:Windows 7中,阿帕奇2.4,蝙蝠先进的EXE转换器2.92

    Tested on : Windows 7, Apache 2.4, Advanced Bat to Exe Converter 2.92

    这篇关于在Apache的启动/重新启动后台运行的PHP脚本(在Windows Server)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆