Localhost

Tag: Localhost

How to Set Up a Local WordPress Installation on Your PC

2018-10-30T22:18:47+00:00April 10th, 2015|25 Comments

There’s one clear dividing line between WordPress newbies and grizzled pros: whether they have a local development environment set up or not.

If you’re in the habit of working directly on a live site, you’re probably already painfully familiar with the frustration, risk and uncertainty that accompanies that approach. And if you’re not, you soon will be! This article is about taking the first step towards a new and better you: setting up a local WordPress installation on your PC and taking control of your development process.

We’ve already covered options for our Mac brethren here, but this time around we’re focusing exclusively on the world of Windows. Before we get going, let’s briefly run through the main reasons why you should really get started on this as soon as possible.

Reasons for Setting up a Local WordPress Installation on Your PC

There are four main reasons to get started with this process today:

1. You’re Free to Work Offline

Ubiquitous internet access is increasingly common, but it’s a rare individual who hasn’t been let down when it really mattered on more than one occasion.

Spotty connections while traveling, local glitches in the matrix or remote services unexpectedly going down are just three common problems that can have you tearing your hair out and, worst case scenario, losing unsaved work. Stop living with that risk.

Set up a local install of WordPress and you’re good to go no matter what your surroundings are; even when flying!

2. You’ll Be Working Faster

Regardless how fast your connection speed is, or how well apportioned the remote server is, reading direct from your hard drive is always going to be quicker. By working locally, you’re potentially saving hours of otherwise wasted time per week that you can put to good use elsewhere.

There’s a nice knock-on bonus when it comes to focus as well. The sort of unpredictable and unexpected delays you get when working remotely play havoc with getting into any sort of flow state. Work locally and you’ll be in the zone within minutes and able to stay there.

3. You’ll Be Able to Test Ideas Quickly

The power and flexibility of WordPress as a platform make it a superb solution for developers, business owners and designers alike but fleshing out those initial ideas is sometimes more involved than it needs to be.

Get your local setup right and you’ll have a perfect environment for quickly producing prototypes in just a few minutes.

4. No More Playing with Fire on Live Sites

There’s no other way of putting it: doing substantial development work of any kind on a live production site is the mark of an amateur and simply begging for trouble. Don’t do it.

By working locally, you’re ensuring that – if something does go wrong, or if you make a careless mistake – you have a chance to spot problems in an environment where they can be calmly dealt with without putting user experience, revenue or even your job at risk.

Hopefully the importance of having a local install is starting to become clear by now and you’re already thinking of the many ways this could make your life easier.

Let’s get down to business.

Setting up a Local Environment with XAMPP

XAMPP logo

It wasn’t so long ago that the mere thought of trying get a WordPress-friendly local environment working on a PC would have sent developers of anything less than expert level running for the hills.

These days, fortunately, it’s a relatively straightforward project. The basic setup isn’t quite at the level of simplicity of WordPress’ own famous 5-Minute Install but it’s more than manageable.

We’ll give some pointers for more advanced setups at the end of the article, but the simplest way to quickly get up and running is by using XAMPP – an application specifically designed to install a local web server suitable for WordPress onto your Windows machine.

XAMPP stands for cross-platform, Apache, MySQL, PHP and Perl and has long been the standby choice for PC-based developers looking for a quick and easy local setup.

(We should mention at this point that there’s also a very popular alternative called WampServer available if you are looking to explore other options. For this article though, we’ll be sticking with XAMPP.)

When you strip it right down, WordPress needs two things to run:

  • a web server with PHP running, and

  • a database.

XAMPP gives you a stable and easily manageable version of this right out of the box in one easy to install package.

Let’s get started.

Download and Install XAMPP

XAMMP is hosted over at the Apache Friends website. Visit the download page and choose either of the Windows versions on offer. Both are above WordPress’ recommended minimum requirements for PHP. The download should clock in at around the 143MB mark.

The XAMPP homepage

Once it’s downloaded, double-click on on the executable to launch the setup wizard and begin the installation. There’s a few points to note about the basic setup so we’ll be referring to screenshots from here on in.

Note: XAMPP is a well put-together package and we’ve tested the following steps ourselves with success. That said, depending on your existing setup, even experienced users can run into difficulty if they are doing this for the first time.

If you find yourself getting stuck at any point, check out the friendly Windows XAMPP community forums for troubleshooting tips.

Select the Basic Components

XAMPP ships with a number of packages that aren’t necessary for getting your local WordPress install running so, to keep matters simple, we’ll stick to just the subset required on the components selection screen. Choose only the following: Apache, MySQL, PHP and phpMyAdmin.

Select Your Installation Folder

The next step is choosing where XAMPP is going to live locally. You’ll be using the /htdocs sub-directory within this folder to serve your WordPress files to Apache so take note of its location.

Skip Bitnami Install

The app platform Bitnami offers an add-on for automatically installing WordPress along with extra software such as Joomla and Drupal in the next step. For the purposes of this tutorial, we’re going to stick to the basics and install WordPress by hand so leave the Learn more option unchecked.

