Skip to content

How to Install WordPress on Localhost: Step-by-Step From Scratch

The WordPress development team makes it simple and straightforward to develop on your live site. However, this isn’t the best way to make changes, and could see your site go offline, show changes to end users that you don’t expect, and more. A safer way to make changes is through using a local development environment – otherwise known as “localhost”. You can learn how to install WordPress on localhost using a few different ways depending on your preferences, skill level, and desired workflow.

how to install wordpress on localhost

For this post, we’ll show you ⏩ how to install WordPress on localhost. The instructions will cover Windows, macOS, and even Linux. This means regardless of your operating system (OS) you’ll be able to follow along.

Why you'd want to install WordPress on localhost

Most developers will have a strict and repeatable workflow that helps them take a website from the WordPress install ZIP file to a full live instance. While you can get complex with this, there are three touch points to bear in mind:

  • Live. 🐝 This is the site as you'd browse to on the web, and there shouldn't be any changes you make here. This is because you don't want your end users to see these changes, especially if they go wrong. In the worst case scenario, your site might have to go offline while you fix things, which can impact traffic numbers and future potential income.
  • Staging. 💻 This is a live server that contains your site, but you'll hide it from the public. This lets you test the changes you make without a negative impact to your live site. Also, you can try and catch any bugs and errors that occur due to the architecture of the target server.
  • Local. 🗃 You'll see "localhost" used a lot in this article, but in short terms, it's your computer. This isn't a live server, and only you can see the site. To achieve this though, you'll need to create a local development environment on your computer.

It's important to use all three "states" to develop your site, and the local environment might be the most vital. This gives you as much time as you need to create your site, without using up server resources or giving you a feeling of being "on the clock."

The methods you can use to install WordPress on localhost

