MAMP Wordpress

Install WordPress Locally with MAMP

There are times when you want to build a wordpress site, but you don’t want it on your server quite yet and you want to build it locally on your machine.  That’s where the free application MAMP comes in. The abbreviation “MAMP” stands for: Macintosh, Apache, Mysql, and PHP. With just a few mouse-clicks, you can install Apache, PHP and MySQL for Mac OS X! (If you are a Windows user you can use XAMPP, but this tutorial is all about MAMP for Mac users only, sorry).

What is MAMP?

MAMP WordPressMAMP installs a local server environment in a matter of seconds on your Mac OS X computer, be it MacBook Pro or iMac. Like similar packages from the Windows- and Linux-world, MAMP comes free of charge.

MAMP is installed in the typical Mac fashion: very easily. MAMP will not compromise any existing Apache installation already running with your OS X. You can install Apache, PHP and MySQL without starting a script or having to change any configuration files!

Furthermore, if MAMP is no longer needed, it is sufficient to delete the MAMP folder and everything returns to its original status (i.e. MAMP does not modify any of the “normal” OS X).

How to install WordPress using MAMP

So, here is how to get WordPress installed using MAMP locally on your Mac so you can start building your WordPress website:

Step 1) – Download MAMP

Download MAMP by going to http://mamp.info and install it on your Mac.

Step 2) Add WordPress to MAMP htdocs folder

Once downloaded, look inside your Applications folder and you’ll see a folder in there called MAMP.  Inside of that folder you’ll see a folder called “htdocs”. Here is where we are going to install WordPress.  So first we need to go get the WordPress install by downloading the current version by going to http://wordpress.org/download/.  After you’ve downloaded wordpress, unzip the .zip file (if your browser didn’t unzip it for you) and move the Wordpress folder to the htdocs folder.  So your path should look like this: Applications/MAMP/htdocs/Wordpress/Wordpress Files Here.  You might want to rename the WordPress folder so it’s the name of your website, so the path becomes Applications/MAMP/htdocs/your_new_website/Wordpress Files here.  So here’s what it should look like in your finder:

MAMP Install Location

Click to Enlarge

Step 3) Launch MAMP

Launch MAMP by launching the MAMP App that is in the MAMP folder and wait for all the green lights to show up on the “Apache Server” and “MySQL Server”.

MAMP Start Screen

Step 4) Create Database

Click on the “Open Start Page” button (which will launch in your default web browser) and navigate to the “phpMyAdmin” section.  On this page you’ll see the title “MySQL localhost” and under that you’ll see a “Create New Database” section. Type in a name that you want to name your database (I recommend it being all lowercase with no spaces), then click create (you can leave all settings at their default). You’ll see a new page that says (in green) “Database “your_database_name” has been created”. You can then close this window.

MAMP Database

Click to Enlarge

Step 5) Install WordPress

Now that we have our WordPress files in place in the htdocs folder (Step 2) and a database created (step 4) we are ready to do the famous 5-minute-install of WordPress.  There are a couple sub-steps here that I’ll walk you through:

Step 5A) wp-config file

So first things first, we need to tell our wordpress files where to look for the database.  So navigate to the wordpress wp-config-sample.php file in the applications/MAMP/htdocs/your_site_folder/ and rename it to wp-config.php.

Now open up wp-config.php in code editor (such as Coda or Espresso, or even TextEdit would work) and you’ll see sections where you can add the database name, username, password, host, and more. Which looks like this:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');
 
/** MySQL database username */
define('DB_USER', 'username_here');
 
/** MySQL database password */
define('DB_PASSWORD', 'password_here');
 
/** MySQL hostname */
define('DB_HOST', 'localhost');

Then just change the “database_name_here” with the name of the database that we created in step 4.  Username is “root” and Password is “root“. Don’t change hostname, character set, or database type.

We then need to create a Unique Authentication key.  You can do so by going to this URL https://api.wordpress.org/secret-key/1.1/salt/.  Copy all text from the web browser and paste it over the matching items in the wp-config file.

Authentication Code

Click to Enlarge

Now save the file and close it.

Step 5A) Install WordPress

Now we are ready for the fun WordPress installation part. Simply browse to the local host install wizard in your web browser by going to http://localhost:8888/foldername (this folder name is the name we created in step 2.  Then you’ll be seeing the great WordPress install wizard to walk you through the rest where it will ask for:

  • Site Title – Whatever you want to name your site.
  • Username – This will be the admin username to log into the main backend of WordPress website.
  • Password – This will also be the admin password to log into the main backend of WordPress website.
  • Your Email – This is important as all the notifications will go to this email as well as if you forget your password it would be sent to this email as well.
  • You’ll also see a checkbox that asks: “Allow my site to appear in search engines like Google and Technorati.”.  Since your site isn’t really online this doesn’t really matter, so I’d recommend keeping it unchecked until you actually take your site live.
Wordpress Installation

Click to Enlarge

Step 6) Launch Website

