Sélectionner une page

How To Create A Local WordPress Installation On A Mac

How To Create A Local WordPress Installation On A Mac

Of all blogging platforms, WordPress takes the trophy as the most popular. Since 2003, WordPress has allowed users to blog on top of beautiful websites with no upfront costs. Today WordPress has held onto it’s roots as well as evolved into a fully functional CMS offering users the ability to build nearly any type of website.

Whether you want a custom install (www.wordpress.org) or a place to just write your thoughts and ideas,(wordpress.com) there’s no easier way to go about creating your own blog.

Our very own Kevin Muldoon recently wrote a post about Installing WordPress on a Windows Machine. This post will be about doing the same thing only on a Mac.

Why Install Locally?

Before we dive in, I wanted to explain the benefits to installing a local version of your WordPress site or any website for that matter.

Working with WordPress locally allows you to make changes and revisions to your website’s design, functionality, or even theme options on the fly. Since the installation is a local one it will not disrupt what your users see on your existing live website.

On top of all of these things the concept of testing plays an even more important role. Say you have installed a new theme or a new plugin and want to give it a try before anyone else can see it. There’s no better way to do this than to try it locally to work out any kinks or conflicts that may arise.

Always keep updates in mind with WordPress, your themes, plugins, etc.. when logged into your live site. While most developers make their code play nicely with others, there’s always a chance that it can break your site causing a moment of panic and possibly even some down time before a you figure out a solution to the problem.

How To Create A Local WordPress Installation On A Mac

WordPress requires an enhanced environment to run correctly on your Mac. This environment uses a local PHP server and MySQL server that when working together provide the necessary code to run WordPress properly. For this tutorial we will be using an application called MAMP. MAMP stands for Macintosh, Apache, MySQL, and PHP.

Downloading MAMP

Before you can install MAMP on your Mac, you’ll need to download it from the MAMP website. MAMP requires that your Mac be running Mac OSX 10.6.6 or later so be sure your system is up to date.

At the time of this writing, MAMP currently offers a beta version for Windows users so if you are following along and are on a PC feel free to give it a try. If MAMP isn’t for your be sure to check out Kevin’s post about Installing WordPress on A Windows Computer.

After you have downloaded the software (which might take a little while to download due to it’s size) double click the .pkg file and install.

Unless you plan on buying MAMP Pro, which I have to say has some great features, be sure to pay attention to the Installer prompt. Once it you make it to Installation Type you will see a Customize button on the bottom left.


Customize your MAMP installation

Click “Customize” and uncheck MAMP Pro from the packages to install. This will save a bit of space on your hard drive. Ok now go ahead and click Install.

Configuring MAMP

Now that you have MAMP installed, head to your Applications folder on your Mac. You should find a new folder for MAMP that looks like the image below.


Our newly installed MAMP folder

Inside this folder you’ll find some more folders and some applications. For now the main one we are concerned with is, you guessed it, MAMP. If you plan to work locally a lot, drag the MAMP application icon to your dock and assign it to stay there.

Fire up the application and you’ll see the screen below. It’s extremely simple and offers only a few options from the start. This is a good thing as it makes setup a breeze.


MAMP’s simple interface

In order to get our local WordPress installation off the ground we need a place to keep the files that make up the software. By default, MAMP assigns a folder named “htdocs” to be the home for our local sites. For this tutorial we will use the default provided by MAMP but I want to point out that you can assign any folder on your system to be your workspace for all of your locally installed websites. Some people will often use a folder that is version controlled with Git or even a folder on their dropbox to have access to backups at all times.

To change your root folder simply click “Preferences” on the MAMP Main screen and click the tab titled “Apache”. Here you will see the path to your htdocs folder which like I said before is assigned by MAMP by default.


MAMP’s preferences at a glance

Look for the folder icon above the folder path. Click to to assign a new folder as your local site directory.


Start MAMP Servers

With our local site directories all setup (our’s is the MAMP default), we are ready to start up the MAMP servers.

Click the big Start servers button.

If your servers started successfully your default browser should open to a webpage at http://localhost:8888/MAMP/ which looks like below.


The MAMP start page.

The MAMP Start Page tells us a little bit about our setup as well as provides us with some important tools we will need to use coming up. Now that MAMP is running it’s time to download WordPress.

Installing WordPress Locally

To download a local installation of WordPress we need to visit the WordPress Website to get the latest version.



