美文网首页PHP程序员
ubuntu 中,同时安装了多个php时,切换如何切换cli模式

ubuntu 中,同时安装了多个php时,切换如何切换cli模式

作者: php转go | 来源:发表于2020-09-19 17:29 被阅读0次

    安装了多个php时,通过cli模式遇到版本太低,执行失败的情况,需要切换php版本
    查看当前PHP版本

    root@iZbp13qbzm5fmvq3cmegygZ:# php -v
    
    PHP 5.6.39-1+ubuntu14.04.1+deb.sury.org+1 (cli) 
    
    Copyright (c) 1997-2016 The PHP Group
    
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    
        with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
    

    php5.6已经算比较低的版本了,需要切换到高版本

    方法1,选择默认版本

    进入多版本页面,现在

    root@iZbp13qbzm5fmvq3cmegygZ:# update-alternatives --config php
    
    There are 3 choices for the alternative php (providing /usr/bin/php).
     Selection    Path             Priority   Status
    
    ------------------------------------------------------------
    
     0            /usr/bin/php7.2   72        auto mode
    
     1            /usr/bin/php5     50        manual mode
    
    * 2            /usr/bin/php5.6   56        manual mode
    
     3            /usr/bin/php7.2   72        manual mode
    Press enter to keep the current choice[*], or type selection number: 3 #选择7.2版本,enter
    

    方法2,通过update-alternatives --set来设置默认版本

    sudo update-alternatives --set php /usr/bin/php5.6
    

    相关文章

      网友评论

        本文标题:ubuntu 中,同时安装了多个php时,切换如何切换cli模式

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