美文网首页
mac升级后PHP失败报错Error: php@7.3 has

mac升级后PHP失败报错Error: php@7.3 has

作者: 张清柏 | 来源:发表于2021-12-24 14:25 被阅读0次
    • 各种补救方法皆不可用,开始卸载重装
    # 查看服务列表
    brew services list
    #卸载
    brew uninstall php@7.3
    #删除配置目录
     rm -rf /usr/local/etc/php/7.3
    # 恢复brew
    brew doctor
    # 重新安装
    brew install php@7.4
    
    • 如果过程中有包下载不下来可以更换源或者开启代理
      打开代理
    export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;
    
    
    • 终端关闭代理
    unset http_proxy
    unset https_proxy
    
    
    • 安装完毕后的配置信息
    ==> php@7.4
    To enable PHP in Apache add the following to httpd.conf and restart Apache:
        LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so
    
        <FilesMatch \.php$>
            SetHandler application/x-httpd-php
        </FilesMatch>
    
    Finally, check DirectoryIndex includes index.php
        DirectoryIndex index.php index.html
    
    The php.ini and php-fpm.ini file can be found in:
        /usr/local/etc/php/7.4/
    
    php@7.4 is keg-only, which means it was not symlinked into /usr/local,
    because this is an alternate version of another formula.
    
    
    To restart php@7.4 after an upgrade:
      brew services restart php@7.4
    Or, if you don't want/need a background service you can just run:
      /usr/local/opt/php@7.4/sbin/php-fpm --nodaemonize
    
    • 添加到环境变量中去,变量文件可以在下面文件中添加
      a. /etc/profile
      b. /etc/paths
      c. ~/.bash_profile
      d. ~/.bash_login
      e. ~/.profile
      f. ~/.bashrc

    • 添加完毕,更新文件,让环境变量生效并查看是否生效

    zhangguofu@zhangguofudeMacBook-Pro ~ $ vi ~/.bash_profile 
    zhangguofu@zhangguofudeMacBook-Pro ~ $ source ./.bash_profile
    zhangguofu@zhangguofudeMacBook-Pro ~ $ echo $PATH
    
    • 执行php -v
    zhangguofu@zhangguofudeMacBook-Pro ~ $ php -v
    -bash: php: command not found # 呃,没有找到这个文件,我们看看有没有这个目录吧
    zhangguofu@zhangguofudeMacBook-Pro php@7.4 $ cd /usr/local/opt/
    zhangguofu@zhangguofudeMacBook-Pro php@7.4 $ ls -al
    lrwxr-xr-x    1 zhangguofu  admin    24 Dec 24 14:25 php@7.4 -> ../Cellar/php@7.4/7.4.27 # 发现是一个软连接
    # 进入真实文件路径查看文件
    zhangguofu@zhangguofudeMacBook-Pro opt $ cd ../Cellar/php@7.4/      
    zhangguofu@zhangguofudeMacBook-Pro php@7.4 $ ls
    7.4.27.reinstall
    # 发现文件名不是7.4.27 修改文件名
    zhangguofu@zhangguofudeMacBook-Pro php@7.4 $ mv 7.4.27.reinstall 7.4.27
    zhangguofu@zhangguofudeMacBook-Pro php@7.4 $ php -v
    PHP 7.4.27 (cli) (built: Dec 16 2021 18:14:46) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies
    
    • 安装完毕

    相关文章

      网友评论

          本文标题:mac升级后PHP失败报错Error: php@7.3 has

          本文链接:https://www.haomeiwen.com/subject/ycblqrtx.html