 As I mentioned in last week's video, I quickly went over three different options for lightweight web browsers. Obviously, there are fuller ones out there such as Apache and others, but if you want a quick and simple setup for a web server with software that is probably already installed on your system, there are a few options. Today, we're going to be looking at Busybox's HTTPD. Again, Busybox is a shell environment that has a bunch of tools already built into it and it's on many systems and especially lighter weight systems. Last week, I said it's on pretty much every system and then this week I went to do a tutorial using a Raspberry Pi as a setup and I go to use it and Busybox is not installed, although it's in the repositories, so forgive me for that little thing I said that wasn't really true, but it will be on most systems and again, especially lightweight systems, which is probably what you're going to be using this on if you're going to use it. I am logged into a Raspberry Pi here running Raspbian, besides installing Vim in Busybox, it's the default install and I'm just SSH'd into it, so let's go ahead and start setting up a little web server. Now you can use any folder you want, I'm in the home directory for the user Pi right now. I'm going to make directory for all my web stuff, so I'm just going to create directory, call it www but you can call it whatever you'd like and I'll move into that directory and I will use Vim or whatever text area you like. I'll create a index.html file and we'll create an extremely simple hello world file and we will save that. Now we can use Busybox, let's real quick, as I said I installed Busybox using the command sudo aptitude install busybox if I could type today. That's the command, I already have it installed but if you didn't it takes like 10 or 15 seconds for it to download and install it, so I'm just going to kill that because I already have it installed. I'll clear the screen here and now that we have it installed let's check it out because Busybox can be compiled with different components but if you have full version of Busybox it's going to have a lot of tools in it and if you just type Busybox it gives you all that information and you can see all these tools built into it and they're alphabetical so if we looked at h right here we have httpd so if you have that you're good to go, we can now set our web server, I can just type in Busybox httpd and that's the command for that server and let's tell it, well by default it's going to use the current directory and the current user and port 80 if I go to do that right now it's going to give me a permission denied and that's because most systems won't allow a regular user to use port 80 now there's ways around this you know giving different users permission to use that but for this I'm just going to set up a different port so I'm going to type in the same thing busybox httpd I'm going to do stash dash p and I'm just going to use a higher port I'll just use 8080 I'll hit enter and our web server is now up and running on port 8080 if I do if config I can see that the IP address for this server is 192.168.1.115 so if I go to my web browser and I type in that IP address along with colon 8080 or whatever port you choose you're good to go you can hit enter if you have it running on port 80 you don't have to tell your web browser what port it is so I'll hit enter there right away it says hello world because it knows that there's an index file in there and it uses that index now if we were to rename or move that index file to well to say my.html it still exists but if we go up here and refresh it says file not found so take into account as I said last week by default httpd is not going to create a directory index for you although you can do that with scripting which is something we'll get into possibly in the future but it will automatically look for an index or you can tell it forward slash and the name of the file my.html there it is so either use an index to point to different files or you give it the full URL and that's the same with pretty much all web servers unless you have it set up to give you a direct index now how do we kill our server you notice that it's no longer running in the shell down here let me bring this up like this it's by default busybox's httpd gets thrown into the background as a daemon so it's running as a background process if you type in ps ux and hit enter you can see right here that it's running so I can grab its PID its process ID and just type in kill and its process ID and now it's killed if I go back to my web browser here and I try refreshing it's going to tell me that the web page is not available because the server is turned off so that's one way that's you know the the basic basic functionality of this you know all we did the only thing out of the defaults is that we changed the port so let's give it another option here and let's do dash F and enter what this does is it prevents it from going into the background as you can see we can no longer use the shell here because it's running so I can go back to our web browser and hit F5 to refresh and there we go we have our hello world file so I will now come back down here and since it's running in this shell I can hit control C to kill it and hit F5 up here and you can see now it's gone because I killed it down there so by default it's going to go into the background and let's use the dash F option which will keep it in the foreground F for foreground and and that in that case you can just use control C to kill it now another benefit of using the foreground is you can also add to that dash V which gives it the verbose motor I always have trouble saying that basically it gives you a lot more output so hit enter and now if I hit F5 up here you can see it tells me that we were connected it tells what computer connected so the server is ends in 115 but it's saying here that the computer at 192.168.1.150 is connecting and by default you can see here it responses 200.200 means good output so I mean that it served up the webpage okay so every time I hit F5 up here it's going to give us a little bit of output there you also notice it's giving a port number here even though we're connecting to the server on port 8080 there's other interactions with other ports going on here basically where it's returning stuff to not going to get into that too much just know that 200 means it's served up okay 400 I forget what that means but we all know what a 404 is if I was to type in the name of a URL that does not exist and hit enter you can see we get a 404 here so you are getting some sort of output with that verbose turned on so you can see real time if there's any problems it's good for troubleshooting again since we're in the foreground here I can come back down here and hit control C and if I come back up here and hit F5 instead of getting a 404 we're gonna get this web page is not available because the server is down one more thing I'd like to go over today and we are gonna go over more stuff with HTTP in the coming weeks is that as I said by default it uses whatever directory you are in so we want to be able to tell it what folder to use sometimes in cases where we're not necessarily in that folder because if I was to go back to my home directory here and run that command well now it's running in that directory and if I try up here you can see I'm getting a file not found for that but I'm also getting a file not found for my my HTML because it's no longer looking in the proper directory so how can we tell it to use a certain directory regardless of where we are when we start busy box well hit control C to kill our server there we can do is we do dash H and we can tell it well I want you to always run this folder here and give it whatever folder you want so you can be in any directory on the system run this and it will always this is the root directory for your web servers and come back up here hit F5 and there's our hello world so now let's these are just some very basic options we got over today and the three servers we're going to be looking at in the coming weeks busy boxes HTTPD is my favorite by far although there are some other benefits of some of the other options out there but there's a lot more to this and it's a nice little lightweight tool that again you probably already have installed on your system if not you will be able to install it and again a lot of devices routers phones and things such as that nature probably have a version of busy box on it and even if they don't have the HTTPD version in there you can always compile your own and replace the one that's on that system allowing you to run a basic web server on pretty much any device as long as you can you know get a shell and root access preferably if in case you need to do some advanced stuff so again let's review busy box HTTP be HTTPD and then whatever ports you want you need special permission if you want just use port 80 which is the default web server port dash F is foreground you can also do dash V along with that for verbose mode and dash H is for your home or the root directory of the web server so whatever you put after that will be the root directory for the web server and that's it I hope you enjoyed the tutorial I hope you subscribe check out the video next week if you like this topic be sure to give the video a like that helps me out and also allows me to know what you guys are enjoying and oh as always share the video I would appreciate that and please visit filmsbychrist.com that's Chris of the K there should be a link in the description to that and it's as always I hope that you have a great day if you enjoyed my tutorials and would like to see more please think about contributing to my patreon account at patreon.com forward slash metal x 1000