As a developer, it’s always a great idea to setup a local developer environment. Here’s a guide to setup MAMP (Mac Apache MySQL PHP) on your Mac.
In this article you’ll learn:
- What MAMP is and why you should use it
- How to install and configure MAMP on your computer
- How to install WordPress on your computer (and where to store it)
- And how to use MAMP in the future with other sites you’d like to test
First off you might wonder what MAMP stands for:
- Macintosh: an operating system
- Apache: an open source web server
- MySQL: most widely available relational database in the world
- PHP: server-side scripting language
12 Steps to Installing WordPress Locally
STEP 1: INSTALL THE LATEST VERSION OF WORDPRESS
Next, open up a new finder window (⌘N) from your desktop. You should be in your user directory. (If not, make sure you are.)
STEP 2: INSTALL MAMP ON YOUR LAPTOP/COMPUTER
Next, you want to install MAMP on your machine. Do this by heading over to the official MAMP website.
Click on “download” below the free version. The free version should be sufficient for beginners.
On this page, click the orange “download” button as shown above.
MAMP should start downloading automatically. It can take a few minutes to download.
When it is finished, click on the download and a typical installation box will appear.
Continue through the steps past installation.
STEP 3: LAUNCHING MAMP FROM YOUR APPLICATIONS FOLDER
Go into your Applications folder (where MAMP should have been saved in the previous step) and click the “MAMP” folder.
Once inside, you should see folder contents that look similar to below.
Click on the elephant “MAMP” icon. And you’ll see this box appear.
I have my ports (pictured above) set on the default. (Which is 8888 for Apache, and 8889 for MySQL.)
However, others recommend setting it to the suggested ports 80 and 3306. If you’re a more advanced user and would like to learn about using these ports and setting up WordPress multi-site installations, check out this tutorial. Otherwise, stick to the defaults above.
STEP 5 : CONFIGURE THE WEB SERVER AND DOCUMENT ROOT
Now click on the “Web Server” tab.
Make sure the web server selected is “Apache”.
Now, you’ll need to set the document root. The document root is where all your files for you local web server will be stored.
My document root, as shown in the photo above, is: Macintosh HD > Applications > MAMP > htdocs
Mine is this way because of how I installed and setup MAMP initially.
But remember back in step one when we created the new folders with the fresh WordPress install zip file?
That’s going to be your document root.
To change/set your document root, click the gray folder icon. A finder window will appear, where you can select the document root.
Below is what yours should look like when you set the root to the “wordpress” folder in the “sites” directory (except with your name rather than “Sites”).
However, it is important to realize that by setting up the document root, you are not changing the location of MAMP (the application). You are simply specifying where MAMP will be looking for the files.
(Pro tip: I store both the MAMP application and my document root folder in the dock at the bottom of my screen for easy access.)
STEP 6: START YOUR SERVERS
Let’s make sure everything is working up to this point.
Click on the “Open start page” option in the MAMP box.
(Note: If you can’t click it, your servers probably aren’t turned on. The green color in the tiny boxes on the top right indicates that the servers are indeed turned on, as shown above.)
After clicking “Open start page”, you’ll be brought to a page that looks like this.
Information on this start page indicates your setup and other MAMP news / info.
STEP 7: CREATE A MYSQL DATABASE
Before you can get going with WordPress locally, you need to create a database for your install to live on.
MySQL is one of the most popular relational databases in the world. It is open source and without a doubt the most widely accessible. And all WordPress sites run on MySQL databases.
To build simple, or even more complex, WordPress sites you don’t have to know all the ins and outs of MySQL or databases in general. Just understand that databases are used to store data on most websites and web applications. Data like usernames, blog posts, comments, images, and so forth.
(However, also realize that you don’t need a database to build a site. You can build a simple one-page site with just HTML and CSS—no database—and it would still be a website. It would just be static site rather than dynamic.)
When using MAMP, you create new databases in phpMyAdmin. (Note: every time you want to create a new WordPress site locally you must create a new database!)
There are two options of getting to phpMyAdmin:
- Visit the URL http://localhost:8888/phpMyAdmin
- Or on the MAMP start page in your browser, click the phpMyAdmin link
Your phpMyAdmin panel will look similar to below…
What you should see, though, are these three in the side panel:
After you name your database, click the “create” button.
STEP 8 : UNZIPPING THE WORDPRESS INSTALL
Now, head back over to the root folder you set up previously in step one.
If you’ve been following along, your root folder will be here: “users > yourname > sites > wordpress”.
If this is your first time doing this, your root folder should be empty except with the WordPress install from step one. Just like below.
Unpack the WordPress zip file in the folder.
STEP 9: CONFIGURING THE WP-CONFIG.PHP FILE
Now, open the “wp-config-sample.php” file in your favorite text editor. Mine is Sublime Text 2.
Your wp-config-sample.php file should look like this on the inside.
In line 19, replace ‘database_name_here’ with the name of your database. Remember?
Mine is called ‘skillcrush_db’. (If you forget, go back to your phpMyAdmin panel.)
Then, in lines 22 and 25, replace ‘username_here’ and ‘password_here’ with ‘root’—which is the default for the database you created before in phpMyAdmin.
Your file should now look like below. (Except with your database name matching the one you created earlier.)
Save the file and ex out of it.
And now, this is very important, rename the file from wp-config-sample.php to wp-config.php.
Just remove the word “sample” from the file name.
There is another way to configure the wp-config file at the beginning of your setup in the browser rather than in the text editor. I prefer setting it up this way because you get to work directly with the files to make sure your MAMP setup is all connected properly.
STEP 10: THE FAMOUS FIVE MINUTE INSTALL.
Now, go to your preferred browser and type in the url pointing to your site folder.
Click continue, with “English (United States)” selected as the language. (Unless you would like the install to be in another language.)
And now the famous five minute install. Understand that the credentials you setup here is what you’ll use to log into the WordPress dashboard later.
So remember what you input for your username and password. (However, you can always change this information later.)
Note: if you skipped Step 9, you’ll have to set up the username and password for your database (“root”) here.
The information above is fairly self-explanatory.
But a quick note about the “Privacy” checkbox: Checking or unchecking the search engine visibility doesn’t really matter because the site is not online. Meaning a search engine can’t index the site. I unchecked mine anyway.
After you have all the information filled out, click the “Install WordPress” button.
Almost immediately you should see a success screen.