Posted on

Command line Magento 1.5 install on MAMP

In my last big post on Magento deployment there were a number of simple little tidbits that on their own may be useful to people who might not be ready to jump headlong into the sort of project structure I described.

So with that in mind I thought I’d pull out the first of the useful tips, this time installing Magento 1.5 on MAMP (OSX) all via the command-line, it saves time and is nicely repeatable for scripting. Plus OSX is a unix system, why not make use of it!

In this little guide we’ll be installing Magento into your webserver’s document root. If that doesn’t mean anything to you, it may be worth checking out a couple of my earlier MAMP guides.

I wrote two related guides a while back that you may also find useful, for setting up MAMP based Magento development environments. Firstly a guide to installing MAMP on a Mac and secondly a way to set up virtual hosts on MAMP.

Update: Before we go any further, I included steps for downloading that use wget, which as Talesh quite rightly noted is not included with Mac OSX by default. I suggest you get wget on Mac OSX using Homebrew but there are other ways too.

Alternatively you can use curl to grab the file like this:

curl > magento-

Ok, so we’re ready to begin. These commands should be copy-pastable, if anything goes wrong let me know.

cd ~/Downloads
# If you do not have wget installed (see above) you can use curl.
tar xzf magento-
#This assumes your document root is ~/Documents/web
mv magento ~/Documents/web/magento/

Now we create the database, again we can do this on the commandline, to save time fluffing around with phpMyadmin.

# Your password is probably still 'root', unless you changed it.
/Applications/MAMP/Library/bin/mysql -uroot -p -e "create database magento1501"
# Put your own ulta secure password in place of 'password' below
/Applications/MAMP/Library/bin/mysql -uroot -p -e "grant all on magento1501.* to magento1501@'localhost' identified by 'password'"

Now we run the actual Magento install on the commandline. It pays to set the permissions before installing.

cd ~/Documents/web/magento/
chmod -R o+w media var
chmod o+w app/etc

This next command runs the actual install. There are several things you need to change to match. others are optional, for example timezone, currency and locale can all be changed later in the admin, but for a local development environment the defaults are probably fine. The admin email/username/password, database details and base url are all important. Screwing these up will render the install broken – happily it won’t take you long to re-run the above commands and start over if that happens, right?

/Applications/MAMP/bin/php5/bin/php -f install.php -- --license_agreement_accepted "yes" --locale "en_US" --timezone "America/Los_Angeles" --default_currency "USD" --db_host "localhost" --db_name "magento1501" --db_user "magento1501" --db_pass "password" --url "" --use_rewrites "yes" --use_secure "no" --secure_base_url "" --use_secure_admin "no" --admin_firstname "max" --admin_lastname "power" --admin_email "" --admin_username "admin" --admin_password "password"

Update: Thanks to Nathan for pointing out that the latest version of MAMP has a two versions of PHP in it. You’ll need to run:/Applications/MAMP/bin/php5.3/bin/php in the above command.

If it worked you’ll see something like SUCCESS: 183748... with a big long hash code. Now you should be able to see the default Magento start page here: and log in to the admin panel at /admin.

Let me know if you have any troubles with getting these commands to work. I ran through them myself doing an install and everything was just fine, but if your environment is set up differently there could be some subtle issues.

Posted on

Whoops: Magento supports PHP 5.2.0 or newer

You need to run PHP 5.2.0 or newer for Magento. This is normally not a problem for MAMP but a recent reader has asked about determining which version is running on their Mac when this error does occur. I just wanted to make a quick post on checking PHP versions in MAMP, because it seems if your Mac has other versions of php installed you can end up having odd results when trying to run Magento in MAMP.

You can determine which PHP version your MAMP server is running by opening the MAMP ‘start page’ and clicking the phpInfo link in the top menu. This will also tell you which php.ini file is being used.

You can also run:

 php -version

Run this in a terminal (, to print the PHP version that is on your PATH. You can determine which php is being run by typing:

which php

To find any php binaries on your Mac you can run the locate command in a terminal:

locate php | grep "[^\.]php$"

The pipe into grep just filters out any files that have php in the path, but are not php binaries, and also removes any files that are of the form filename.php which would otherwise turn up in the search.

You can execute any of the php binaries this command finds with the argument -version to find out what version of PHP it is. This may help you to identify any versions of PHP you have installed that you do not want anymore.

For example:

/usr/bin/php -version
/Applications/MAMP/bin/php4/bin/php -version

If anyone has any other tips for solving this or questions please post them below. Hopefully we can make sure this problem doesn’t trip anyone else up!

Posted on

How to use Apache Virtual Hosts over a local network with MAMP

I was asked recently whether it was possible to use the Virtual hosting in Apache I describe for Magento on MAMP over a network rather than just locally. To make a sensible response I wanted to give a quick background to the HTTP requests going on and how Apache uses those requests to decide what HTTP response to send back. It turned into a bit of a long reply comment so here it is as a post instead.

I use a network Apache virtual hosts setup all the time (though the network isn’t a local network it’s the internet, but same principle).

Continue reading How to use Apache Virtual Hosts over a local network with MAMP

Posted on

How to use the MAMP Mysql command line client in a terminal

Coming from a Linux background, one of the things I didn’t like about MAMP was the way it hid away the mysql command line interface. Once you are comfortable using it, the CLI is a powerful and quick method of interacting with a mysql server. I just wanted to share a quick and easy way to access the MAMP mysql command line client on Mac OSX.

Firstly you can run the Mac OSX terminal easily by just typing:

ctrl + space bar (to access spotlight)

Then start typing ‘Terminal’ before you have even finished the little Apple gnomes will have guessed you want to open the Terminal (which of course you do). Start the Terminal by hitting enter when spotlight highlights the Terminal app.

Now that you are in a Terminal you are able to do all sorts of excellent things to your Mac. For now though, we’ll stick to running the mysql client. The client is located in /Applications/MAMP/Library/bin so to run it execute this command:

/Applications/MAMP/Library/bin/mysql -uroot -p

Continue reading How to use the MAMP Mysql command line client in a terminal

Posted on

How to install MAMP on your Leopard Mac

I’m writing a full series on setting up your Mac for Magnto ecommerce development, I should probably start with the first step – installing MAMP on a Leopard Mac, even if it’s a quite basic and hopefully self evident.

Maybe one of the less obvious things is that you do not need MAMP pro to get virtual hosting set up in Apache on a Mac, but it will require you to work with Apache config files as described in my post on setting up virtual hosts in apache on MAMP.

Continue reading How to install MAMP on your Leopard Mac