且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 Apache 启动/重启(Windows Server)的后台运行 PHP 脚本

更新时间:2023-02-22 21:03:04

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

  • 创建一个指向 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
  • 创建一个批处理文件并输入以下代码:

  • 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(下一个,下一个,...)
  • 打开已安装的转换器并打开您新创建的批处理文件
  • 点击按钮Build 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、Apache 2.4、Advanced Bat to Exe Converter 2.92

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