Launch Your Control Panel and Start Apache and MySQL

Tick the option to start the Control Panel automatically in the final step. You can also start the Control Panel at any time in the future from the Start Menu or by clicking on XAMPP Control Panel in the XAMPP folder.

All being well, you should be looking at a Control Panel similar to the one below. Click Start next to both Apache and MySQL under the Actions header to get going.

Check Your Homepage in a Browser

Visit http://localhost in a browser of your choice and you should see the default XAMPP homepage being served by Apache from your local /htdocs directory.

XAMPP homepage on localhost

Congratulations! XAMPP is now installed and running and you are officially in business.

Before we move on to the next step, let’s mention a few common gotchas that might have tripped you up by now and how to handle them. If you find yourself completely at sea, head over to the Windows XAMPP community forums or consult the miracle that is Stack Overflow.

Gotchas: Managing Your XAMPP Permissions

During or immediately after your install, you may receive security/firewall warnings for both Apache and MySQL similar to the one below.

XAMPP permissions warning example

You’ll have to select the Private networks checkbox here in both cases to proceed further.

Gotchas: XAMPP Ports and IIS

By default, XAMPP is configured to use ports 80 and 443 for Apache and 3306 for MySQL. If these are already in use by other applications, you’ll receive an error and need to quit the other programs.

Another common snag here is that the default Windows web server IIS may already be running. If you see an IIS welcome screen when you visit http://localhost rather than the XAMPP home page above, you’ll need to disable IIS.

Setting up Your Database

Now let’s create our first database. XAMPP comes with phpMyAdmin (a convenient and powerful tool for managing MySQL databases) installed as standard, so we’ll be using that.

You’ll also find phpMyAdmin installed as standard on many remote hosting environments, so getting used to working with it locally is a great way to brush up your skills in a safe setting.

We need to do two things:

  • create a database for our WordPress install to use, and

  • create a user for that database with the appropriate privileges.

Launch phpMyAdmin direct from the XAMPP Control Panel by clicking on Admin in the MySQL row.

Launch phpMyAdmin from XAMPP

Now click on the Databases tab, enter the name of your database in the Create database field and click Create. Use a UTF-8 collation such as utf8_general_ci to avoid issues with character encoding down the line.

Create a database in phpMyAdmin

Now navigate to the Users tab, click Add user, enter a name and secure password and set the host to local. Then return to the Users tab, select Edit privileges on the user you just created, click Check all and save. We’re assuming here that this database will only be used locally and by yourself.

Make a note of the database name along with the user name and password. You’ll be entering them again shortly.

Create a user in phpMyAdmin

If you run into difficulties at this stage, head on over to the WordPress guide to using phpMyAdmin and troubleshoot from there.

Install WordPress

WordPress Logo

We’re out of the woods now and heading on to more familiar ground – installing WordPress. The process here is essentially the same as installing on a live server; the server just happens to be located on your Windows machine.

Begin by downloading the latest version of WordPress and extracting it to a folder within /htdocs in the XAMPP home folder on your system. Let’s assume in this instance you call the folder localwp.

Now make sure XAMPP is running Apache and MySQL and navigate via browser to the WordPress install script in that folder. Use the address format localhost/folder_renamed/wp-login.php. In our example that would be localhost/localwp/wp-login.php.

Reaching that page should launch the familiar WordPress 5-Minute Install sequence. Complete this using the database details you created previously and you should have a fully functional copy of WordPress running locally to use at your leisure.

Taking Your Local WordPress Install to the next Level

Congratulations! You are now covered for basic local development in WordPress on your Windows machine. Sooner or later though, you’ll be looking to kick things up a level. Here are three more advanced topics to explore when you’re ready go further:

1. Desktop Server

Desktop Server is a tool for automating and managing many of the steps we’ve just taken across multiple local installs. It can also be used to sync these local sites with live environments. Free and premium versions are available.

2. Varying Vagrant Vagrants

One for the power users, Varying Vagrant Vagrants is a sophisticated approach that leverages the power of virtual machines in Vagrant to create programatically reproducible WordPress development environments. There’s a great intro to the concept over at WebDevStudios.

3. Exploring Development Workflow

We’ve concentrated on the local environment here, but more sophisticated setups will call for a full local -> staging -> production workflow. This is a vast topic, but you can start dipping a toe in the water with WordPress Tavern’s overview.

Conclusion

It may seem a little daunting at first, but taking the time to get WordPress set up locally is going to save you a truly massive amount of frustration down the line. As we’ve shown above, it’s not that difficult to get up and running. To recap, here is the basic sequence again:

  • Download and install XAMPP,
  • Set up your database and database user with phpMyAdmin, and

  • Install WordPress locally and get to work!

With your local install humming along, you’re free to explore a world of other improvements to your workflow in a safe environment. Share what you discover with us down in the comments below and feel free to pass this tutorial on to any other Windows user who might find it useful!

Recent Posts

Recent Tweets

For privacy reasons Twitter needs your permission to be loaded. For more details, please see our Privacy Policy.
I Accept