You have a few different approaches to create a local development environment. There are all sorts of tools available, and each will install all the prerequisites you need for the most part. For example, XAMPP (which we'll cover in a minute) includes the following:

  • X: Cross-platform support.
  • A: The Apache server type.
  • M: Support for either MySQL or MariaDB databases.
  • P: PHP support.
  • P: Perl scripting support.

However, there are other tools that abstract this away under the hood, and also provide greater support for email testing and more. Over the rest of the article, we'll show you the general steps for each method. By the end, you'll know how to install WordPress on localhost in a number of different ways.

How to install WordPress on localhost (4 tools, 4 tutorials)

We're going to give you four different tutorials here. They won't be in any order, as each one could be suitable for you. Here is a list 📝 of the tools we'll use to show you how to install WordPress on localhost:

  1. XAMPP.
  2. A desktop local development environment, such as Local or DevKinsta.
  3. Laravel Valet.
  4. VVV.

First off, we're going to look at 🔎 a old stalwart of local development.


XAMPP represents one of the earliest ways available to set up a local development environment. While this version is cross-platform - and as such, you can use it with any Operating System (OS) - there are other versions that target specific OSs: MAMP and WampServer, for example.

The MAMP Pro interface.

Note though, that all of these versions are not from a single developer, which could confuse you. In many cases, developers like to create their own "stack" from the constituent parts. These apps look to bundle together the components you need in a single installer package.

Even so, XAMPP's User Experience (UX) is "dog-eared" in comparison to the other options on this list. For those with in-depth knowledge of XAMPP though, it will be a number one application. One of its benefits is customization ability. This means you can swap out database types, email clients, and much more. Though, the installation process is as straightforward as using its download installer for your OS:

The download section on the XAMPP website.

Once this is complete, make sure you run everything on the Manage Servers tab in the XAMPP panel - green is good!

Managing servers on the XAMPP control panel.

From there, test the connection using http://localhost in your browser, which should bring up a dashboard:

Running the XAMPP dashboard in a web browser.

You'll also want to install a database, as XAMPP won't do this for you. We cover this in our post on how to move a website to a new hosting provider.

⚙️ Installing WordPress

To install WordPress, you can download the ZIP file from the website.

Back in XAMPP, head to the Welcome tab and choose Open Application Folder. This will open your home directory, htdocs:

The XAMPP interface showing the Open Application Folder button.

Inside, give a new directory a descriptive name for your site, then extract the WordPress ZIP file. You'll want to make sure that the top level of the directory contains your files, as sometimes the extraction process can create its own home directory:

A local directory complete with WordPress files and folders.

After, head to localhost/<your-site>/wp-admin/setup-config.php within your browser (and replace the placeholder with your own site directory name.) This will begin the WordPress installation process:

The WordPress five-minute install wizard.

From here, you'll have some fields to fill out. The first requires your database credentials:

Entering database credentials for a new WordPress website.

Next, open up a new text file using whatever editor you like and copy the text on screen into it:

Copying data for a wp-config.php file during the WordPress installation process.

Save this file as plain text, rename it wp-config.php, and move it to your site's htdocs folder. From here, click the button to install WordPress. The final step is to fill in some more fields about your site, then click to install WordPress:

Adding new site details for a fresh WordPress website.

There's a lot to do here, and the setup time can hurt you, especially if you encounter an error. This is where our next method for how to install WordPress on localhost comes in.

2. A dedicated app

One of the more recent advancements in local WordPress development comes in the form of apps. These give you a nice Graphical User Interface (GUI) to look at, while looking to include almost everything you need under the hood.

The first app of this ilk - DesktopServer - is unfortunately no longer active. There are really only two alternatives: Flywheel's Local and Kinsta's DevKinsta. Both offer a similar set of features and functionality in that you have a minimal-click way to set up a full WordPress installation. This means you don't need to worry about dependencies, managing databases, email, or any other associated aspect.

Another benefit is that you can push your site from local to live as long as your server uses Flywheel or WPEngine (for Local) or Kinsta (for DevKinsta.) This can give you back even more time, and for this reason, a dedicated app will suit most users.

⚙️ Installing WordPress

We'll use Local as our app of choice here to show you how to install WordPress on localhost. At first, the interface will be blank, and there will often be a visible button to click to start the install process. For Local, there's a Plus icon in the bottom left-hand corner:

The Local app interface.

This begins a wizard that first asks you to either create a new site or use a "Blueprint." Consider these templates for sites you'll create on a regular basis:

Choosing a method to create a new site using Local.

Next, give your site a name…

Adding a site name for a new site within Local.

…then choose an environment for your site:

Choosing a server environment for a new site within Local.

For the majority of cases, the Preferred option is the best to use. The Custom tab lets you select the exact PHP version number, web server type, and database type for your installation. It helps to choose options similar to your own site.

From here, click to confirm, and Local will install WordPress for you.

3. Laravel Valet

The rest of this post will look at command line tools that you'll access using a Terminal application. Laravel Valet is a fantastic option that we'd recommend if you are comfortable with running commands. Think of it as a good balance between XAMPP and Local/DevKinsta, albeit without a GUI.

There are two big benefits with Valet. First, it's tiny and performant. Second, you can use dedicated domain names, rather than a string of IP addresses like XAMPP. However, one big drawback is that Valet is compatible with macOS only.

You'll also want to use the Homebrew package manager for that OS to install dependencies for Valet (such as PHP and Composer.) The official Valet documentation has the full instructions for this. You will also have to set up a database. MariaDB is straightforward and is something you can use with Homebrew. Once you're in, you can use the command create database <name> to add a new database.

⚙️ Installing WordPress

Most of the process to install WordPress using Valet involves shuttling around your directories. While you don't need to use the command line for these parts, it's more straightforward to do so. Regardless, there are three commands to use first:

mkdir websites
cd websites
valet park

This will set the websites directory as the Valet root folder. Next, create another directory within the Valet root folder and navigate into it using the command line. From here, use the following four commands to install WordPress on localhost:

git clone <folder-name>
cd <folder-name>
valet link <folder-name>
valet secure <folder-name>Code language: HTML, XML (xml)

In turn, this clones the official latest release of WordPress from its GitHub repository into a new directory, then enters into that directory. The valet link command serves the site to the "server," and the valet secure command adds encryption to the connection.

At this point, you can navigate to the <folder-name>.test domain and begin to install WordPress as per the instructions for XAMPP.

4. Varying Vagrant Vagrants

Finally, VVV is how to install WordPress on localhost for Windows. In fact, it's a command line app specifically for local WordPress installs that technically works for macOS too, but uses the VirtualBox virtual machine tool to create installations. Unfortunately, this doesn't work on current macOS versions, so you'd either need to opt for Valet or a different virtual machine alternative such as Parallels.

Along with XAMPP and its variants, VVV is also a recommended local development environment over at the Make WordPress website. The site provides full setup instructions.

You'll manage sites from a configuration file, so it's a good idea to copy this once you first launch VVV. To do so, enter the following on the command line:

cd vagrant-local
vagrant status

This navigates to your VVV root folder and copies the relevant file.

⚙️ Installing WordPress

At this point, open the config.yml file in a text editor, and add the following code to the sites section:

- mysite.testCode language: JavaScript (javascript)

Once you save your changes, stay within the vagrant-local folder, run the vagrant up command, and follow the instructions. This "provisions" your site and doesn't require you to run through the WordPress install process like the other tools. Once this completes, you can navigate to your new site and get to work!

Conclusion 🧐

To develop your WordPress website, you could install the platform on your live server and hack away. However, this can bring you a number of negatives that might impact the future of your site before it begins. Instead, it's better practice to learn how to install WordPress on localhost. The good news is there are lots of options to achieve this that don't relate to skill level or budget.

This post has looked at how to install WordPress on localhost. Depending on your goals, you have a number of different ways. An app such as DevKinsta or Local is ideal for the majority of use cases. If you have hosting accounts with Kinsta, WPEngine, or Flywheel, you'll be able to push your site live from there too. However, older tools such as XAMPP (and other variants) are just as solid - they wouldn't be in use if they weren't. It could be that command line apps such as Laravel Valet and VVV will work best for you too, if you have knowledge of how to get around your system using the command line.

Do you have any questions about how to install WordPress on localhost? If so, fire away in the comments section below!

Don’t forget to join our crash course on speeding up your WordPress site. Learn more below:

Yay! 🎉 You made it to the end of the article!
Tom Rankin

Inline Feedbacks
View all comments

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!

Would love your thoughts, please comment.x