Congratulations! You have successfully installed WordPress on your local machine. If you want to install another install just repeat the process with a different folder name in the htdocs folder. Now all you need to do is click the “Log In” button you’ll see on your screen and you can alway pull it up new by going to http://localhost:8888/your_folder/

Transfer MAMP WordPress site to your Live Server

Now you can begin developing your website locally to get ready to transfer to your website.  I’ll be creating a separate tutorial on how to get your site from MAMP to your live server, but for now here are the quick simple steps:

  1. Change the wordpress URL in the backend settings of wordpress to the new server domain name on both the WordPress URL and the Blog URL.  Then click “Save Changes”
  2. Your website will now look broken.  That’s cause it’s now looking for the domain name.
  3. Now go to the phpMyadmin section in MAMP and select the database where your wordpress site is installed.
  4. Go to the export tab, and select all tables, be sure that SQL is selected, check the checkbox that says save as a file, and give the file a name and click “go”.
  5. Now simply upload your wordpress files to the server.
  6. Now go to the MySQL Database Manager for your site and create a new database, along with new user, password, etc.
  7. Now in the database manager go to the import tab and import your database that you exported from MAMP.
  8. Go to your wp-config.php file and add the database info that you created/used for the new database.
  9. Test your site and you should be good to go!
As I said I’ll be creating a tutorial with more details on how to get the MAMP WordPress install to your server, but hopefully that was helpful.

Hope that all makes sense and you are able to successfully get your WordPress install on your local machine with MAMP. If you found this tutorial helpful, please consider donating to the website and the further developement of it.
Make a Donation to Learn2Wordpress.com

