在 Apache 启动/重启(Windows Server)的后台运行 PHP 脚本 [英] Run PHP script in background on Apache start/restart(Windows Server)
问题描述
我已经按照本手册中的说明在 Windows Server 2008 上安装了带有 PHP 5.4 的 Apache 2.4:Apache 安装手册.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
问题是:有没有办法在系统(apache)重启时自动启动后台脚本?
The question is: Is there a way to start a background script automatically on system(apache) restart?
我发现了以下主题,但我不知道在哪里可以找到适用于 Windows 的 apache 启动脚本.
I found the following topic, but I didn't know where I could find an apache startup script for Windows.
任何帮助都会非常有用.
Any help will be much appriciated.
推荐答案
我想出了一个解决方案 :)
I come up with a solution :)
APACHE_HOME = C:/PATH/TO_APACHE
%APACHE_HOME%\bin\httpd.exe
到 %APACHE_HOME%\bin\httpdVendor.exe
%APACHE_HOME%\bin\httpd.exe
to %APACHE_HOME%\bin\httpdVendor.exe
php myscript.php
%APACHE_HOME%\bin\httpdVendor.exe -k runservice
exit 0
%APACHE_HOME%\bin\httpd.exe
%APACHE_HOME%\bin\httpd.exe
测试:Windows 7、Apache 2.4、Advanced Bat to Exe Converter 2.92
Tested on : Windows 7, Apache 2.4, Advanced Bat to Exe Converter 2.92
这篇关于在 Apache 启动/重启(Windows Server)的后台运行 PHP 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!