A few weeks ago I spoke about the importance of having a test area for WordPress so that you can test plugins and develop themes without worrying about anything messing up on your live site.

I’ve always had a test blog installed somewhere online so that I can play around with things so that I can access it anywhere in the world and test themes and plugins. It’s beneficial to have WordPress installed locally too; it can be a real life saver if your internet connection slows down or is lost completely as you can continue to work on modifying your blog in your test area and then update your live blog later.

Today I will be showing you how to install WordPress locally on your Mac or PC. It may seem daunting at first, but as you shall soon see, it’s actually very easy :)

How to Install WordPress Locally on a Mac

MAMP is a fantastic application for Macintosh which allows you to install a local server on your computer (MAMP stands for Macintosh, Apache, Mysql and PHP). The standard version is free and comes with a 14 day trial of the pro version. I believe the standard version is more than sufficient so you don’t need to worry about spending any money upgrading.

OK, let’s get started. The first thing you need to do is download MAMP and install it on your Mac. The file is 162mb is size. Simply unzip the file and drag the dmg file to your application folder to install it.

When you load MAMP up you should see the following start up screen:

MAMP Start Screen

You should then create a directory for your WordPress installation (e.g. WordPressLocal) and copy all of your WordPress files to it.

Then click on the preferences button. The default ports are 8888 for Apache and 8889 for MySQL. There isn’t any reason to change these. What you should do is click on the Apache tab at the top and change the Document Root to the destination of your newly created WordPress folder (e.g. /Users/yourusername/WordPressLocal).

The next thing you should do is start servers from the MAMP start up box (this will change the status lights from red to green). Once the Apache and MySQL servers have been started you need to click on the ‘Open Start Page’ button. Doing so will open up the following page in your browser (the URL will be something like http://localhost:8888/MAMP/?language=English).

MAMP Start Page

Click on the phpMyAdmin tab at the top of the page. From here you can create and modify your WordPress database.

You can call the database whatever you want though I kept things simple and called mine WordPress.

phpMyAdmin

Go back to your WordPress folder and open up wp-config.php and enter your database information (rename it from wp-config-sample.php if you haven’t already done so). The hostname should be set to ‘hostname’ whereas the user and password should both be set to ‘root’. The database name is the name of the database you created earlier in phpMyAdmin.

The database connection area of wp-config.php should look something 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');

Once you have updated your wp-config.php file you can now access your new WordPress installation at http://localhost:8888/ (assuming you didn’t change the Apache Port number).

Now you can install WordPress using the famous 5 minute installation.

Installing WordPress Locally

How to Install WordPress Locally on a PC

Installing WordPress on Windows is very similar to installing it on a Mac. The only difference is the application which is used to create a local server.

The three I would recommend for Windows are the WordPress Web App from Microsoft, Wamp Server and XAMPP.

You will need to install the Web Platform Installer for the WordPress Web App to work though it is arguably the best one to use (it’s certainly the easiest). The Web Platform Installer works with Windows 7, Windows Vista, Windows Vista SP1, Windows XP SP2+, Windows Server 2003 SP1+, Windows Server 2008 and Windows Server 2008 R2.

Even though I have Vista on my Windows laptop, the installer wouldn’t install correctly. Therefore for this tutorial I will be using the Wamp Server as an example in this tutorial :)

Once you launch Wamp Server you will see a new Wamp icon in your toolbar. Clicking on the icon will bring up the Wamp menu. You can configure Apache, PHP and MySQL from this menu.

WAMP Server Start UP Box

Selecting phpMyAdmin will open the application up at http://localhost/phpmyadmin. Create a new database for your fourth coming WordPress installation. I called mine WordPress.

phpMyAdmin

Now go back to the Wamp menu and click on www directory. Doing so will open up the www folder in Windows Explorer. It is a subfolder of the main Wamp directory so unless you changed the default install directory it will be located at C://wamp/www.

Copy all of your WordPress files over to the www directory. There should already be an index.php in the www directory but it is not needed so simply copy it over with the WordPress index.php file (or delete it before moving the WordPress files over).

Next you need to open up wp-config.php in a text editor and enter your database information (rename it from wp-config-sample.php if you haven’t already done so). The hostname should be set to ‘hostname’, user should be set to ‘root’, and the password should be blank. The database name is the name of the database you created earlier in phpMyAdmin.

The database connection area of wp-config.php should look something 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', '');
 
/** MySQL hostname */
define('DB_HOST', 'localhost');

You are now ready to install WordPress. Go back to the Wamp menu and open the top link entitled ‘Localhost’. This will open up http://localhost/ in your browser and you can start installing WordPress using the famous 5 minute installation :)

Installing WordPress Locally

Summary

To recap, the main steps in installing WordPress locally are:

  1. Download an application which lets you create a local server.
  2. Create a database in phpMyAdmin.
  3. Download WordPress. Depending on the server application you use, you will need to either copy the WordPress files to a specified directory or create a directory for WordPress and link to it in the settings/preference area.
  4. Rename wp-config-sample.php to wp-config.php and enter your database connection details. This information is different for every script so make sure to check the documentation on the application website.
  5. Open up the local area start page. It’s usually located at http://localhost/ or a similar URL.
  6. Install WordPress, sit back, and give yourself a pat on the back!

I hope that this tutorial will help you install WordPress locally on your computer. I didn’t run into any problems using MAMP on Mac or Wamp Server on Windows though if you run into any problems please let me know and I’ll do my best to help.

Good luck,
Kevin

Further Reading