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!

    评论

报告相同问题?

悬赏问题

  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题