24 Jan

How to use MAMP’s version of PHP instead of the default on OSX

If you are trying to setup php development environment in OSX then there are two choices. One is to use the default php that comes with OSX  and install mysql and apache separately and other is to install MAMP which comes bundled with php, apache and Mysql. So, if you are going for MAMP then you need to make some changes in order to use MAMP’s version of php than the default one. Here is step to step guide to do that:
Once you download MAMP and install it, open terminal and type the following command

you will see the path of php that is being used currently i.e usr/bin/php

Now you need to tell the system to use MAMP’s version of php which is located at /Applications/MAMP/bin/php/

MAMP's php location
Now you need to add a snippet to the profile file located at root. Use the following commands, open profile file

export php path to be used for MAMP. Here you need to specify which version of php you want to use, so specify the php version accordingly.

Save the file by pressing Esc then type :wq and press enter and then type

This should change the php version from default one to MAMP’s. Type the following command to confirm.

if you have done everything right then you should see output /Applications/MAMP/bin/php/php5.5.10/bin/php

Thats it, now you are using MAMP’s version of php instead of default one.

Also, if you installed MAMP there might be a situation that your apache won’t start. No need to worry, there is an easy solution for that, just read this blog post:  MAMP apache not starting

Hope you found this blog helpful. For more useful posts don’t forget to follow me and if you have any questions then do let me know.

The following two tabs change content below.

Vineet Garg

Sr. Web Developer at GuestHouser
I am passionate about technology and web development.

Latest posts by Vineet Garg (see all)