Need Root-Level Tasks 0:00One of the best and probably most understated feature of Forge is that it essentially removes the need for you to SSH into your server to do anything. If you need to create a site, a scheduled job, a daemon, you can do it all within the Forge dashboard. However, what happens if we need to install additional software onto our server? Perhaps we want to install Elasticsearch, or Sockety, or MongoDB. In a previous video, we've looked at how you can use the site's commands panel and why you should use that for running one-off commands. But in this case, even that wouldn't be enough to install our software. That's because commands run as the site's user, which is typically Forge. Introducing Server Recipes 0:33But in this case, even that wouldn't be enough to install our software. That's because commands run as the site's user, which is typically Forge. Meaning we wouldn't have the sudo permissions needed to install software or create system services. Instead, we need to use recipes. If we think of deploy scripts and the commands panel as scripts to run on our site, recipes are scripts to run on the server. This means that we can run code as the root user, which would give us the necessary permission to install additional software or to make those system configuration file changes. Let's start by creating a really basic recipe to see how this works. Creating a WhoAmI Recipe 1:00to install additional software or to make those system configuration file changes. Let's start by creating a really basic recipe to see how this works. So we'll come down and create a new recipe with the name WhoAmI. We can then select the user, root or Forge, and Forge will always suggest any of the isolated usernames that we have on any of our servers. So now we'll keep it as root. And the script is just bash. So we're going to call it, I am WhoAmI, who are you? So here bash is going to evaluate this and give us the value that this comes back with, which will be the user who is logged in, which should be the root user.So here bash is going to evaluate this and give us the value that this comes back with, which will be the user who is logged in, which should be the root user. We'll come down and create this recipe. And then with that created, we will run it. And we don't need to email ourselves this one, but we do need to run it on this server. And now if we have multiple servers, we could run this recipe on all of those servers or just a handful of them. We'll run that. And then we need to come back to the dashboard and we can see that we have our recent events running recipe, WhoAmI. Running as Root vs Forge 2:04And then we need to come back to the dashboard and we can see that we have our recent events running recipe, WhoAmI. We'll see the output of this. I am root, who are you? Cool. So let's just go back to our recipes panel and change this recipe to run as the Forge user, save, run, and go back to the dashboard, running recipe the second time. And here we go. We have, I am Forge, who are you? So now that we can run code as the root user, we're able to install additional software. Installing Sockity via Recipe 2:41We have, I am Forge, who are you? So now that we can run code as the root user, we're able to install additional software. So in this case, we're going to install Sockity, which is a WebSocket service that is compatible with Laravel Echo. So we'll do npm install, and then globally the Sockity package from the Sockity namespace and create that. Now we will come and run this. We don't need to email ourselves. And now we can go back to the dashboard. So of course, depending on what it is that the recipe is doing, depends on how long these Using Shared Forge Recipes 3:14And now we can go back to the dashboard. So of course, depending on what it is that the recipe is doing, depends on how long these things will take. But if we give it a minute or two, Sockity should be installed and we should be able to view the output. And there we have it. Sockity has been installed on our server. And then finally, while we're on this page, you may have noticed the Forge recipe section. In this case, we have an update CA certificates recipe, and we can click into the details and see more information about what this recipe does.In this case, we have an update CA certificates recipe, and we can click into the details and see more information about what this recipe does. So this is a really powerful way for the Laravel team to create shared recipes that can fix common issues that we can run by ourselves.