<noframes id="bhrfl"><address id="bhrfl"></address>

    <address id="bhrfl"></address>

    <noframes id="bhrfl"><address id="bhrfl"><th id="bhrfl"></th></address>

    <form id="bhrfl"><th id="bhrfl"><progress id="bhrfl"></progress></th></form>

    <em id="bhrfl"><span id="bhrfl"></span></em>

    全部
    常見問題
    產品動態
    精選推薦

    檢測服務器環境,實現快速部署。適用于CRMEB_PRO/多店

    管理 管理 編輯 刪除

    運行效果如圖:

    241b4202311271112504772.png

    最近被好多人問,本來運行的好好的,突然swoole就啟動不了了。

    本工具為愛發電,如果工具正好解決了您的需求。我會很開心

    代碼如下:

    """
        本腳本為愛發電
        by:網前雨刮器
    """
    import subprocess
    import re
    
    def check_php_environment():
        def check_php_version():
            try:
                output = subprocess.check_output(['php', '-v'], stderr=subprocess.STDOUT)
                result = output.decode('utf-8')
                php_version_str = result.split('\n')[0]
                php_version = php_version_str.lower().split(' ')[1]
    
                if php_version.startswith('7.'):
                    major_version, minor_version, patch_version = map(int, php_version.split('.'))
                    if 7 <= major_version <= 7 and 1 <= minor_version <= 4:
                        print(f"\033[32mPHP版本通過 (當前版本:{php_version})\033[0m")
                    else:
                        print(f"\033[31mPHP版本不通過 (當前版本:{php_version})\033[0m")
                else:
                    print(f"\033[31mPHP版本不通過 (當前版本:{php_version})\033[0m")
    
            except subprocess.CalledProcessError as e:
                return None
    
        def check_php_extension(extension_name, expected_version=None):
            try:
                output = subprocess.check_output(['php', '-m'], stderr=subprocess.STDOUT)
                result = output.decode('utf-8')
                installed_extensions = result.split()
    
                if extension_name in installed_extensions:
                    print(f"\033[32m{extension_name} 已安裝\033[0m")
    
                    if expected_version is not None:
                        output = subprocess.check_output(['php', '--ri', extension_name], stderr=subprocess.STDOUT)
                        result = output.decode('utf-8')
    
                        match = re.search(r"Version => (.+)", result)
                        if match:
                            version = match.group(1).strip()
                            print(f"\033[32m{extension_name} 版本號為 {version}\033[0m")
    
                            if not re.match(expected_version.replace("*", r"\d+"), version):
                                return None
                                # print(f"報錯:{extension_name} 擴展的版本號不滿足要求")
                        else:
                            return None
                            #print(f"無法獲取 {extension_name} 擴展的版本信息")
                else:
                    print(f"\033[31m{extension_name} 擴展未安裝\033[0m")
    
            except subprocess.CalledProcessError as e:
                print(f"無法執行命令: {e.output}")
    
        def check_proc_open():
            try:
                output = subprocess.check_output(['php', '-i'], stderr=subprocess.STDOUT)
                result = output.decode('utf-8')
    
                if 'disable_functions' in result:
                    disable_functions = result.split('disable_functions => ')[1].split(' =>')[0]
                    if 'proc_open' in disable_functions:
                        print("\033[31mproc_open 函數已被禁用\033[0m")
                    else:
                        print("\033[32mproc_open 函數未被禁用\033[0m")
                else:
                    print("無法獲取禁用函數列表")
    
            except subprocess.CalledProcessError as e:
                print(f"無法執行命令: {e.output}")
        
        def check_mysql_version():
            try:
                output = subprocess.check_output(['mysql', '-V'], stderr=subprocess.STDOUT)
                result = output.decode('utf-8')
                version_match = re.search(r"\d+\.\d+\.\d+", result)
                if version_match:
                    mysql_version = version_match.group(0)
                    if mysql_version.startswith('5.6.') or mysql_version.startswith('5.7.'):
                        print(f"\033[32mMySQL 版本通過 (當前版本:{mysql_version})\033[0m")
                    else:
                        print(f"\033[31mMySQL 版本不通過 (當前版本:{mysql_version})\033[0m")
                else:
                    print("\033[31m無法獲取MySQL 版本號\033[0m")
        
            except subprocess.CalledProcessError as e:
                print(f"無法執行命令: {e.output}")
    
        def check_web_server():
            try:
                apache_process = subprocess.check_output(['ps', '-ef']).decode('utf-8')
                if 'apache2' in apache_process or 'httpd' in apache_process:
                    print("\033[32m當前環境為 Apache  (建議使用Nginx)\033[0m")
                    return
        
                nginx_process = subprocess.check_output(['ps', '-ef']).decode('utf-8')
                if 'nginx' in nginx_process:
                    print("\033[32m當前環境為 Nginx\033[0m")
                    return
        
                print("\033[31m未檢測到 Apache 或 Nginx 進程\033[0m")
        
            except subprocess.CalledProcessError as e:
                print(f"無法執行命令: {e.output}")
    
    
        print('')
        check_php_version()
        print('')
        check_proc_open()
        print('')
        check_php_extension('redis')
        print('')
        check_php_extension('fileinfo')
        print('')
        check_php_extension('swoole')
        print('')
        check_php_extension('swoole_loader', '3.0.\d+')
        print('')
        check_mysql_version()
        print('')
        check_web_server()
        print('')
        print('---------------------------------------------------------------------------------')
        print('')
        print("\033[33m注:請確定當前PHP命令行版本與你安裝的PHP版本一致\033[0m")
        print("\033[33m注:如果你確定以上擴展已經安裝并配置,請重啟php、必要時重啟服務器\033[0m")
        print("\033[33m本腳本為愛發電\033[0m")
        print("\033[33mby:網前雨刮器\033[0m")
        
    check_php_environment()
    

    如果您不會使用python 不會配置python環境,可以使用我已經打包好的程序

    使用方法如下:

    將程序放在服務器下,直接“./文件名” 運行即可。

    982b9202311271116187887.png

    附件

    php_detection.zip

    請登錄后查看

    聆聽 最后編輯于2023-11-28 09:13:19

    快捷回復
    回復
    回復
    回復({{post_count}}) {{!is_user ? '我的回復' :'全部回復'}}
    排序 默認正序 回復倒序 點贊倒序

    {{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level }}

    作者 管理員 企業

    {{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推薦': '推薦'}}
    {{item.is_suggest == 1? '取消推薦': '推薦'}}
    沙發 板凳 地板 {{item.floor}}#
    {{item.user_info.title || '暫無簡介'}}
    附件

    {{itemf.name}}

    {{item.created_at}}  {{item.ip_address}}
    打賞
    已打賞¥{{item.reward_price}}
    {{item.like_count}}
    {{item.showReply ? '取消回復' : '回復'}}
    刪除
    回復
    回復

    {{itemc.user_info.nickname}}

    {{itemc.user_name}}

    回復 {{itemc.comment_user_info.nickname}}

    附件

    {{itemf.name}}

    {{itemc.created_at}}
    打賞
    已打賞¥{{itemc.reward_price}}
    {{itemc.like_count}}
    {{itemc.showReply ? '取消回復' : '回復'}}
    刪除
    回復
    回復
    查看更多
    打賞
    已打賞¥{{reward_price}}
    3361
    {{like_count}}
    {{collect_count}}
    添加回復 ({{post_count}})

    相關推薦

    快速安全登錄

    使用微信掃碼登錄
    {{item.label}} 加精
    {{item.label}} {{item.label}} 板塊推薦 常見問題 產品動態 精選推薦 首頁頭條 首頁動態 首頁推薦
    取 消 確 定
    回復
    回復
    問題:
    問題自動獲取的帖子內容,不準確時需要手動修改. [獲取答案]
    答案:
    提交
    bug 需求 取 消 確 定
    打賞金額
    當前余額:¥{{rewardUserInfo.reward_price}}
    {{item.price}}元
    請輸入 0.1-{{reward_max_price}} 范圍內的數值
    打賞成功
    ¥{{price}}
    完成 確認打賞

    微信登錄/注冊

    切換手機號登錄

    {{ bind_phone ? '綁定手機' : '手機登錄'}}

    {{codeText}}
    切換微信登錄/注冊
    暫不綁定
    亚洲欧美字幕
    CRMEB客服

    CRMEB咨詢熱線 咨詢熱線

    400-8888-794

    微信掃碼咨詢

    CRMEB開源商城下載 源碼下載 CRMEB幫助文檔 幫助文檔
    返回頂部 返回頂部
    CRMEB客服