DE{CODE}: Best Practices for Site Deployment With Local
While there’s no wrong way to take your sites live, this session walks through the various options for deploying your site from your local environment to your production environment.
Join Independent Instructor and Web Developer Carrie Dills as she looks at some Local workflow tools, and covers why you might choose one deployment method over another based on your team, workflow, and site details!
Session Slides
Full Text Transcript
CARRIE DILS: Hello. Welcome to site deployment best practices with Local. So as a professional web developer, you’re already familiar with the idea of developing sites on your local machine and then deploying them to the live server versus actually doing your development on a live server. When it comes to setting up that local development environment, there are tons of options. You’ve got MAMP or WAMP or XAMPP or DesktopServer.
There’s a lot of different tools you can use for that. My personal favorite is LocalWP. It is a free delivery– excuse me. It’s called Local, but it’s available at localwp.com. It’s a free development tool. It’s really pretty easy to set up and in addition to being a place for local site development, it also has some options for deploying your site life. But it’s got lots of other goodies too for your workflow, things like route SSH access, WPCLI, some cache busting built in, and even like a one-click SSL.
So if you already have this, then you’re ready to go. If not, that is OK. So before we even talk about ways to do a deployment, let’s back up the bus and talk about what is actually involved when it comes to migrating a WordPress site. So think of it as two things. You’ve got your files, and you’ve got your database. And when we talk about migrating a site, we’re simply talking about moving those two things over to a destination server. Got it?
All right. So if you were to crack open a WordPress install or maybe do a fresh download of WordPress and opened it up, what you would see are three main file– or excuse me, folders, WP Admin, WP Includes and WP Content, and a handful of files in that root directory. Now for the purposes of a migration, assuming your destination server already has WordPress installed, all you’re concerned about is that WP Contents folder. So that’s going to hold your themes, your plugins, and also any uploads that you’ve done through your WordPress admin. If you’ve uploaded media files, they’re going to be physically included in that WP Content folder as well.
So with that in mind, we’ve got files, we got database. Let’s check out our options for actually moving forward with migration. All right. If you will join me in your time machine, which I’m sure you have sitting right by wherever you’re watching this. Go ahead, hop in that time machine, and we’re going to go way, way back to something called FTP or file transfer protocol. I’m asking you– I am urging you, please don’t ever use FT–
[LAUGHTER]
–FTP. If you must, at least go to SFTP or secure file transfer protocol, which adds a layer of security over that file movement process. Or you may be with the host that has cPanel, which functions kind of the same. It’s a file browser, and you’re moving files back and forth between your local server and your live server. So that’s for taking care of the files. And you’re like, wait, Carrie. I remember you just said you got a database to move too. And I appreciate you remembering that.
So when it comes to the database, this might feel a little bit intimidating if you’re not used to poking around a MySQL database. And, basically, the process is you’re going to export your local database as a gzip file. You’re going to download that, and then in your database manager that lives on your production server, you’re going to import that database.
[SCREECHING SOUND]
It works, it works. It gets the job done. But you’re probably going to need to use a plug-in like Better Search and Replace to replace all of those development URLs with your live URL. So just keep that in mind.
Next up, we have got migration plug-ins. We have officially moved into the future and are finding easier ways to move sites from local to live. So when it comes to migration plug-ins there are a ton of them in the WordPress plugin repository. Some of my favorite, All-In-One Migration, Duplicater, and WP Migrate DB.
Now when it comes to these, these are going to give you a different sort of assist. So versus that completely manual process that we were looking at with cPanel or SFTP. These are going to do some nice things like when it prepares your database, it’s going to go ahead and help you with that URL– local to live URL swap. And it’s going to package up your files for you, but you’re still going to have to do something with those files on the receiving end. And each of these plug-ins operates in a little bit different way, but they will assist you with the process of going local to live.
Now I would be remiss here if I didn’t mention my absolute favorite plug-in for this, which is Migrate DB Pro. This is created by Brad Touesnard and his team over at Delicious Brains. And what this plugin does, it’s actually a wholesale deployment plug-in. So it’s going to take your files, your database, let you get real granular on which tables that you want to move, and then push those to your live environment. Now because it is an amazing tool, it does– you would have to pull out your wallet to use it. But it is a huge time saver.
But you may be thinking, Carrie, I thought we were talking about Local. And we are talking about Local. We used to have to back up, look at what was involved with the migration process, and then have some ideas of ways that you can migrate a site. Now WP Migrate DB Pro is amazing. But when it comes to Local, you also get that local development environment. But wait, there’s more. You get something called Local Connect and Magic Sync, which is that ability to do a one-push deploy from your local to live. And it actually lets you go the other direction too, if you want to pull. But we’re focusing on the deployment for this.
The only hitch in the get along is that Local Connect works with two web hosts, Flywheel and WP Engine. Now I know a lot of you watching this may already have those accounts. That’s awesome. If you don’t, never fear, there are a couple of free ways to try those out.
So Flywheel, you could create a new demo site, spin that up, use it to play with Local Connect. And then, similarly, with WP Engine, you can create a free partner program account that comes with a site that you can connect with Local.
OK. You all ready for a demo? I heard a resounding yes. So I’m going to March forward with the demo. Of course, what could possibly go wrong?
[CHUCKLES]
OK. So when it comes to the deployment process, you have to have a site to deploy to. So here I am in my WP Engine account area. I’m creating a local site, and I say this is a staging environment. And we’ll go ahead and add that. Now heading back over to Local, first, I need to connect Local to my host, in this case, WP Engine.
I’m going to log in, and it gives me some links there. I’m going to go visit this top link. That pops me back over to my WP Engine account, and there I can generate my credentials. So this gives me an API username and password. Let me go ahead and copy that, head over to Local, paste that, and do the same for the password. And now we’re in the process of connecting to WP Engine. And what you see here is a list of all sites that I have hosted on WP Engine that are now available to me and Local. And note that I can pull these directly down to Local. But, again, we’re talking about the other direction here.
OK, so you with me so far? We’ve created a site on our host that we’re going to send our local site to, and we’ve also connected the Local tool to WP Engine. All right, moving forward. Now it’s time to actually check out the site that I’ve got developed locally and it’s pretty darn boring, but I just want you to see what it is so that we have context for when we send it upstream.
So first, I’m going to connect this particular site to WP Engine. And then with a single click, boop. It’s just going to say which site do you want to send it to, and I’m going to select that local demo site that I just created. And you can also push directly to staging, production, or development. And now in this case, I’m doing staging. And you can optionally include whether or not you want to send the database along. Here’s a pro tip. When I’m developing locally, sometimes I get really lazy and use terrible username and passwords. Remember, when you’re pushing this to a live server, you want to be sure that you’re using a secure username and password, even if it’s not your production environment.
OK. So we’ve started the process of pushing. That involves uploading the files. We talked about moving files
And then we’re going to go and upload that database, since we selected database in our options. It must have been in big database.
[LAUGHTER]
Now it’s doing that URL search and replace that we mentioned, and it’s checking the database table prefix to make sure that it’s a match between local and live. So through that deployment process, and I can even see at the bottom of the screen there how long since my last deployment. So let’s head back over to my WP Engine account. I’m going to go open up that site that I just pushed. And if we visit it, there you can see it is the site that we just had local. Again, it’s not anything super special, but there it is. And just to show you about the URL situation, there you can see that it did update to the live URL. So pretty cool.
All right. Still with me? Recapping, so far we’ve taken a live site– or excuse me, a local site that we’ve developed locally. We’ve created a site on the destination server. We’ve connected local to our WP Engine account and also connected the specific site to WP Engine. And then, voila, with a push of a button, it does the whole thing. It’s replacing the URLs. It’s busting the cache. It’s also doing backups during the process just in case anything goes sideways. So deploying with local is– it’s so ridiculously easy. The first time I saw it, I was sold.
Now in case you’re not suitably impressed– I hope you are. But in case you’re not, now I want to introduce you to something called MagicSync. Now MagicSync is a viewer where you get sort of a two-pane window where you can see what the files are on your local site and compare them to the files on the destination site and be real specific about which files you want to deploy. Let’s take a look.
OK. So here I am back in Local. And if I go to Local Preferences, there is a button that I can toggle for MagicSync. And turn that on, and just go ahead and apply. OK, now I need to create– or add something to my existing Local site so that I can show you how MagicSync works. And I’m going to do that by adding a theme to my Local WordPress install. And we’ll just go with 2021.
It doesn’t matter. Again, just showing you an example of how this works. So no need to activate. So heading back to Local, I’m going to click Push again. And this time, you’ll notice– woo, there it is, that MagicSync window. And if we scroll down, there it is, that 2021 theme. We can see that it’s present in the file directory locally and that if we were to push it that it would be added to that remote environment.
We also can see things that will be deleted if we were to push this and what that means is that the file exists both locally and remote. So with MagicSync, you can get really granular, again, about which files that you want to push up. Now you don’t have to use MagicSync. You could just do a wholesale push of everything, which is one way to do it. It just takes a little bit longer than if you’re using MagicSync to only send the files over that you specify.
So heading back to WP Engine. Let’s look at the live site. And if I go to themes, there I can see it. That 2021 theme is there. That’s so cool. OK, so that is how MagicSync works in a nutshell. So again, you could use MagicSync as part of the deployment process or just stick with Local Push and that works– that works beautifully as well too. So I’m hoping that you have enjoyed seeing how easy it is to do this.
Now if you run into problems when you’re doing any of this, Local has a really fantastic community support forums. And they’re super active. So if you ask questions, you will get answers in there. And shout out to Clay Griffith, who’s actually the original creator of Local. And he’s also– you’ll see him around the forums too.
Now if you are a paying WP Engine or Flywheel customer, you actually get dedicated support for Local and Local Connect, which is really, really cool. And both of those hosts, I know from experience, have amazing support teams.
OK, so let’s recap. When it comes to migrations, what’s that first option? Right, SFTP or cPanel along with a manual database, Migration. So you’re going to export it, and then you’ve got to import it. So this would be the most manual way of doing a deployment. Next up, we’ve got Migration plug-ins, and then some database helpers that do things like that search and replace on the URL, things that can check our WordPress database table prefixes.
So it’s better– way improved over the old SFTP model, but it’s still not 100% one click of a button. Which, of course, leaves that last one, Local Connect and MagicSync to get your files and your database up to the server and I bet you can tell which one is my favorite tool.
So if you want to go ahead and get started, I would love to invite you to download Local from localwp.com if you haven’t done that already and Local Connect is a totally free feature to use. Just keep in mind that it only works with Flywheel or WP Engine. And there are a couple of ways to try out either one of those hosts, just to play around with Connect and get a feel for how it goes.
All right. So with that, I would love to thank you for your time and attention, and I wish you many happy deployments.