change the PHP path to MAMPs PHP

后端 未结 6 845
野的像风
野的像风 2020-12-05 08:38

I\'m running PHP with MAMP on OSX 10.5.8

So if I want to run a script from console I always need to write

/applications/mamp/bin/php5.3/bin/php path/         


        
相关标签:
6条回答
  • 2020-12-05 09:18

    The easiest way would be to rewrite the alias. Just copy/paste the cmd bellow into terminal for temporary use or write it into .bash_profile to make it permanent.

    For MAMP

    $ alias php=/applications/mamp/bin/php5.3/bin/php
    

    For XAMPP

    $ alias php=/Applications/XAMPP/bin/php
    

    For AMPPS

    $ alias php=/Applications/AMPPS/php-5.6/bin/php
    

    Run php via our new alias

    $ php -v
    
    0 讨论(0)
  • 2020-12-05 09:26

    Create a file called .bash_profile on your home directory (if you don't have this file already), and add this to the file:

    export PATH=/Applications/mamp/bin/php5.3/bin:$PATH
    

    Then quit and relaunch Terminal.app

    0 讨论(0)
  • 2020-12-05 09:27

    In addition to bfvarettos great answer: since .bash_profile executes at login, you will need to restart your system for the changes to take effect.

    0 讨论(0)
  • 2020-12-05 09:28

    Use latest MAMP version of PHP

    you need to edit .bash_profile

    open -a TextEdit ~/.bash_profile
    

    if you cannot find bash_profile under your home directory then create .bash_profile:

     touch ~/.bash_profile
    

    Use latest MAMP version of PHP

    PHP_VERSION=`ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
    export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
    

    (Use source ~/.bash_profile after making your changes to make sure they take effect.)

    source: How to override the path of PHP to use the MAMP path?

    0 讨论(0)
  • 2020-12-05 09:29
    vi ~/.bash_profile
    
    //add
    export PATH=/path/to/php/bin:$PATH
    
    source ~/.bash_profile 
    
    0 讨论(0)
  • 2020-12-05 09:29

    I'm not sure if this is specific to MAMP 3.0 or not but you need to do the following path for MAMP 3.0. Make sure you change the PHP version to the version you are using for your server.

    Again this goes in ~/.bash_profile

    export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:$PATH
    
    0 讨论(0)
提交回复
热议问题