dsa2c2255888 2017-08-04 03:32
浏览 185

如何在MAC OS中将PHP一个版本切换到另一个版本?

I have installed php7.1 using homebrew in mac. But when i try php -version it shows 5.5. How can I switch version. I could not find my php instalation directory for php7.1 to set the path at bash_profile.

#brew install php71
Warning: homebrew/php/php71 7.1.7_19 is already installed

#php --version
PHP 5.5.30 (cli) (built: Oct 23 2015 17:21:45) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

Edit

I see my php installtion directory is under /usr/local/etc/php/7.1 But it contains only php.ini and pear.conf files.

I tried

export PATH="$(brew --prefix homebrew/php/php71)/bin:$PATH" But it didn't change my php version.( i tried php --version, still shows 5.5)

  • 写回答

1条回答

  • dpkiubcc265650 2017-08-04 12:24
    关注

    I had the same issue, this guide helped me upgrade:

    Make sure brew is up to date:

    brew update
    brew upgrade
    

    (I kinda helped make that update happen! Woo!)

    If you’re not already running php7 then you may need:

    brew tap homebrew/dupes
    brew tap homebrew/versions
    brew tap homebrew/homebrew-php
    

    And then the complicated part:

    brew unlink php70 # or  brew unlink php55
    brew install php71
    

    And the result?

    $ php --version
    PHP 7.1.0 (cli) (built: Dec  2 2016 03:30:24) ( NTS )
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
    

    Woohoo!

    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?