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 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:
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”.
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.
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 */
/** MySQL database username */
/** MySQL database password */
/** MySQL hostname */
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.
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.
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:
- 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”
- Your website will now look broken. That’s cause it’s now looking for the domain name.
- Now go to the phpMyadmin section in MAMP and select the database where your wordpress site is installed.
- 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”.
- Now simply upload your wordpress files to the server.
- Now go to the MySQL Database Manager for your site and create a new database, along with new user, password, etc.
- Now in the database manager go to the import tab and import your database that you exported from MAMP.
- Go to your wp-config.php file and add the database info that you created/used for the new database.
- Test your site and you should be good to go!