To install Magento 2 on MAMP takes a bit more effort than you’re regular WordPress installation. This is mostly because Magento 2 needs a newer MySQL and PHP version, and you’ll need your Terminal!
1. Install MAMP
Download MAMP and install it.
2. Set correct PHP version
Magento 2 will run on 5.6 and newer. PHP 7 is supported by MAMP out of the box and can significantly improves performance, so unless you have some other reason for it I’d recommend to use PHP7. To do so, open MAMP and set PHP to 7.0.0. in the preferences.
3. Update MySQL
Magento 2 requires MySQL 5.6, which has been on the market for years, but 5.5 is still the standard and so is usually bundled with MAMP. They do offer an easy way to upgrade it. Download the script and unzip it. Double-click it to run it via Terminal, you will need to input your password for the changes. If you haven’t made any changes to the MAMP/MySQL config before, this should do it. Stop-and-start your MAMP server and your MySQL is updated.
4. To Github!
The next step is to install GIT on your local machine, so you can copy the latest Magento branche from Github to your local machine and install it via Composer.
So sign up for a Github account if you haven’t and enter your SSH Key. An easy way to get your correct SSH key to the clipboard is running this command from terminal:
pbcopy < ~/.ssh/id_rsa.pub. If you haven't generated a key before or are unclear on this part, read this.
When you added your key to Github you can now pull in the Magento branche to your local machine. Navigate via Terminal to your htdocs like so
cd /Applications/MAMP/htdocs/ and clone the repository like so
git clone email@example.com:magento/magento2.git. You might want or need to add Github to your list of known hosts with
ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts.
5. Install Composer and Magento
At this point you'll have the Magento repository in your localhost, but it needs to be installed via Composer. To install Composer run
curl -sS https://getcomposer.org/installer | php. To make Composer available everywhere by just typing
composer in Terminal, move it to your local bin with
sudo mv composer.phar /usr/local/bin/ and edit your bash profile with
sudo nano ~/.bash_profile. Simply add this line and save it:
alias composer="php /usr/local/bin/composer.phar". You'll have to restart Terminal to apply the changes.
If you try to install Magento now, you'll probably get error messages about missing PHP modules (ext-mcrypt and ext-intl). If this is the case your machine still uses the built-in OSX PHP version, and not the MAMP one. We can fix this easily. In Terminal type
which php to check which PHP version is used. The default OSX option would be
/usr/bin/php. We'll need to change this to /Applications/MAMP/bin/php/php7.0.0/bin (or php5.6.0 if you want). To do so, again edit .bash_profile with
sudo nano ~/.bash_profile and add this line
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH, then run
source ~/.bash_profile. If all is well, run the
which php command again and you should see the new path.
So with the proper PHP version, we can install Magento. In Terminal navigate to your htdocs and run
composer install to (finally) install Magento 2.
6. Add a database and install
In MAMP via Terminal or via the interface of MySQL, create a database and note the user and password for it. The next step is to install Magento, you can do this via the webinterface (just open the URL in your browser), or via Terminal.
Pro-tip: Magento 2 has a very nice CLI you can use from the /bin/ directory via Terminal. To use it from anywhere, again edit your .bash_profile and add
PATH=$PATH:./bin on a new line. Restart Terminal and you can use it from anywhere.
7. The Aftermath
The final step is the configuration etc, about which you can find info here. The most I did was run these commands to set the right ownership:
In my git clone the .htaccess was missing, so I added this myself in the root:
And how I set the crons:
Setting up cron for Magento2 on MAMP