In MacOSX there is a default Apache + PHP server.
When you type the php
command in Terminal, the PHP version used is the one shipped with the MacOSX.
But, if you install MAMP, then what you want is that the version used is the one shipped with MAMP.
So, let’s make Terminal aware of the existence of the MAMP’s PHP binaries and use them instead of the ones shipped with MacOSX.
STEP 1: Verify which PHP is used by your Terminal
To verify which PHP is your Terminal using, open it and type:
$ which php
/usr/bin/php
Make another try:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
As you can see, the PHP binaries are in /usr/bin/php
and this path is also printed by the echo $PATH
command.
And, ever as you can see, the MAMP’s folders don’t are showed. We have to add them to $PATH
.
STEP 2: Add MAMP’s PHP binaries to $PATH variable
To make Terminal aware of the existence of the MAMP’s PHP binaries and make it use them, you have to modify the $PATH
variable modifying the file ~/.bash_profile
located in your root user folder (~
stands for root and you can type it using “Option + 5”). Use VIM to open it in your Terminal (you’ll have to type in your admin password):
sudo vi ~/.bash_profile
Password: •
If you cannot edit the file, enter the Edit mode
simply typing a
.
Write in the file the $PATH
variable that Terminal has to use (keep attention to the version MAMP is currently running checking your MAMP’s preferences!):
PATH=/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.6.6/bin:$PATH
Then, save the file, so FIRST press Esc
on your keyboard to quit the edit mode
and fallback to command line mode
, then type:
:wp
A short hand could be to press SHIFT
and the letter Z
for two times.
STEP 3: Load the .bash_file
and check all went good
Now it’s time to load the new .bash_profile
file. Type:
$ source ~/.bash_profile
Finally, check that all went good and that the configuration is right:
$ which php
/Applications/MAMP/bin/php/php5.6.6/bin/php
$ echo $PATH
/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php/php5.6.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Now the path to MAMP’s PHP binaries is set and used before all others by you system.
Remember to “Make. Ideas. Happen.”.
I wish you flocking users, see you soon!
L'articolo How to make Terminal use MAMP’s PHP (in only 3 steps) proviene da ÐΞV Experiences by Serendipity HQ.
Top comments (0)