Comments

  • Curtis Ellis
    Reply

    Hi Jason,

    Great tutorials and tips! We appreciate them. I’d like to know how to upload a WordPress Theme to my locally using MAMP that I could edit before taking it live. The themes I purchased did not come with a .zip file. So, I zipped it myself using the compress feature in Finder, but each time I received an error saying “Are you sure you want to do this? Please try again.”

    Any help would be much appreciate.

    Sincerely,
    -curtis

    • Jason White

      Curtis, drop your theme folder in the WordPress install location wp-content/themes/here if you put your theme folder there then you will be able to see the theme in the WordPress backend under Appearance > Themes

      Hope that helps.

      • Curtis Ellis

        Oh, ok. That sounds so simple. What was the need for the FTP client? We are running OS X Lion (10.7.2). How can we send a donation for your help? Thanks again.

        Also, pretty soon we’ll be changing our iWeb site over to WordPress. We appreciate the tutorials. We’re learning a lot. Great job!

        -curtis

  • Curtis Ellis
    Reply

    Wee are trying to transfer WordPress site from one localhost (iMac) to another localhost (Macbook Pro). Is this possible? If so, how?

    Thanks for your help.
    -curtis

    • Jason White

      Hi Curtis, it indeed is. However it’s going to take a few steps of moving the WordPress files and changing the current database to moved as well. I’m not sure what your skill level is with this kind of stuff, but I’ll just give you the basics for now: (note: be sure to backup your site before doing so, I recommend BackupBuddy)

      1) Create a WordPress install on the receiving Mac (MacBook Pro) using Mamp with the above steps in this tip and make note of the URL that it uses.
      2) Go into your WordPress admin on your current install (iMac in your case) and go to the general settings and change the URL to the url that the MacBook Pro had. After saving it will appear that the site is broken. Don’t fear.
      3) Open up the phpMyAdmin from the start screen that MAMP gives you. And export our your database. (you do so by clicking the export tab, selecting all the database tables, saving it as a sql file. It will then save the .sql file to your computer.
      4) Open up the sql file in a html editor and do a mass replace of all the old urls to the new url. For example localhost:8888/imac/wordpress/ to localhost:8888/macbookpro/wordpress/ (it might be possible that it’s the same url in that case you don’t need to change anything.) Once done save it.
      5) Transfer all the WordPress and theme files over to the MacBook Pro in the same location as it was on the iMac, and open up the PHPmyAdmin for the MacBook Pro database of the wordpress install. Click on the summary tab, and select all the tables and “drop” them which basically will remove all the tables in the current database. Then click the import tab and import your new .sql file (which now has the correct urls for this install) from your previous install.

      Now simply visit your local url and you should be in business.

      If you want to make it much easier you can get the backup buddy plugin (paid) which will help you do the migration very easily.

  • Curtis Ellis
    Reply

    Thanks Jason for giving such thorough instructions on transferring WordPress site from iMac to MBP. All I can say is that…you’re a genius, bro. All I knew before was iWeb. Then you encourage us to move over to WordPress with the shutdown of MobileMe looming. This is our first project with WordPress and it happens to be our biggest. So, your level of expertise and understanding has been a huge help to us. We’re were grateful for iWebUnlimited.com and are already even more grateful for Learn2WordPress.com. We will be moving our personal website over to WordPress soon, as well. Thank you. We all appreciate the help. Especially, those of us that are not as familiar with coding. :-))

  • Curtis Ellis
    Reply

    Hello again Jason.

    We are now about to transfer our Localhost site to a live web server (GoDaddy.com). We watched your tutorial on how to install WordPress on GoDaddy, so our question was how do we then transfer our files from the Localhost to the Web Server while keeping all of the edited site content safe and uploaded to this new home?

    • Jason White

      You could use the same steps I mentioned above, but really the easiest (and most reliable) way that I’ve found is to use the plugin BackupBuddy. It makes it incredibly easy to backup your site from MAMP (or any server), then they have super easy migration tools to move it to a new location/server.
      1) Purchase BackupBuddy here: Get BackupBuddy »

      2) Watch Video here that shows how to do it:
      Watch BackupBuddy Video

  • Curtis Ellis
    Reply

    Awesome. I’ll have to save up a few pennies and just buy the Unlimited Sites package. In the meantime, I’m going to rematch your tutorials and Learn2Wordpress! I too have been following you since we first heard of iWebUnlimited.com. You’re the professor and class is in session, bro. ‘Preciate the tutorials, vids and great support you give to us who are working hard to become respected web developers. Thanks!

  • Curtis Ellis
    Reply

    Ha! Hey Jason. We just went for it and purchased the entire PluginBuddy Developer Suite w/ unlimited sites. Thanks for the advice. I’ll get started on the transfer soon.

  • Curtis Ellis
    Reply

    Hello Jason.

    We are trying to use the BackupBuddy plugin to transfer our locally MAMP hosted website to GoDaddy, but are having difficult time in doing so. Our hosting and domain name is with GoDaddy. We have uploaded the backed up files from BackupBuddy. We begun the Restoration & Migration process, but have stalled out on Step 3. It returned the following error:
    1. Logging in to server … Failed
    Error: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
    2. Verifying database access & permission … Failed
    Error: N/A
    3. Verifying no existing WP data … N/A
    4. Overall mySQL test result … Failed

    We are unsure on all of this and are afraid to lose two months worth of work on the site. It is backed up using a Full Backup with BackupBuddy. Can you shed some light on this gloomy situation?
    Thanks.

    Warm Regards,
    Curtis

    • Jason White

      Hmmm, my first thought (based on the error) is perhaps you aren’t putting in the correct database username and password. The GoDaddy username you will find if you log in to your hosting control panel and go into the MySQL section. The title of the MySQL database is the username, then make sure you have the correct password. Be sure to the the backed up .zip file on the level where you are moving the site. But this sounds like it’s a database login issue.

      • Curtis

        Hi Jason,

        We’ve got the site up & running. Thanks for all the tutorials and additional comments. They helped immensely. This website is a great resource for anyone new to WordPress or just wanting to review before starting the process. Thanks again!

        -curtis

  • Sierra
    Reply

    Hi Jason,

    You’re a gem first of all. I am finally moving with you from iWeb to WP. Wowzers. BUT I am having difficulty with step 5A… When I type in http://localhost:8888/thefoldernameicreated (this folder name is the name we created in step 2) I don’t see the great WP install wizard! Just server error or not found. I have double checked everything – or at least I thought. Any suggestions?

    • Jason White

      Be sure to check if; (1) You created your database, (2) You renamed the wp-config-sample.php to wp-config.php and added the database settings.

  • Sierra
    Reply

    fingers crossed, I think I figured it out using http://localhost:8888/wp-login.php from this webpage: http://www.a4aapl.com/2009/12/how-to-install-wordpress-on-mac-with.html.

  • Jeff B
    Reply

    Hey Jason, great work with this post. Quick question for ya. I have just become webmaster for an existing wordpress website. I have a new theme that I want to customize using espresso and use for the website. Is it at all possible for my locally installed wordpress to point to the existing databases so that I can truly develop locally and then publish all at once when the redesign is complete? Thanks in advance! Jeff

    • Jason White

      It is possible to use your servers database on a local install, however that kindof defeats the purpose of having it locally. Cause one of the main points is that you can develop without an internet connection and do it all from your computer, plus even if you did that your urls would still be local urls that you’d have to update your database later anyway. I recoommend keeping it all local (site and database), then using BackupBuddy to move it to your live environment. It works great!!

  • alex
    Reply

    Hi Jason,

    I just downloaded WordPress Twenty Twelve (Version 1.2), and I don’t see a file named wp-config-sample.php anywhere in the folder.

    Should I try downloading it again?

    Alex

    • Jason White

      Hi Alex, it’s not in the Theme, it’s in WordPress core itself.

      • Alex

        Thanks for the reply!

  • Alex
    Reply

    Hi Jason,

    I know it’s been a while since you posted this helpful tutorial.

    I’m trying to connect to my new wordpress site, via localhost, but I’m getting a “file not found” message. There are two other local sites that I’m able to connect to, but for some reason I can’t connect with this one.

    Could it be a problem with the way I’ve set up the config file?

    Alex

    • Jason White

      Hi Alex, without seeing it, it’s hard to troubleshoot. It could be your wp-config file, it could be permissions, it could be your.htaccess, etc. I’d first make sure that your site is in localhost/(folder name), then this site http://codex.wordpress.org/First_Steps_With_WordPress may also be of assistance.

      • Alex

        Thanks Jason. I’ll keep digging.