Magento is a web-based application, and therefore Magento development is thankfully not limited to any particular platform or operating system. As a Mac user I prefer to do my Magento development on my Mac. In setting up my development environment, I discovered that there are very few useful resources out there for other developers looking to do the same. So hopefully this post will serve as a start for others looking to do the same.

Even though OS X comes with Apache and PHP, both of those tend to be a little out of date and it is generally easier to just install a MAMP (http://en.wikipedia.org/wiki/MAMP) rather than individually setting up PHP and MySQL. The MAMP package that I have been using can be found here: http://www.mamp.info (download link).

I found the following benefits in using this particular MAMP package:

  • easy to install and set up
  • no system files are changed
  • easy to delete since everything is in one directory
  • easy to start/stop the Apache and MySQL servers
  • meets all Magento pre-requisites
  • comes with a couple of PHP caching extensions pre-installed
  • phpmyadmin is pre-installed

To install, you should simply extract the zip file into the Applications directory. Please note that in order for this MAMP stack to work, it must be located in the Application directory. Once installed, opening the file called 'MAMP' in the MAMP directory will bring up a Preferences Panel.

There you can change the preferences associated with the running of the MAMP package. It also comes with a widget, which allows for quick starting and stopping of Apache and MySQL. By default, Apache runs on port 8888 and MySQL on port 8889. You can change the ports at any time under Preferences > Ports.

Before you can install a local copy of Magento, you will need to setup a database. Fortunately, this MAMP package comes with phpmyadmin pre-installed, which makes that task very simple. To get to phpmyadmin, click 'Open start page' either on the widget or in the Preferences Panel. That will take you to this page:

which you can also reach by entering the following url: http://localhost:8888/MAMP/. However, the apache server must be running in order to do this, so make sure you click 'Start servers' first.

To create a database for Magento follow these steps:

On the phpmyadmin start page click 'Privileges'.
Click 'Add a new User'
Fill in the following:
User name:'Use text field:' magento
Host: 'Local' localhost
Password: 'Use text field:' -enter your password-
Re-type: -enter your password-
Under 'Database for user' 
select 'Generate database with same name and grant all privileges'
Click 'Go'

Once you have created a database, you need to download Magento. Extract the Magento zip file into the following directory:

/Applications/MAMP/htdocs/

If you want to use another directory you can set a different 'Document Root' in the Preferences Panel. To install Magento open http://localhost:8888/magento, provided that you are still using the default '8888' port. Just follow the instructions provided by the installation script to complete the installation. When you are entering the database information make sure that you change 'localhost' to 'localhost:8888' or whatever port number you are using. Also enter the database name, mysql user and the mysql user password, all of which you would have created in the phpmyadmin steps above.

Once the installation is completed you will be able to load your local copy of Magento with the following url: http://127.0.0.1:8888/magento. Note that when it comes to Magento it is important to use '127.0.0.1' instead of 'localhost' when accessing via a browser, since otherwise the Magento admin panel may not load.

You should now be all set to start developing for Magento on your Mac.