How to install WordPress locally for testing, learning, and development

How to setup a WordPress local install environments

In this tutorial, we’re going to setup a WordPress local install on your computer (laptop or desktop) to help you develop better themes, plugins, and test WordPress outside a live web environment.

What you’ll need to install WordPress on your local computer

In order to accomplish this tutorial, you’ll need to download a couple of pieces of free software from their source websites:

  1. WordPress – wordpress.org
  2. XAMPP – apachefriends.org

The first piece of software of course is WordPress, which is the software we’re trying to get running on your local computer. The second, XAMPP is a self contained LAMP (Linux, Apache, MySQL, PHP) server with all the setup already completed and optimized.

Setting up XAMPP on your local computer

XAMPP SetupThe installer for XAMPP is a simple process, just follow the steps as you would with any regular installer and wait for the installation process to complete.

Once done, your computer will have a fully functional web server installed and running. From this point, you’ll be able to run any LAMP  web application on your local laptop.

Why XAMPP? Before I continue, there are alternatives to XAMPP including a Macintosh specific and Windows specific version of the software. I’m not sure if the others are any better or worse, but I prefer XAMPP and since it comes in Mac, Windows, and Linux versions it’s the one I’ll recommend.

Configuring your WordPress database

XAMPP SettingsThe next step is to setup a database for WordPress in XAMPP. To do this, you’ll need to open the XAMPP application and turn on the web servers. After turning on your web servers, you should be able to visit your local website environment at http://localhost/ and see the welcome page for the XAMMP server.

To use WordPress on your XAMMP server you’ll need to setup a database by following these simple steps:

  1. open http://localhost/ in a web browser;
  2. open the phpMyAdmin link to open your database manager;
  3. selected Databases from the navigation tabs;
  4. create a new database with an appropriate name (wordpress for example);

Create a database in phpMyAdmin

Now that you have a database for WordPress to populate, it’s time to install the software properly.

Installing WordPress on your local server

WordPress in the XAMPP htdocs folderInstalling WordPress on your local server is now as simple as it would be on any website server except it’s local.

  1. download WordPress from the official source;
  2. decompress the archive;
  3. move the resulting folder to your local htdocs folder;
  4. set the folder permissions so everybody can read / write;
  5. open your new WordPress website at http://localhost/wordpress/ and enjoy;

Since I’ve done this a number of times over the years, there are a few things that I like to keep in mind to help me make the process smoother.

Set your file permissions

Take the time to set your file permissions on the WordPress folder. It may not seem a big deal but without the ability to write files, WordPress will struggle to create the required wp-config.php, .htaccess files, directories, and plugin files you’ll need later.

Local database settings

WordPress wp-config file for XAMPPWhen you’re setting up WordPress, you’ll need to remember your basic credentials:

  • Database Name – wordpress
  • Database User – root
  • Database Password –
  • Database Host – localhost

Remember, there is no password by default for connecting to your local database.

Summary

If you’re still looking for help setting up your own local hosting environment for WordPress, here are some great resources that I can recommend:

Of course, installing WordPress locally created it’s own set of problems from how to migrate your database between a test environment and the live site, to how to debug WordPress, develop themes, and connect to your server. I’ll do my best to find you some new tutorials to help you solve some of those problems shortly.

5 responses to “How to install WordPress locally for testing, learning, and development”

  1. Great post, and this is exactly how I’ve been doing my local WordPress development for the last few years. However, recently, many developers have been touting the advantages of using Vagrant (http://www.vagrantup.com/) and I’ve joined that crowd.

    Vagrant sets up a virtual machine on your computer, allowing you to have a development environment that mirrors the software (and the same versions of said software) that you’re using in production – which is invaluable.

    There is a project dedicated to creating WordPress development environments – Varying Vagrant Vagrants (VVV) that I would recommend checking out: https://github.com/Varying-Vagrant-Vagrants/VVV

  2. Hi Chris,

    This is certainly going to help me for testing the wordpress websites after customizing and making coding changes. Till date, i used to create a subdomain with demo.sitename.com and test the website, will use this approach and let you know about the experience of using it. :)

Leave a Reply

Your email address will not be published. Required fields are marked *