How do I upgrade PHP in Mac OS X?

前端 未结 13 776
暖寄归人
暖寄归人 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 13:47

    You can use curl to update php version.

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

    Last Step:

    export PATH=/usr/local/php5/bin:$PATH
    

    Check the upgraded version

    php -v
    
    0 讨论(0)
  • 2020-12-12 13:57

    best way to upgrade is compile it from source

    see this tutorial that may be helful for you

    http://www.computersnyou.com/2012/09/how-to-upgrade-php-in-mac-osx-compiling.html

    0 讨论(0)
  • 2020-12-12 13:58

    Upgrading to Snow Leopard won't solve the your primary problem of keeping PHP up to date. Apple doesn't always keep the third party software that it bundles up to date with OS updates. And relying on Apple to get you the bug fix / security update you need is asking for trouble.

    Additionally, I would recommend installing through MacPorts (and doing the config necessary to use it instead of Apple's PHP) rather than try to upgrade the Apple supplied PHP in place. Anything you do to /usr/bin risks being overwritten by some future Apple update.

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

    There is no built-in package manager. MacPorts doesn't recognize php as an installed package because it didn't install PHP itself.

    You could still install it with MacPorts. sudo port install php52 (or whichever version you want) will install PHP.

    It won't overwrite the Apple-supplied version. It'll install it under /opt/local. You can add /opt/local to the beginning of your $PATH, and use the MacPorts version in your Apache config.

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

    I use this: https://github.com/Homebrew/homebrew-php

    The command is:

    $ xcode-select --install
    
    $ brew tap homebrew/dupes
    $ brew tap homebrew/versions
    $ brew tap homebrew/homebrew-php
    
    $ brew options php56
    $ brew install php56
    

    Then config in your .bash_profile or .bashrc

    # Homebrew PHP CLI
    export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
    
    0 讨论(0)
  • 2020-12-12 14:03

    Option #1

    As recommended here, this site provides a convenient, up-to-date one liner.

    This doesn't overwrite the base version of PHP on your system, but instead installs it cleanly in /usr/local/php5.

    Option #2

    My preferred method is to just install via Homebrew.

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