Mac upgraded PHP to 5.6, but CLI php -v get 5.3.28?

前端 未结 4 1664
太阳男子
太阳男子 2020-12-17 00:26

I have installed MAMP (comes with PHP 5.5) on my machine. And localhost pointed to /Applications/MAMP/htdocs. The problem happened when I was trying to use composer in termi

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 01:08

    Thanks for the help.

    It is due to the order in $PATH, like Marc and jkj posted in the comments above.

    I can't find a way to re-order the $PATH (did some research but failed to find an easy way), but I am able to fix this by simply removing the Apahce2 previously installed following this post:

    https://apple.stackexchange.com/questions/41143/how-to-revert-default-mac-apache-install-to-original

    update 9/9/2014: after some research, the following procedure would make PHP version setting system wide.

    The procedure comes from this source, please look for the comments down below that page and find user Amtriorix.

    I am just copy/paste his solution here:

      The php-cli version is still the Apple version if You do not change it. Your php on apache can be different as the cli version, including used modules ! So beware.
        As Brian Wynn did mention, of course You can modify Your PATH settings to write into your ~/.profile file the following
        export PATH=/usr/local/php5/bin:$PATH
        Most likely a better approach is to make the setting system wide.
        You should symlink to the right php executable.
        So:
        #cd /usr/bin
        #mv php php.org
        #ln -s /usr/local/php5/bin/php
        test if it works:
        #php -v && php -m && php --ini
        --> should be php-osx version with related modules...
    

提交回复
热议问题