使用 AutoIt3 在 Windows 下实现一个简单的 PHP-FPM

代码见真章,请勿直接用,按注释修改。

#NoTrayIcon

AutoItSetOption("MustDeclareVars", 1);限定变量必须先定义后使用,防止出错

;定义全局常量
Global Const $phpDir = "D:\Webserver\PHP53";PHP 路径
Global Const $phpFile = "php.exe";PHP 程序名
Global Const $phpExe = $phpDir & "\" & $phpFile;PHP 完整路径
Global Const $phpCgiFile = "php-cgi.exe";PHP-CGI 程序名
Global Const $phpCgiExe = $phpDir & "\" & $phpCgiFile;PHP-CGI 完整路径
Global Const $phpIniFile = "php.ini";PHP.INI 名
Global Const $phpIni = $phpDir & "\" & $phpIniFile;PHP.INI 完整路径

__onStart();运行前执行

OnAutoItExitRegister("__onExit");注册回调(退出后执行)

__main();执行主函数

Exit;退出

#comments-start
启动时运行函数
#comments-end
Func __onStart()

EndFunc ;==>__onStart

#comments-start
主函数
#comments-end
Func __main()
    If ($CmdLine[0] >= 1) Then
        __cmdMain()
        Exit
    EndIf
EndFunc ;==>__main

#comments-start
命令行主函数
#comments-end
Func __cmdMain()
    While 1
        If (__checkPhpCgiProcess() < $CmdLine[1]) Then
            __runPhpCgi($CmdLine[1] - __checkPhpCgiProcess())
        EndIf
        Sleep(10000)
    WEnd
EndFunc ;==>__cmdMain

#comments-start
退出时运行函数
#comments-end
Func __onExit()

EndFunc ;==>__onExit

#comments-start
检查 PHP-CGI 是否在运行
@return boolean 运行返回 true,否则返回 false
#comments-end
Func __checkPhpCgiState()
    Return ProcessExists($phpCgiFile)
EndFunc ;==>__checkPhpCgiState

#comments-start
检查 PHP-CGI 进程数
@return int 返回目前 PHP-CGI 进程数
#comments-end
Func __checkPhpCgiProcess()
    Local $phpCgiProcessArray = ProcessList($phpCgiFile)
    Return IsArray($phpCgiProcessArray) ? $phpCgiProcessArray[0][0] : 0;
EndFunc ;==>__checkPhpCgiProcess

#comments-start
运行 PHP-CGI
@param int $start 运行几个 PHP-CGI
#comments-end
Func __runPhpCgi($start = 3)
    Local $i = 1
    For $i = 1 To $start Step 1
        Run($phpCgiExe & " -b 127.0.0.1:9000", $phpDir, @SW_HIDE)
    Next
EndFunc ;==>__runPhpCgi

#comments-start
结束 PHP-CGI
#comments-end
Func __stopPhpCgi()
    While __checkPhpCgiState()
        __closePhpCgiProcess()
    WEnd
EndFunc ;==>__stopPhpCgi

#comments-start
结束 PHP-CGI 进程
#comments-end
Func __closePhpCgiProcess()
    ProcessClose($phpCgiFile)
EndFunc ;==>__closePhpCgiProcess
此文章是由nikbobo发表在PHP分类目录的。将固定链接加入收藏夹。

关于 nikbobo

Nikbobo,本名刘永强,记忆空间站长,男,1998 年出生于广东茂名,至今(2022 年)23 岁,目前(2022 年)就读于广州大学华软软件学院,常以“nikbobo”这个网名混迹互联网。如无特殊注明,Nikbobo 在本站发表的文章,遵循 知识共享 署名-非商业性使用-相同方式共享 4.0 国际 许可协议。详情请参阅关于页面的作者介绍。

使用 AutoIt3 在 Windows 下实现一个简单的 PHP-FPM》上有2个想法

  1. 好久不见,我最近发现了一款可以通过杀软锁主页软件,我想发给你研究一下。他的原理是什么。软件本身下载下来杀软都会拦截或者误杀。运行起来修改主页杀软虽然是有提示,但是最后还是被设置了。目前就360软件运行状态下无法设置主页。bobo什么时候有时间研究下。回复我信息。

    • 发到QQ邮箱,我看看,最近总算能有一点时间了,研究一下,不过我不干这个那么久了,还会不会也不保证。破出来就真的帅了。

回复 匿名 取消回复

您的电子邮箱地址不会被公开。