Table of Contents
- 1.See Also
- 2.Create Your Sandbox
- 3.Installing MAMP
- 4.Installing MacPorts
- 5.Developer Tools
Installing Drupal on MAMP
- Creating Your Sandbox -- Start Here!
- Sandbox Tools
- Modern alternative: LAMP stack with Homebrew (or google: "homebrew lamp stack")
Create Your Sandbox
See Creating Your Sandbox for step-by-step instructions on creating and using the multi-ste, shared core directory structure and layout recommended by CivicActions' Best Practices and assumed by our documentaion and Sandbox Tools.
Mac OS X comes with an Apache process running. To turn this off (necessary to run MAMP) go to System Preferences >> Sharing and unclick Web Sharing. Then download and install MAMP from http://www.mamp.info/
IMPORTANT: Make sure you have no other Apache (httpd) nor MySQL (mysql) processes running first!
Start MAMP and choose "Preferences".
- Under "Start/Stop..." uncheck "Check for MAMP PRO"
- Under "PORTS" click on "Set to default Apache and MySQL ports"
- Under "Apache" set the Document Root to "/Users/YOURNAME/workspace"
CivicActions MAMP Configuration
- Don't forget: once you have created your Apache configuration files, be sure that you inform Apache of their existance.
- Make a link to the logs/ directory (useful for debugging - and similar to standard VHost configuration):
cd ln -s /Applications/MAMP/logs
- Add this (see notes below) to the end of your ~/.bash_profile file (create this file if it does not exist):
PATH=$HOME/bin:/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3.6/bin:$PATH export PATHNotes:
- As of this writing, Drupal and CiviCRM work better with PHP 5.3 but they may still work with PHP 5.2. We recommend using PHP 5.3 unless you have some good reason not to.
- The path /Applications/MAMP/bin/php5.3.6/bin may vary with specific versions of MAMP - check the location of your PHP bin directory and use that.
- ...and restart any Terminal session you may have running
Edit /Applications/MAMP/conf/php5.3/php.ini to raise the default memory_limit:
memory_limit = 128M
You may also want to increase (by an order of magnitude or more) max_execution_time and max_input_time as well as post_max_size and upload_max_filesize. See PHP and MySQL Configuration Files for more details.
MySQL: Create and Update my.cnf
- Stop MAMP and create a my.cnf file for setting default MySQL configurations. We recommend starting with the "large" version:
cp /Applications/MAMP/Library/share/mysql/my-large.cnf /Applications/MAMP/db/mysql/my.cnf
- Then edit the my.cnf file and set max_allowed_packet = 16M - the default of 1M is too small for most Drupal sites
- See PHP and MySQL Configuration Files for more details.
MacPorts is an alternative to MAMP and may be a useful alternative for some people. (Fen has been using MacPorts since 2010 and likes it, though he admits it was a bit more work to install than the turnkey MAMP.)
Instructions for installation are at http://www.macports.org/install.php.
Installing Apache MySQL and PHP with MacPorts
To install, see: Getting Apache, MySQL, and PHP Running under MacPorts
git svn installation
If when you run git svn ... and get the error "Can't locate SVN/Core.pm" then try this:
sudo port install git-core +svn
This should work even if you have SVN and/or Git installed by other means/
For many operations (including the installation of wget and/or DBD::mysql) you'll need the "XCode" Mac Developer Tools. They're usually found on the second Apple OSX install disk, or can also be downloaded from the Apple Developer Connection (where you'll get a more up-to-date copy - free membership required).
These two tools are useful: http://dev.mysql.com/downloads/gui-tools/5.0.html
Pulling files/ and Database dumps from Dev/Qa/Live Instances
Use sync.sh (or syncdb.sh, syncfiles.sh & pushdb) to get the files and database, see Sandbox Tools
Pushdb and DBD::mysql
Important update: Pushdb is no longer required for the sandbox tools to work. While it is still handy for some tasks, sync.sh now uses cleanup.sh to update the database pulled from a vhost for sandbox use. So it is safe to skip installing DBD::mysql and the only lost functionality will be the --backup and --zDrop functions that can be manually run as shown below:
# pushdb --backup dbname mysqldump dbname | gzip -c > ~/nobackup/dbname-YYYYMMDD-HHMM.sql.gz # pushdb --zDrop dbname mysql -e "DROP DATABASE dbname; CREATE DATABASE dbname
Macs for some reason don't come with DBD::mysql - required by pushdb - installed, and it's not trivial to add, but here are the steps (tested on Leopard; doesn't seem to work on Snow Leopard):
- First you need the "XCode" Mac Developer Tools.
- Download and install the 32-bin MySQL binary Package needed for linking the Perl package (even though you'll continue to use MAMP) from mysql.com
- Unzip the package and move it under /usr/local
tar zxf mysql-5.1.30-osx10.4-x86,tar.gz sudo mv mysql-5.1.30-osx10.4-x86 /usr/local cd /usr/local sudo ln -s mysql-5.1.30-osx10.4-x86 mysql
- Create these symlinks:
sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql sudo mkdir /Applications/MAMP/Library/include sudo ln -s /usr/local/mysql/include /Applications/MAMP/Library/include/mysql
- Note: If you're not using MAMP you may have to download the mysql source to get the needed include files and the second symlink would go to the appropriate place n the source. To make matters worse (!!) if the downloaded source version isn't the same as the mysql binary you're running, you may run into additional problems - compiling the source locally and switching to using that may be the best solution. For more hints, see http://www.nntp.perl.org/group/perl.macosx/2008/01/msg10568.html
- Start cpan (the installer provided by the Comprehensive Perl Archive Network) and install the DBD::mysql bundle:
sudo cpan .... when CPAN asks "are you ready for manual configuration [yes]" BE SURE TO ANSWER "no" .... .... lots of setup the first time .... .... if it can't find some tools - like lynx - no worries, ignore it .... cpan> install Bundle::DBD::mysql .... answer yes to questions regarding installing other packages .... cpan> quit
- If cpan tests fail because it can't connect to the database, do:
cpan> o conf makepl_arg "--testuser=root --testpass=root123"
Drush for Multisite
- Command line MySQL looks for /tmp/mysql.sock so you'll need this link:
ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
- Unfortunately, you'll have to re-create this link every time you reboot your machine, as rebooting clears all files and links from /tmp
- Consider adding an alias to your .bashrc or .bash_profile like:
alias fixmamp='ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock'
- To install WGET you will need to have the "XCode" Mac Developer Tools installed.
- Once you have XCode Tools installed, you have two options:
- install fink, then go to command line: fink install wget
- Download and compile wget yourself: Follow these instructions OR these easy instructions except for the last part about the "man page": instead of editing man.conf (actually in /etc on my Leopard install) create a sym link like this:
sudo ln -s /usr/local/man/man1/wget.1 /usr/share/man/man1
While the "terminal" app that comes with Mac OSX is pretty good, for enhanced functionality, download and install iTerm2. It will happily coexist with the terminal.app so you can easily switch between the two. Highly recommended!