Haven't heard of Local by Flywheel? It's a web development tool for managing server environments that was designed to be used with Wordpress, but can easily be used for Craft, ExpressionEngine, Processwire or any Content Management System (CMS).
So why should you use it? In my case, I've been using MAMP Pro for a long time but have been finding that any sites running on it are very slow. I'm not sure whether that's a problem with the app itself or it could just be my own individual set-up. But I also find that it crashes quite often, which isn't harmful, it doesn't do anything to my local sites, but it is inconvenient having to restart it more than once when making changes.
So a while back I went looking for alternatives and I came across Local by Flywheel.
Local is powered by Docker which means your local environment can exactly match that of your live server. It's easy to switch between NGINX and Apache, and change versions of PHP and MySQL. Creating local SSL support is also simple. And it's got a nice, friendly interface to guide you through the process too.
I'm still running MAMP because I have a lot of older sites set up with it that I haven't bothered to set up again with Local (yet) but I'm finding the sites running on Local to be more responsive, less laggy, than the ones running on MAMP.
So enough of the sales pitch, Local is great, how do we go about it?
After you've installed Local, you'll be ready to create your first site. You'll start by giving it a name, domain and specifying the location (it can be anywhere on your computer you like).
You'll notice the dropdown that says
Create site from Blueprint?; at the end of the process when you've set up your site and have everything just the way you want it, and would want to use the exact same set-up for other sites, you'll be able to save it as a blueprint and will be able to skip some of the steps that are to follow. A blueprint is essentially a boilerplate but it will also include the database of the site you're setting up, so it will be worthwhile logging into the CMS once you're done copying and moving files and performing whatever default set up tasks you normally carry out so that these can all be easily duplicated when you're creating new sites from the blueprint.
Next you'll choose set up the environment and you can choose either the preferred Local environment, or you can set up your own custom one, choosing from different versions of PHP and MySQL and either Apache or NGINX.
The last step asks you to set up Wordpress which is basically just creating an admin user. After Local has finished installing Wordpress you're going to remove all the files and the tables from the database but keep the database itself, so it doesn't really matter what you specify here.
When Local has finished installing Wordpress, you should see something like this:
Clicking through the other tabs
- you can see all the information you need for connecting to the database with buttons which will open the database in either Sequel Pro or Adminer (not sure if it's possible to configure Local to work with other database management apps)
- there's a button to create a local SSL certificate
- and under Utilities there's a button to open MailHog which I haven't actually gotten around to using yet
After installation is complete, your directory structure will look like this:
Before moving on, you'll notice that the public folder is called
public, but you can rename it to anything you like to mirror your production server. To do that, you'll need to edit the
000-default.conf file which you can find in the
/conf/sites-enabled folder. Before editing the file, stop the site in Local and then restart it again afterwards.
Remove Wordpress and install your own CMS
At the completion of the Local installation process, you'll have a default Wordpress site working. If you do Wordpress development, then you can stop reading here.
If you want to use Local with a different CMS, then your next steps will be:
- remove all the Wordpress files from the public folder
- remove all the tables from the database
- copy the files from your chosen CMS into the public folder
- run the installer for the new CMS, or if you've already got a boilerplate instance working elsewhere, you could just import the database
I always like to refresh my boilerplates periodically so running a fresh install and reviewing all the default settings you usually establish might be a good idea now.
If you're already happy with the boilerplate you have, copy all the files and import the database and you're done… nearly. There's one more thing you can do to make the process quicker and simpler in the future.
Create a blueprint
A blueprint is essentially Local's own form of boilerplate. To create one, you right click on the name of the site in the list and then choose Save as blueprint. The next time you create a site, at the first step you'll be able to choose a blueprint which means you won't need to do any file deletion or copying or importing of databases, the new site will be an exact copy of the state of the site at the point you saved the blueprint.
The only small problem with blueprints is that you can't update them, you have to delete and then save a new one.
And that's it! That's all there is to it. You can now get on to the most important, the actual development of the site.