Upon visiting the site you’ll likely see a download button instantly. Click it and download to your Mac. At the time of this writing we will be installing WordPress 3.9.1. The download comes as a .zip file which you can unarchive with your Mac’s built in utility. Within the archive is a single folder called wordpress.

This folder contains everything required to run a new copy of WordPress locally. We will move this folder to our htdocs directory which was explained when installing MAMP earlier.


We move our wordpress download into our htdocs folder.

Configuring WordPress To Run Locally

Out of the box WordPress requires a bit of information to operate.
WordPress requires:

  • a database
  • an optimized wp-config.php file
  • a php/mysql server (we have taken care of this one!)

If you open the MAMP start page and navigate to http://localhost:8888/wordpress/ you’ll likely see an error about a wp-config file not being present. We will take care of that in a bit but before we do, let’s create a database.


Wordpress Error

Error message indicating that we need to setup our wp-config file.


Databases are organized collections of data. Think of it as a home for each and every blog post you create or image you upload. It’s a place to store content we create through WordPress.

Earlier, I mentioned some tools that came bundled with our MAMP application. One of these tools is called phpMyAdmin. You can find this tool by visiting the start page on MAMP. Under the Tools menu item there should be a link for phpMyAdmin. We will head there now.


phpMyAdmin screen

At first glance phpMyAdmin might look a little overwhelming to you if this is your first look at it. We will be doing on critical but simple task to get our installation in place. Most of the time you likely won’t be inside phpMyAdmin a lot but it is a necessary step when installing any website that requires a database.

Creating a database

Let’s create a database for our WordPress installation. Look for the tab labeled “Databases” inside of phpMyAdmin. Click it and you will see and input field with a create button alongside it.


We create our database

Lets enter a name for our database in the input field. We will call our database wordpress. Be sure that it is in all lowercase characters and click create.

You should see now that we have added a new database titled wordpress.


Database successfully created.

With that complete we are now finished using phpMyAdmin.

The wp-config.php file

Think of the wp-config.php file as a settings area for your WordPress installation. Here WordPress uses values you supply to connect successfully to a database. In our case we will be configuring the file to connect to our local database we created earlier.

Let’s configure the file. Open up the folder within our htdocs folder called wordpress at

Inside the folder you will see our wordpress installation. In order to edit the config file you will need a text editor of some type. I would recommend a code editor such as Sublime Text or Coda 2 to edit these files. I could go into why but I’ll save that for another time.

Here’s is our project open in Sublime Text

sublime project

Our project open in Sublime Text

With our folder open we need to modify the existing file called wp-config-sample.php. Lets rename this file to wp-config.php. WordPress will automatically recognize the file once we finish. Once you have renamed the file open it up in your code editor.


Our default wp-config.php file.

Inside the file you’ll find some text that has been commented out, explaining what the file does and why it’s important to the functionality of WordPress.
The lines of code we will be editing are below:

/** 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');

If you recall we named our database wordpress so we will update the first line to replace the “database_name_here” text

define('DB_NAME', 'wordpress');

The next two lines coincide with our database username and password. By default MAMP sets both of these values to root. If you ever forget you can find the same information on the MAMP start page at http://localhost:8888/MAMP. The lines update to the following:

define('DB_USER', 'root');

define('DB_PASSWORD', 'root');

The very last line of code we needn’t worry about. Because we are running our site locally the value of “localhost” already works. So combined we get our wp-config.php file to look like this:

/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'root');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Here it is again inside Sublime Text with the updated values:


Our wp-config.php file updated.

Keep in mind that once you decide your local website is ready to launch you will need to edit this file again when uploading the site to a web server. We won’t cover this today but I just wanted to note that this file plays an important role no matter the situation.

Testing Our Local Installation

Now that our configurations are all setup we can test our work. Head to your site at http://localhost:8888/wordpress/. You should now see the popular screen below:


The infamous 5 minutes install screen

Known for it’s quick installation. WordPress has coined the phrase “The Five Minute Install”. This page essentially sets up your installation to declare a name for your blog as well as setup your username and password.


Once complete you will be redirected to your flashy new WordPress Installation. Congratulations on making it this far. You now have a fully functional WordPress installation on your Mac. From here you can use one of our themes to customize your site any way you please.

After reading this tutorial do you think working locally is a smart way to develop a website? Let us know in the comments below!

Source link