 Thank you I was taking a look yesterday kind of who was who was here and so I've got some slides I want to go to but really what I wanted to talk about is getting into code so just bear with me these slides they're more just a general overview of WPCLI so does anybody know what WPCLI is? Is there anyone that doesn't? No I guess it's a better question for a couple people. So WPCLI is just a set of commands you can run on a command line so you actually command line into a box you SSH into a box we're going to be using varying vagrant vagrants today to go over that so these aren't scary so don't don't feel alarmed I think everybody in here is probably better than command line and they're pretty cool to do so so really quick just so you know what SSH is it's a connection from your local computer to some other device we're gonna simulate that just like laptop it's all explained that and it's secure so how do I SSH that's probably the most important question I get or how I get started is how do I SSH in so I'm on a Mac so you can use terminal or I turn here on windows you can use money and if you really want to be adventurous and do an iPhone you can use probably to read you so to get started with WPCLI you first have to install it you just go here there's great instructions there's a lot of posts though that already already create install them we we have a group already create install it so it's there ready to go running the command is as simple as running WP a command a sub-command and some sort of parameter after that so really that's thank you that's what this looks like is a program is required you have an optional flag and then sometimes the optional flags with value so the biggest one that I use WP core so so the core is you can do things like check the current version of wordpress you can see if there's updates available you can do the update you can install a brand new site you can even convert an existing site to multi-site then you can verify checks so if you're if you've gotten hacked you can verify the wordpress of the time also so some things that you can do with core as you can set up a brand new site and a development server these are the ways to get that started you run WP core download you then run config config and then you hit create just create the database and then install so it also has plugins the plug-ins you can install the delete plug-ins you can activate deactivate plug-ins you can update plug-ins and you can even search the repository these are probably the two biggest time savers WP plug-in update all so this will update all plugins that are available for updates and if you get a white screen in death or you have some weird issue that you think is plug-in related you can run WP plug-in deactivate dash dash all and that'll actually deactivate everything there's database commands so you can run WP DB export and then give it a filing not actually create a export of your database you can also import that database so you're moving migrating from server to server you can do that and if you want to get into actual the data gradient by SQL WP DB CLI would be two in there all right so enough of that let's go into the command everybody see that one here you went below and vagrant install and for vagrant when you're on a little computer to get into it it's just vagrant SSH and this will log you in typically you would have you know SSH your username an IP address or domain and then you'll have to put in your password so once I'm in here I can actually go into our WordPress directory so I'll do all right so this is so we can run some commands in here WP core for example will give you an output of the available sub commands you can do things like check update we run one we can see if there's an update available all right so you can see the success is the latest version that means there's no updates to do for this WordPress which is great where we don't run today so let's look at plugins a second we do plug-in lists we can see all the plugins that are are at least downloaded for this you can see that both of these are already happening so if I want to do activate Kismet I could do again I'll do help so you can see the commands so you'll see there's there's activate is the first one so plug-in activate and then we just type in the name so Kismet and it tells us that it's active so how do we use this to start an install what I do every time I install WordPress is I have this this bad script is not scary either you can download this what this actually allows you to do though is go through a common set of plugins so in this case I've actually pre-populated this with just whatever you plug-in that I have but we can run this on the environment so that we're able to get a little bit ahead of ourselves as we create any WordPress site so to run that so it is going to ask me for a bunch of information in this case that asking me to install if I want to install this plug-in so as I have a client that's working with this this site I know if I want to advertise I can say yes and it's going to go through and install it and the PHP notices because I'm using it's a bigger thing that usually doesn't come up so what did it do here it install first off the latest version it then download it and use the cash file so I've already used this once on this box so the nice thing about WPCLIs it's going to say hey I've already got this locally let's not go back out to the Internet to re-download it let's just use that cash version so I did that it then unpackaged unpack the package they installed the plug-in and then I if you go back here I actually just activate it because I don't want to have to download it and then activate it right so I did that now it's asking me to if I want to install members so I can say yes again and it'll install so it install that now I can keep going right this is just asking me if I say no it's gonna ask me if I want to install the next plug-in if I say yes it's been installed so it's gonna go through and I can keep going through all of my list of plugins I want to use on a reinstall this is pretty easy it's just a you know give it a question so would you like to install plugin X read the output of that file and then run this WPCLIC man is there any questions about this great yes is there like yes these are all these all we have to get up so I would make this go a little bit faster instead of having to ask if I want to install I'm gonna run the script again but this time I'm just gonna have it go install all these plugins I don't have to answer yes every time if it's already been installed to see the warning it was already I'm already installed those takes just a few minutes depending on how fast the internet is to show you that they're installed you can start to see that they're already activated as well pretty cool right I didn't do much work I installed plugins so that I'm now able to get this site up and going so is there questions about installing plug-in and activating the license key so certain plugins have actually right into WPCI so the minute it's activated you can run another command to do that I don't believe what I'm gonna do that but I think if you go to get help WPCI there's a list of third-party all right so I just beat that mean told me that everything was so you can see I've got all right so I'm gonna come back to plug-ins a second but let's actually run a backup this is this is kind of where from a managed hosting perspective you're gonna want to do so I'll walk through the script first and then come to it so this this is essentially all we need to do to do a backup so you'll notice I always echo out some commands I'm usually paying attention to what these run at least at first and also gives us an idea of what it's actually doing so this first date is actually just giving me today's date of through through bash I then export it database to SQL file I then tar up the entire directory including the SQL file and then I just move it to a backup folder I have on my server in a real-world scenario what I'm actually what I would do in this case is not just move it to backup folder on this server I'd actually have a mount somewhere else and that that way would be an awesome and then finally I remove that back so let's run this really quick just to show you that all right so this is gonna be quick so I put in a little sleep instance just a little change your phone color yellow or something yeah that's what I was just gonna switch it to I didn't change or is that better sorry all right so what are they about backups let's check my back up folder really quick all right so looks like it didn't do back up so we'll just run it again I actually think that now that I added this in here it's gonna delete the backup before it actually didn't let it save. Always great doing a demo, but let's just check it out. Yeah all right so we'll stop removing the backup first so once the script is fixed what this actually allows us to do is we can set this as a project and then every night it can run or every X amount of time it can run and you've got yourself backups all right so if we check this again hey maybe I'm just like no it's WWE there we go all right there we go so I apologize it's green backup it just gave us backup dash and today's date 3 20 2016 so you could you can tie this up anyway you want to you'll have to tie it up as a GSD you wanted to do it the same that way as well all right so that's backups now let's come back to plugins because maybe I don't need all these plugins anymore yeah so yeah so so most hosts that offer SSH access let me repeat the question for the video but the question was kind of around how you set the plugins so with with hosts digital ocean look web somebody that gives you SSH access you can usually just go into a tab with that user help and then you can set it up to run this script X amount of times daily nightly you know you could you could even modify the script so I did a full backup or maybe on what database backup or you just want to come to the backup you can easily modify lines 9 and 10 to be changed all right so I've got some plugins and maybe I need to deactivate some maybe there's an instance where hey this site is just running really slow so I can go in and say we'll do a plug-in list again this will show us all the plugins installed it'll also show us the status of them so I'm gonna deactivate a couple here you can also chain these together so I wanted to do multiple in one command I can do this I can do jetpack in stockbox so if I deactivate these it'll tell me that spits it out hey these were successfully deactivated if I run a plug-in list again we'll see these status and then one thing I didn't install with this is a theme so anyway on a theme we'll do WordPress directory that you like to use we'll do 2016 let me make sure it's done so that this one now remove it actually I'll do I'll do 2013 so here's what theme options are available we can activate the lead pretty similar to the way the plugins just work and we can search so remember we do search 20 I'll just search that way we're gonna get a list back for the word just our directory of all the plugins that have something related to 20 so we can see here's 2016 through 2012 so we'll go ahead and install 2012 it's important that we have this luck that's how it installs so if I copy that and do install we can check back here just to make sure it's installed they will notice I didn't activate it there was no activate so here's 2012 I can activate it right in here or I can go back to the WPCLI let me get rid of some of these lovely messages so that's themes I have to do one thing here so as a manage host or or as you're using WPCLI to run your own box you may go across the time where you want to just update plugins so I have a script that allows you to check a list for updated plugins that's this command right here and then ask you if you want update if you do then we can update all so let's show that all right so that what this is doing is it's querying our local plugins and looking for update available here and I can see that I have one that's updateable so if I click yes I go down it's gonna turn on maintenance mode and then it's gonna update and then we can see that I put in a paticious number and it actually updated to 3.18 so that's how you would update plugins. Unfortunately I can't show you how to do core because I don't have this box a WordPress that is not an old version but essentially it would just be right this is how we checked make sure there was update we would just change check update to update and we would then be able to update WordPress before we do that though it's probably good to run that backup script just so we have backup right so we can instead of just using a cron job you can actually manually back up. With update not automatically go ahead and reinstall the files even if it's the latest version say you've got hacked and there's a malicious node in there. Sure. Let's try it. When it already just go ahead. It might. We'll find out. It's a good question. I have not tried that. It tells us it's up to date. But that's probably the same success you would get. Anyway, it doesn't actually count a lot of the files because it's checking the version of WordPress. We could do because I know when we're back in there it's a reinstall files. Yeah. So I just figured that would do the same thing. Let me make sure I get the right one. So if we were hacked we could do verify and check sums and this would actually go back and check the files on our our install to the files that WordPress.org would deliver and we can see this line that it verified so we would know we're not hacked. If I were to go in and change the thing, I'll just see if this works. So it gave me a warning. Hey, this WPW I edited really quick. It didn't verify it because I threw some extra text in there. No, no, we'll do the update. So if we rerun the check sums then we should have probably changed the file. Yeah, it would usually spit back out if it was doubling again. I could do and there was already a file there so you have to manually go in. Alright, so we made that file better again. We should be able to check it and then it'll run fine. Okay, so there's also if I had a core update, it's a very similar script, right? It's just gonna run. It's gonna first check if there's an update, if there is, then you can run the update. So I have another script in here that is installed. So let's say you have a new client, you have a new customer and you want to actually run that install. This script is rather long. It asks for some information and it goes and creates the site and the folder on that. So we'll walk through that as we go and install it. Alright, so this is gonna walk us through just some more questions, right? So let's give it a database name. We can give it a username, give it a password. And then that actually goes in and creates the database. So our database is all set up and ready to go. Now we need to go down and install WordPress. Alright, so we give it a site name, the username, give it a password and what it's done at this point is just capture that data so that when we run, as we're ready to run this install, it's gonna go in and make all the changes. So if we say yes, it's gonna download, it's gonna create a config file, it's gonna install. This one also installs under score us, for those that were wanting that. I now need to give it a directory, which this was actually, this part is broken on Vagrant. It should have done this automatically. But what this is for is it's gonna go create the engine that's configing Vagrant. So this parking at me is just saying, hey, I can't do Vagrant, I can do a regular VPS. With that, I've barely done any work and I've got my site up and running. So you can see that WPCI, excuse me, is pretty handy to do a lot of that. And with a little bit of work, we can start to manage our own posts. I'll show you how to do updates, I'll show you how to do backups, I'll show you how to do installs. So we need to install a new server or a new site rather. And you can use those tools with a little bit of extra work to really get into posting your own server. So, amazing, I worked really well on Twitter's Agent Morris that's made it. So, thanks. Did you say you were going to clear up the... Yeah, I'll clear up Twitter with the GitHub reports for it. I think so. First, you can set up a box with CPL or WPCI. How do you do that? The biggest piece is to... With CPL and WHM, you'd want to somewhere put these scripts. So, get cloned into a folder. And you have to install it in a certain way so that it's usable on every other CPL on the U.S.S.H.G. Like you can put it in the user-slash-share folder. You could. And then you'd have the WHM share that folder out to each individual CPL user. Or run in this group. Yeah, part of mine actually requires me to run that as a group. That's why vagrant yelled at me. Is there a question over here? Is there a way to detect all WordPress installs throughout the server? Just do one. Yeah, so the way that WPCI would work is you have to be in the directory of a WordPress instance. So you wouldn't be able to... It wouldn't know until it's in there. You just need to spit out. If I go into this folder, I'm just in my W2W group. If I try to run a command, it's going to come back and basically tell the haters where it's not installed. But I think you'd rather run a fast script. You could run a fast script. Yeah, if you're going to go through it. And then it could call each... Yeah, yeah. Good point. Is there a question over here? No. Okay. Thank you.