There are a variety of reasons you might want to install WordPress locally. Want to test to see if a new plugin will conflict with other plugins? Want to change some code but not sure if you’ll break something? Just want to compare the look of your site with a new theme side by side with your current? You can do all these things and more if you have a local installation of WordPress on your computer without having to worry about breaking anything on your live site.
This article will walk you through how to install WordPress locally on your Mac using MAMP (Macintosh, Apache, MySQL, PHP). Despite the name, you can also use MAMP for WordPress installation on Windows machines. There are some minor variations in the process relative to OS differences, but it is very similar. Stick with us and you’ll be up and running in no time!
Installing WordPress On Your Local Machine
Step 1: Downloading and Installing MAMP
Normally when our browser is online, it requests a WordPress site from the server that site lives on (Bluehost, for example), the server returns data in a format that our browser can understand, and the browser displays it.
MAMP takes the role of a server for your local environment. Since your browser can’t understand WordPress on its own, it makes its request of MAMP, which through its installed features (Apahce, PHP, MySQL) is able to output the WordPress data in a format your browser can understand and display for you.
- Head over to the MAMP website and download MAMP. The free version works just fine.
- Install MAMP and run the application just like any other.
- When the MAMP application runs, you’ll see the application window (see the screenshot below) as well as a MAMP web page open. Leave the web page open but for now focus on the MAMP application window. Click on ‘Start Servers’. The light should turn green after a few seconds and you now have a local server environment up and running! Anytime you want to run WordPress locally in the future you’re going to need to start MAMP first and click Start Servers.
Step 2: Creating a Database for Your WordPress Installation
When you have a WordPress site online, your pages, posts, plugins, etc are all stored in a WordPress database on that server. You need to create a database now on your local environment. That’s what we’re about to do in this step.
- Return now to the web page that opened when you opened MAMP. Click on Tools on the menu at the top of the page, and then click phpMyAdmin from the dropdown that opens. This will open a new browser tab for your localhost.
- On the new localhost tab, click on the Databases tab in the upper left.
- On the Databases tab, you’ll see where you can enter the name of your database. Name it whatever you like/will remember. I’ll call this one “wptutorial”.
- Now look to the right at the drop down list titled ‘collation’. Click that list, scroll down to the utf8 section, and select utf8_unicode_ci.
- Click ‘Create’ just to the right of the drop down list. Your database name will now appear on the left hand sidebar tree in that window and you now have a database!
Step3: Downloading and installing WordPress
Now we need to get WordPress installed and configured for your local environment.
- Head over to wordpress.org and download a copy of WordPress. Unzip it.
- MAMP has created the folder htdocs that will serve as the root directory for your WordPress install. You can find the htdocs folder under MAMP wherever you have MAMP installed. Open htdocs and drop your unzipped WordPress folder inside.
- Now we need to configure WordPress to connect with the database we created in Step 2. Open the WordPress folder and find the wp-config-sample.php file. You’ll need a text editor to open it.
- Refer to the before/after screenshots below. You want to change the database name to the name you used for the database you created in step 2 (I used wptutorial). Both the username and password need to be changed to ‘root’ (with one set of apostrophes around the word).
- Now save this file, but remove ‘sample’ from the name. Your saved file should be wp-config.php. If you leave ‘sample’ in the name, WordPress will ignore it.
- Verify that MAMP is open and servers are running (Step 1). Open a new browser tab and in the url bar enter the following address to open your WordPress installation: localhost:8888/wordpress/
- Follow the prompts to set up WordPress (site name, username, password, etc), click install when directed, log in, and you’re good to go!
Now that you have WordPress installed on your local machine you can play! Try new themes, experiment with code, try all the things that you were afraid to try on your live site! Worst case scenario, you completely break your local WordPress install beyond any hope of repair. No problem! Delete the WordPress folder in htdocs, repeat Step 3, you’re back on your feet. Have fun, experiment, learn, and don’t be afraid to break something!