When developing a WordPress theme or plugin, it’s useful to have an installation of WordPress on your computer. AMP stacks are very popular for local development, apps like XAMPP or MAMP, WAMP etc, will give you a local server environment where you can install WordPress just like you would on a normal hosting server.
In this guide we’re going to take a look at a tool that makes this procedure much easier.
Local by Flywheel
Local by Flywheel is a Docker based tool built to take all the fuss out of creating local WordPress installations. It’s designed to help you create new, independent, local WordPress installations with just a few clicks.
The app is currently available for MacOS and Windows, and can be downloaded from this URL.
Once you download the installer, you will need to run it. You will be presented with a screen similar to this one:
The setup wizard will guide you through the installation and configuration of the required components. The steps here include installing VirtualBox, creating a host machine and downloading the required virtual machine image. Most things are completely automated, what you might have to do is approve a few changes if you need to install VirtualBox.
After the installation is completed, you will be presented with the application’s main screen.
There are two tabs available on the top left hand side of the window, Sites and Settings. Let’s start by checking out the settings.
The starting section allows us to configure the default environment for our sites. You can select your preferred PHP version from the five available ones in the drop down. Similarly, you can choose between MySQL 5.5 or 5.6, and between Apache and nginx. You can also set a default administrator username, password, and email so you won’t have to input them on each site separately. Finally, you can modify the default path where the sites will be stored on your computer.
From the settings tab you can also export an existing site, and create blueprints for later usage. Finally, the add-ons section allows you to activate any available add-ons, such as live links or Xdebug IntelliJ integration, which come pre-installed.
Creating a new site
Now let’s go back to the Sites tab and click the Add Site button.
To create a new site first we need to fill in the site’s name, its domain and the path where all the related files will be stored.
Next in the environment section we need to select the PHP & MySQL versions we want to run and our web server, of course this is optional, you can just proceed by using the defaults we set up in the previous step.
Finally, we need to configure WordPress. We can select between a normal or a multisite installation, and set the administrator’s information (again this is optional if we have set defaults).
Once done, just click the Add Site button. Just after this you will be prompted to allow the program to edit your hosts file, this is normal and it’s required in order for the custom domain to work.
The next screen will inform you on the site’s creation progress, which will only take a few minutes.
When the site is created you will see the screen above which provides you with all related information. There are links to get you to the site itself or directly to the administration area (View Site and Admin respectively), you can also switch PHP’s version and the web server very easily. Under the Database tab on the top right you will find a link to connect to the site’s database using Adminer. Another useful tool can be found under the Utilities tab is called Live Link. By enabling it you will create a secure tunnel to your localhost using ngrok, this allows you to share the link with clients or other developers so they can check out your site.
Good to go!
That was it, pretty simple right? You can now visit your custom domain on the browser of your choice and start working on your new local WordPress installation.