Table of Contents
Last update on
Setting up a localhost environment for WordPress so it can run on your computer can save you loads of time. For one thing, you can test WordPress updates, plugins and themes to make sure they’re a-okay before pushing changes to your live site. You can learn WordPress development. You can even work on your site offline, or while traveling and don’t have wifi.
Best of all, you can tinker with your site without fear of breaking your live site and impacting your site visitors. And fortunately, setting up WordPress locally only takes a few minutes thanks to the many fantastic solutions that have been released in recent years.
In this post, we’ll explore what a localhost environment is, why it’s worth setting one up, and we’ll look at the top options available for WordPress. Then I’ll step you through how to set up by Local by Flywheel, my favorite solution for setting up WordPress locally.
What is a Localhost Environment?
In computer networking, “localhost” refers to the computer that a program is running on. For example, if you’re running a program such as a browser on your computer, then your computer is considered to be the “localhost.”
In the context of running WordPress “locally,” setting up a localhost environment means creating a server-like environment on your computer that allows you to run WordPress. Because the thing is, you can’t just install WordPress on your computer like an executable file — it needs a server environment that can power PHP and MySQL for your local site’s database.
This is where local server environment software comes in. Popular solutions like DesktopServer, Local by Flywheel, and Vagrant — which we’ll explore in more detail below — let you create a localhost environment on your computer that can support web server software like Apache or NGINX, on top of which you can then install WordPress.
Why Set Up WordPress Locally?
When you’re starting out with WordPress, it’s easy to make changes directly to your live site. But over time, as your site grows and becomes more complex (i.e., you might add WooCommerce and start selling products), updating your live site leaves you open to all kinds of things going wrong.
Setting up WordPress locally on your computer ensures you have a second copy of your site — aka a staging version — which you can use as a testing ground before making changes to your live site.
Setting up WordPress locally on your computer comes with many other advantages:
- If you’re a digital nomad or travel often, you’ll be able to access your website without needing wifi.
- Manipulating files and making changes locally is faster when files don’t have to travel to a remote server.
- You can learn WordPress development on your computer.
- It’s cheaper — no need to buy web hosting or a domain.
Personally, running a localhost environment has become invaluable to my workflow, particularly as I regularly test themes and plugins for blog posts. With a localhost environment set up on my computer, I can quickly spin up a new WordPress install faster — and cheaper — than it takes to make a cup of coffee.
Top 3 Localhost Solutions for WordPress
Over the years, I’ve tried and tested lots of localhost solutions. But the thing is, I’m impatient. I’d rather spend my time designing and developing sites than wasting time installing Visual C++ libraries (I’m looking at you, WampServer), trying to fix firewalls and interpret confusing and frustrating error messages (grr…. XAMPP…) or messing around with setting up databases (thanks for nothing, MAMP).
So while I’d encourage you to check out WampServer, MAMP and XAMPP if you’re interested in testing localhost technologies for yourself, there are three solutions I recommend wholeheartedly: DesktopServer, Local By Flywheel, and Vagrant.
DesktopServer, by the folks at ServerPress, lets you quickly and easily set up multiple WordPress sites on your computer in under 5 minutes (trust me, I timed it!).
If you’re new to DesktopServer, start with the free version. After signing up for an account and downloading the software (it’s 197 MB), a set-up wizard takes you thought the installation process. Once DesktopServer is installed on your computer, you can set up your first WordPress site.
Whenever you need to set up a new WordPress install, just fire up DesktopServer and choose the option to create a new development website. It will do its work in the background and then provide a localhost URL where you can finish setting up your WordPress site.
I’m a big fan of DesktopServer. I’ve been using it for many years and it’s not only super easy to set up, but it’s never failed me the way other localhost solutions have. DesktopServer just works.
Key features include:
- The wizard makes it simple to set up a new WordPress install in about 1 minute.
- Cross-platform support for macOS and Windows.
- Save blueprints, aka website configurations, you frequently use so you can quickly set up new WordPress sites quickly.
- Supports Multisite.
While the free version of DesktopServer offers limited features, for $99 the premium version offers more powerful features, including the ability to create unlimited websites and updates.
It’s also worth mentioning that DesktopServer provides an optimized AMP stack (Apache, MySQL and PHP). So if you want a solution that supports NGINX, read on.
2. Local By Flywheel
Local by Flywheel is a localhost solution that has quickly gained in popularity thanks to its user-friendly interface. Compared to other localhost solutions, Local by Flywheel is a breath of fresh air!
While tools like XAMPP and Vagrant are powerful, giving you more control over your local server environment, they’re not exactly easy to use if you don’t have a development background. Local by Flywheel, meanwhile, is perfect for beginners and developers alike working on small to medium website projects.
Local by Flywheel is free to download, but you’ll need to sign up for an account and choose whether you want to use it for macOS or Windows. You’ll then need to download the software, which is 550 MB.
Setting up a new WordPress website is as easy as clicking through a wizard. During setup, you can choose the default setup (PHP 7.2.9, NGINX + Varnish, and MySQL 5.7 at the time of writing), or set up a custom install with your choice of PHP version, web server (NGINX or Apache), and version of MySQL.
Key features include:
- Create a new WordPress install in just a few clicks.
- Cross-platform support for macOS and Windows.
- Set up “blueprints” so you can quickly deploy new sites using frequently used configurations.
- Set up custom configurations using your choice of PHP and MySQL versions, and Apache or NGINX — and can hot-swap once you’re up and running without impacting your site.
- Access to SSH and WP-CLI.
- Supports Multisite.
Local by Flywheel is completely free and you can set up unlimited sites (as far as I can tell — I haven’t seen any information contrary to this!).
So far we’ve looked at options that are great for WordPress implementers and those working on small to medium websites. But what about large sites, or developers who need flexibility and portability?
Vagrant lets you create and configure lightweight, reproducible, and portable development environments — i.e. virtual machines — which you can use as local server environments. It’s ideal for developers who want full control over their localhost environment since you can control every aspect of it, more so than solutions like XAMPP or MAMP.
Setting up Vagrant only takes a couple of minutes. After downloading and installing VirtualBox and Vagrant, you can then download one of the many pre-configured “boxes” shared by the Vagrant community. I recommended VCCW, a Vagrant configuration for WordPress plugin, theme, and website development.
As developer Daniel Pataki highlights in his excellent Vagrant explainer on the WPMU DEV blog:
Since Vagrant uses virtual machines you can download boxes which mimic popular web hosts completely, thus resulting in a near identical local and production environment.
How cool is that?
In addition to its flexibility, Vagrant is also portable, which is important when you’re working in teams or working from different locations. The Vagrantfile and install files are all you need for a complete server configuration, with both files typically less than 1 KB each.
Key features include:
- Set up virtual machines for local development.
- Flexible and portable — configure virtual machines and share them with your team.
- Download pre-configured boxes created by the Vagrant community.
- Use the command line to manage your virtual machines.
- Cross-platform support macOS, Windows, Linux and more.
Vagrant is free and open source. If you’re a developer who’s frustrated by web server software with limited functionality, or you just want something you can use via the command line, Vagrant is well worth trying out.
How to Set up WordPress Locally with Local By Flywheel
Local by Flywheel has become my software of choice when it comes to setting up WordPress locally, mostly due to the options it provides for creating custom installs. But I’ll also admit, I love how easy it is to use and the interface makes setting up new WordPress installs less of a chore!
To set up Local by Flywheel, first you need to download and install the software.
A pop-up will display, asking you to choose your platform (Mac or Windows). Fill out the form with your details and click “Get it now!”
Once the download is finished, install it. And when it’s done, open Local by Flywheel on your computer.
Initially, you’ll be prompted to set up a VirtualBox and Host Machine, which Local by Flywheel will go ahead and do for you when you click “Let’s go!”
And that’s it, Local by Flywheel is ready to go!
Now it’s time to create your first WordPress site. Click the green “Create a new site” button to get started.
The software will prompt you to give your install a name, and then choose the type of environment you want to set up. If you go with the default, it will set up web server environment using the latest versions of PHP and MySQL along with NGINX + Varnish.
If you go with the custom option, you can configure these settings, right down to the versions of PHP and MySQL you want to use, and you can also switch to using Apache.
When you click “Continue,” Local by Flywheel will go about setting up your new WordPress install before displaying the details of the backend of your local site.
When you click “Admin” in the top right, you’ll be taken to the WordPress admin for your site. Clicking “Stop site” will turn off the web server and you’ll no longer be able to access your site.
And now you’re ready to use Local by Flywheel on your computer! Now that you’re set up, you can create new sites, and clone, export and save configurations as blueprints.
Creating a localhost environment provides an easy way to run WordPress without the need for web hosting, allowing you to quickly spin up new sites for testing and development offline.
DesktopServer, Local by Flywheel and Vagrant are all fantastic options for creating a localhost environment. Each has its pros and cons, and I recommend trying out all three before settling on the software that best suits you and your development workflow.