When I ran into problems running Drupal on my local install of OSX 10.5 / Leopard a few years ago, I turned to MAMP to save my sanity. MAMP is a simple all-in-one installer with Apache HTTP Server, MySQL and PHP for running PHP web apps on your Mac. It provides a really great way of getting a full *AMP stack running on your Mac, with many more PHP extensions than are normally installed on the built-in version of Apache, and it can easily be removed should you need to. It's also worth mentioning that one of MAMP's strongest features for running Drupal vs alternatives, e.g. Acquia's DAMP / Dev Desktop, is that it can run Apache on port 80, the normal HTTP port, which is great for beginners and experienced developers who hate having to type a port number in the URL to access their local websites.
I originally installed MAMP 1.9 and never updated it because, honestly, it worked, so why bother? On a normal day nobody from the outside world was going to be accessing my web server as my local network is firewalled, and the laptop itself has a firewall so that nobody can access it while I'm using an unsecured network, e.g. at a coffee shop. Thanks to finally having a Drupal 8 issue I really wanted to fix (#1067120) I finally had a reason to upgrade. Drupal 8 requires PHP v5.3.3 or newer, whereas MAMP 1.9 only had v5.3.2. So, time to upgrade.
When MAMP is installed it is required to be ran from /Applications/MAMP—there are lots of configuration files included that depend upon that path, so I'm sure it could be moved if you felt up for the task, or bored. All of the various command line tools, bundled PHP apps and databases are installed in subdirectories, so the normal Mac technique of "delete and replace" for updating the software will run into a major problem: the databases. While MAMP will make your websites automatically available from http://localhost/~myusername/, excluding any custom virtual hosts that are added, the databases are still all created in the /Applications/MAMP/db directory, so these need to be accounted for prior to upgrading.
The first thing I did when I tried upgrading was to copy the MAMP 1.9 databases into the MAMP 2.0 directory structure, but it didn't work, so I had to try another plan. My final process was a quick export of 1.9's databases and then to recreate & reload each one on 2.0; hopefully the following will help you make this upgrade too.
The first step is to export all of the existing databases. The simplest way I found was:
mysqldump -Q --add-drop-table -c --order-by-primary --extended-insert=FALSE --no-create-db=TRUE -uROOTUSER -pROOTPASSWD example > example.sql
mysqldump -Q --add-drop-table -c --order-by-primary --extended-insert=FALSE --no-create-db=TRUE -uROOTUSER -pROOTPASSWD joeschmoley > joeschmoley.sql
mysqldump -Q --add-drop-table -c --order-by-primary --extended-insert=FALSE --no-create-db=TRUE -uROOTUSER -pROOTPASSWD monkey > monkey.sql
The next step is to swap around the MAMP installs and tweak the configuration of MAMP v2 so the database dump files will be able to load.
Before you do any file shuffling, turn off MAMP 1.9 (hit the "Stop services" button) and then quit the MAMP application. Just to confirm it is fully disabled, try visiting one of your local development sites, it should say that the web server is unavailable. Once that is done, go to /Applications and rename the "MAMP" directory to e.g. "MAMP 1.9" as we'll need it later.
Install MAMP / MAMP Pro v2 as normal, which will go into /Applications/MAMP - exactly where the old version was. At this point I'd like to go on a tangent and wish you could choose where it's installed, but it's not usually *that* big of a deal. But, I digress. Once it's installed, start the MAMP control panel.
Now that MAMP is installed it needs to be configured so the database dump files can be loaded. The first think you'll want to do is change it to use PHP 5.3 (on the PHP settings tab), as Drupal (and contrib modules especially) isn't currently fully compatible with the default of PHP 5.4. Incidentally, it seems that you can only pick PHP 5.3 if you're using MAMP Pro, the basic MAMP only allows you to pick 5.2 or 5.4, so give the Pro version a trial run to make these changes.
While you're in the configuration tool you'll also want to turn on the APC caches, and on the General settings click the "Default Ports" button to change all three services (Apache, SSL and MySQL) to their respective default port (80, 443 and 3306) rather than the custom ones MAMP ships with. That said, just be aware that the system will validate account password when MAMP is started or stopped due to OSX's standard UNIX security practices - only the admin can run programs on ports lower than 1000, i.e. Apache HTTP server's use of ports 80 and 443.
At this point it's safe to hit the Apply button to save all changes, and it should also be possible to click the Start button to launch MAMP. Should any errors occur be sure to check the log files, tweak the settings and try again.
The next thing is to fix PHP so it uses more memory and has a higher execution timeout limit than the default. To do so, open the "php.ini" file for each version of PHP that's available, i.e. edit /Applications/MAMP/conf/php5.2.17/php.ini for PHP 5.2, etc. The following line(s) will need to be changed to the value(s) shown:
or even more if you have a lot of memory in your machine:
If you don't use Drush you'll also want to change "max_execution_time" to 60 or maybe even 180, just to be safe. Also, shame on you for not using Drush!
Make the above changes for each version of PHP installed (at the time of writing - 5.2.7, 5.3.14, 5.4.4), then stop & start MAMP again to ensure the settings have taken effect properly.
The final configuration step is to fix MySQL. Out of the box it has several problems - it doesn't listen to requests on the TCP/IP port, it has a limit on the query length that'll cause problems with Drupal's cache tables & others (the "max_allowed_packet" setting), and has some really low memory limits for InnoDB that need improving. I've attached a copy of the my.cnf file that I use (it's zipped, so just download it and extract if necessary to get the raw "my.cnf" file), which should be placed in /Applications/MAMP/conf. Again, restart MAMP for the settings to take effect.
With my databases I use the simple convention of having a user for each database, with the same name for each, and the password set to the same value too, e.g. the "example" database is accessible by a user "example" with the password "example". This keeps it super simple to remember what's what, avoids me storing my root password in multiple text files which would then be uploaded to a code repository for others to see, and makes it scriptable. Add to this another dash of regular expressions and the database setup becomes child's play, almost.
There is one thing to watch for when import the SQL file. There's honestly no need to import the data into Drupal's cache tables as they can be recompiled at runtime, so we'll tweak the import commands to ignore those lines.
Anyway, on with the show:
echo '$1';mysqladmin -uROOTUSER -pROOTPASSWD create $1 --default-character-set=utf8;mysql -uROOTUSER -pROOTPASSWD -e "CREATE USER '$1'@'localhost' IDENTIFIED BY '$1';GRANT ALL PRIVILEGES ON $1.* TO '$1'@'localhost'";grep -v "INSERT INTO \`cache" $1.sql | mysql -u$1 -p$1 $1;\n
echo 'example';mysqladmin -uROOTUSER -pROOTPASSWD create example --default-character-set=utf8;mysql -uROOTUSER -pROOTPASSWD -e "CREATE USER 'example'@'localhost' IDENTIFIED BY 'example';GRANT ALL PRIVILEGES ON example.* TO 'example'@'localhost'";grep -v "INSERT INTO \`cache" example.sql | mysql -uexample -pexample example;
echo 'joeschmoley';mysqladmin -uROOTUSER -pROOTPASSWD create joeschmoley --default-character-set=utf8;mysql -uROOTUSER -pROOTPASSWD -e "CREATE USER 'joeschmoley'@'localhost' IDENTIFIED BY 'joeschmoley';GRANT ALL PRIVILEGES ON joeschmoley.* TO 'joeschmoley'@'localhost'";grep -v "INSERT INTO \`cache" joeschmoley.sql | mysql -ujoeschmoley -pjoeschmoley joeschmoley;
echo 'monkey';mysqladmin -uROOTUSER -pROOTPASSWD create monkey --default-character-set=utf8;mysql -uROOTUSER -pROOTPASSWD -e "CREATE USER 'monkey'@'localhost' IDENTIFIED BY 'monkey';GRANT ALL PRIVILEGES ON monkey.* TO 'monkey'@'localhost'";grep -v "INSERT INTO \`cache" monkey.sql | mysql -umonkey -pmonkey monkey;
And that should be it! You now should be able to run all of your sites on MAMP 2 without any any problems.
There are a few other improvements that can be made to the MAMP installation. e.g.:
If you have suggestions on how to improve this, including other plugins/extensions that you find essential, or ways to further optimize the export/import process let me know!