Another Mac Setup

Feb 15, 2014

I am not a command line expert. Really, the only time I use the command line is for Drush and Git. I used to dread the initial setup, something always was different than the myriad of blogs suggested. This time is was different. Here is my story, it might help others who are faced with the same endeavor.

Git

First the easy part, installing Git. Download Xcode from the App Store. Git comes bundled with it and after the download/auto-install of Xcode, Git is available on the command line. Type in:

which git

will get you:

/usr/bin/git

MAMP

I use MAMP Pro. The pro version makes life easy. You can switch between different php versions, manage virtual hosts and more, all in the MAMP Pro main window. No command line involved.

After you have downloaded and installed MAMP Pro you need to make some adjustments to the PHP and MySQL settings. With MAMP Pro open go to File > Edit Template > PHP > your_php_version.  Find the Resource Limits section and adjust the limits to your needs. I always increase the memory limit and the max execution time so my settings end up like this:

;;;;;;;;;;;;;;;;;; ; ; Resource Limits ; ; ;;;;;;;;;;;;;;;;;; 
max_execution_time = 60 ; Maximum execution time of each script, in seconds 
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data 
memory_limit = 512M ; Maximum amount of memory a script may consume (8MB)

Next go to File > Edit Template > MySQL my.cnf. I normally increase the maximum allowed packet size to 100M as recommended on drupal.org.

max_allowed_packet = 100M

That takes care of the internal settings. Now we have to insure that our projects use MAMPs PHP and not the internal Mac version. Test what php version is being used with the which command on the command line. which php will result in /usr/bin/php

That is the internal Mac version. We want to use the MAMP version, in my case I use php5.3.27. We have to provide the path to the MAMP PHP to the system. We do that by adding the path to the .bash_profile file. When you do this install on a new Mac, this file will probably not exist so create one in your home directory. I use TextWrangler for these things as it allows you to see hidden files and .bash_profile is a hidden file as its name starts with a dot. Add this line to the file:

export PATH=/Applications/MAMP/bin/php/php5.3.27/bin:$PATH

and then save it as .bash_profile into your home directory. Now restart Apache in the MAMP main window. That will reload the .bash_profile file.

Now

which php

will result in:

/Applications/MAMP/bin/php/php5.3.27/bin/php

That is it for MAMP Pro. On to Drush

Drush

There are a couple of things that are different from the last time I installed Drush. Drush now lives on GitHub and it requires Composer. The process is fairly well described at these two sources:

  • https://getcomposer.org/doc/00-intro.md
  • https://github.com/drush-ops/drush

For completeness, here is what I did:

In the directory usr/local/bin I installed composer as suggested on the composer home page:

sudo curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer

then I installed Drush with:

composer global require drush/drush:6.*

This created a directory .composer in my home directory with Drush being in the vendor folder like so:

~/.composer/vendor/drush/drush/drush

Yes, that is right, three Drush in a row…

And lastly I used TextWrangler one more time and added the path to the Drush executable to the .bash_profile file so now it looks like this:

export PATH=/Applications/MAMP/bin/php/php5.3.27/bin:$HOME/.composer/vendor/bin:$PATH

One last step:

When I started to use this setup I got memory errors. I used the Drush status command and got this info:

PHP executable : /Applications/MAMP/bin/php/php5.3.27/bin/php 
PHP configuration : /Applications/MAMP/bin/php/php5.3.27/conf/php.ini 
PHP OS : Darwin Drush version : 6.2.0

I opened /Applications/MAMP/bin/php/php5.3.27/conf/php.ini and increases the memory limit to 256M and all was well.

Restart Apache one more time in the MAMP Pro main window and you are done.

Comments

For the MAMP section, you said: 'We want to use the MAMP version, in my case I use php5.3.27.' but you set your PATH to use php5.5.3

Thanks Raj, I fixed it.

Thanks... I was totally having my mind blown by installing composer.

Add new comment