How do I upgrade PHP in Mac OS X?

前端 未结 13 777
暖寄归人
暖寄归人 2020-12-12 13:34

I feel this is an awfully obtuse question to ask, but strangely, this problem is poorly documented.

I would like to upgrade PHP, but there are several problems:

相关标签:
13条回答
  • 2020-12-12 14:07

    I think one simple way to do it, is:

    1 - Check you where is your current PHP:

    $ which php
    $ /usr/local/bin/php
    

    You see? Usually, our commands that we run is a link in /usr/local/bin so...

    2 - Unlink this current link of PHP

    unlink /usr/local/bin/php
    

    If you prefere, before unlink it, check the path and then remove php files (do ls -al /usr/local/bin | grep php and then rm -rf into desired path)

    3 - Install PHP 7.1

    curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
    

    4 - Create new link (using php 7.1 bin that you have installed)

    ln /usr/local/php5-7.1.9-20170914-100859/bin/php /usr/local/bin/php
    

    Like I said, its a simple way I think.

    0 讨论(0)
  • 2020-12-12 14:07

    Saving on keystrokes, this worked on MacOS Sierra:

    $ brew install homebrew/php/php71
    
    $ /usr/local/opt/php71/bin/php -v
    PHP 7.1.4 (cli) (built: Apr 14 2017 15:02:16) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    
    0 讨论(0)
  • 2020-12-12 14:08

    You may want to check out Marc Liyanage's PHP package. It comes in a nice Mac OS X installer package that you can double-click. He keeps it pretty up to date.

    http://php-osx.liip.ch/

    Also, although upgrading to Snow Leopard won't help you do PHP updates in the future, it will probably give you a newer version of PHP. I'm running OS X 10.6.2 and it has PHP 5.3.0.

    0 讨论(0)
  • 2020-12-12 14:08

    Check your current php version in terminal with the following command,

    $ php -v
    

    You see current php version in terminal, and next command run in terminal if you want to upgrade your php version with php concat with version liked as,

    $ brew install homebrew/php/php71
    

    Please restart terminal if you finished php version upgrade installed and run the command.

    $ php -v
    

    Now you see the current php version in terminal....thank

    0 讨论(0)
  • 2020-12-12 14:08

    Use this Command:

    curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0
    
    0 讨论(0)
  • 2020-12-12 14:08

    to upgrade php7 to latest stable version brew upgrade php7 or for php5.X to latest stable version

    brew upgrade php56
    

    use brew list to check installed version

    0 讨论(0)
提交回复
热议问题