 Hi, I'm Denji. And in today's episode of my self hosting series, we're going to take a look at how you can install your very own peer tube instance. Before I begin with the tutorial, I'll just explain what peer tube is. Peer tube is your own self hosted, federated and decentralized version of YouTube. I'll explain what that means. Well, you know what self hosted means. It means that you run it off either your own hardware or a VPS or something like that. And then you can access your own website by your own domain, which you should have if you're going to be doing this. You should have a domain and you can watch your own videos. You can upload them. You can like them. You can comment them. You can do everything you can do on YouTube differences is that this is, you know, self hosted, which means, you know, there's no real rules as to what you can upload within the realms of legality, of course. And there's also the features of federation and decentralization. Whenever I watch a video on peer tube, so clicking on just any video of mine, I connect to peers. As you can see here, I only have one peer that being the server I'm currently watching this video off. And if more people were to watch this video, so as you can see in his five views, if those people were online, then I would have multiple peers to connect to. It's the same thing as BitTorrent, where when people download a file, they begin seeding it, which means that when I download the same file, I begin downloading it for multiple people who are seeding it at that moment. This works in the same way. So if there's multiple people online at the moment with that peer tube data, then I can connect to them and the video loads faster. In this sense, peer tube is more bandwidth efficient. The more people watch the video, which is a very good thing because normally with these self-hosted video sites, there's a lot of bandwidth usage. The federation feature of peer tube essentially lets any instances that follow you have your videos show up on them. And if you were to follow any other instances, then their videos would begin showing up on yours. For example, if I were to follow Luke Smith's peer tube over here by copying his domain address and putting it here in my follow domain, then I would send a request to follow him. Soon enough, Luke Smith's videos will start showing up on my instance. But anyways, that was a demonstration of how peer tube actually works. Now let's take a look at how we can install it on our own server. So I've got Debian Buster over here, that's Debian version 10, and we're going to go over to the anyOS recommended guide. Now, before we do any of these things, we want to go to the dependencies guide first, install all the dependencies over here. So we're going to skip the Debian Ubuntu derivative section, which is right here. And the first thing we're going to want to do is install these packages. And these are already installed on my system. But if you want to install them, run this command as root, then there's a tip over here to disable root access and do the rest of the entire tutorial as a user without root access, which is what I'm doing, which is what I'm doing right now. I'm sending this Alex, which is a user that has root privileges, but does not have direct root access. The next thing we're going to want to do is install Node.js 12, which you can install by clicking on this button over here, then just go to Node.js, binary distributions. This will be linked in the description, so you don't have to do any of that. Scroll down all the way until you reach a section that says Node.js version 12.x and go to the Debian section because we are Debian and copy paste these two commands and run it as root. So we're going to want to change to root just like that and then run those two commands and just give it a second. As you can see, it's now installed. And if you run the Node command, you'll see that, well, Node works. So Node.js version 12 is now installed. We can exit the root user and close this entire thing. And now instead, we're going to want to install yarn. So you're going to want to just click over here and there's a command you can run that being MPM install dash dash global yarn. You want to run this as a super user. So sudo MPM install dash dash global yarn. And then it will install yarn, which is the build system for Node. All right, now we're just going to want to install a bunch of packages. And for this, you can essentially just copy paste the command and run it just like that. But I'm not going to do this because I already have all these dependencies installed my system. Once you've installed all those dependencies, the two things you have to pay attention to are Redis and PostgreSQL. So these are two packages you'll be installing here. PostgreSQL and a Redis server. These two run as daemons in the background, which means you have to start them right now. And by default, when you install any daemons on Debian, it automatically enables them on boot anyway. So we're going to want to run sudo system CTL start Redis, PostgreSQL, because while they are enabled that boot, we've just installed them and they're not started yet. So I'm going to start them right now. And as you can see, they're starting. All right, now that we're done with the dependencies, let's begin actually installing PeerTube. So back in the any OS section of the guide, we're going to first of all create a user called PeerTube. So the way this entire system of PeerTube works is you should set up a user. As you can see here called PeerTube with password PeerTube. And this user will manage every single aspect of the directory var www PeerTube, which is where the videos will be stored, all the configuration for PeerTube will be stored, everything PeerTube related on the system besides the database will be stored in var www PeerTube, which is a directory that is going to created once we run this command over here. Just in case it already exists on your system and you're reinstalling, you can run this command rm dash rf then var www PeerTube and then a star just like that to remove anything that might possibly be in there. Now you can set a password for PeerTube. I'm going to give it a password one, two, three, four, because this is not something I'm actually going to be using. So one, two, three, four is fine. And now we're going to create a database. Now when you install Postgres QL, it added a user to a system called Postgres and Postgres can create new users that it can use with its databases. So we're going to just copy paste this command and we're going to create a new database user called PeerTube. Now it's going to ask us for a password to use for it. I'm going to set the password to one, two, three, four and one, two, three, four. That's just a very insecure password. You should set a custom password or something quite secure, which you can then add to the PeerTube configuration. But remember this password because you will need it. Okay, now that we've entered the password, we're going to want to create a database for PeerTube to actually use. So we're going to copy paste this command. And as you can see, it's going to create a database with a bunch of different features, a UTF-8 formatting and that kind of stuff. And it's going to name it PeerTube underscore prod. We're going to press enter and run that command. And as you can see, it created the database. Now we're going to just run these two commands over here, sudu-upostcript, just to add extensions to the database that it needs. So just copy paste these two and run them. It's not exactly a very complex process there. Now we're going to want to actually download and install PeerTube. So how this works is it gives you an environment variable called version and it figures out what the latest version of PeerTube is using that. So we're going to take that and copy paste it in and just press enter. And as you can see, it tells us the latest version is 3.1.0. So now I've gone to var www of PeerTube using a CD command. So just copy pasting this. And now I'm going to create three directories as the PeerTube user called config storage and versions. So there we go. Now if we list the directory, there's config storage and versions directories which are owned by the PeerTube user. Now we're going to go into the versions directory and we're going to want to run these two commands. This first one is going to use that environment variable from before, which is version, to download the latest version of PeerTube and put it in a directory that is appropriate for its name. This is a quiet wget command. So you won't see any prompts or loading things or anything on the screen. Just give it a second to run. Okay, now that that's done, you'll see there's a new file in a directory called PeerTube dash version 3.1.0 zip. And that's a zip file we're not going to extract with this command over here, which uses the unzip command to unzip this into a directory. Once again, this is a quiet command with a dash q option. So you won't see any prompts or anything on screen. And as you can see, we now have a directory called PeerTube dash v 3.1.0 because it also removed the zip. Okay, now we're going to go back one directory so CD dot dot into var www PeerTube and we're going to install it. So first of all, we're going to symbolically link the two files using this command over here, which means it's going to create a file called PeerTube latest and link it to that version of PeerTube that we just installed that folder. So now if you go into the PeerTube latest directory, it's the same contents that would be in the PeerTube version 3.1.0 directory. That's just for convenience. So you can easily switch and swap versions of PeerTube if you're updating. And now we're going to want to run the following command over here where it goes into PeerTube latest and uses yarn to install everything. So just run that command. It will take a while, depending on the speed of your server, but this is actually going to compile and install PeerTube. Okay, so now it's done. Just to clarify these warnings and things, you can ignore those. So I'm going to clear the screen now and I'm going to go back to the previous directory because we're not going to do some configuration, scrolling down to the configuration section over here. We're going to want to use this command to copy over a default dot YAML file that's for configuration. We're not going to edit that file, but we are going to edit this file that we're going to copy over with this command over here. It's config production YAML. So we're going to want to use our editor of choice, in my case VIM, so sudo vim. Remember you have to use sudo privileges because this entire directory is only technically meant to be accessed by the PeerTube user. So we're going to do sudo vim config production dot YAML, which is in the config directory. So we have to change a few things here. Like for example, the web server, we're going to want to change the host name to our actual host name. So in today's example, I'm using test.denchi.live, a host name that has an a entry, so a regular, you know, website entry that points towards the IP address, the public IP address of the server. So that's the domain I'm going to be using. You have to set this correctly, otherwise authentication and various other things will not work in PeerTube. So the port is four for three because we want SSL. We're going to scroll down over here and we're going to go to the database section. And as you can see, it gives us a username and password for PeerTube. And as you remember, we created a database user for PeerTube instead of password to one, two, three, four. So we're going to want to put our password in here. We also want to configure a few more things in here. If you have a mail server and you want PeerTube to be able to send mail to verify users, that kind of thing. If you want to enable that, then you can edit all this kind of stuff. Now I'm not going to do that because I don't have it. Also ignore this admin email over here. This is only for self-signed certificates, which we're not going to be using today. So scrolling down more and more, there's different customizations where you can decide where you store all your various videos and that kind of stuff. It's going to scroll all the way down here to the admin section. So this is lying 220 as you can see down there. And we want to change this email to your email or an email you wish to use for your admin account. So I'm going to set it to my email. That's my personal email over there that I use. And it will generate a password for the administrator user at build, which is what we've already done. So now we've successfully set our email. We're going to want to write and quit. And I'm assuming you know how to use Vim if you're doing this tutorial. So we're going to write, quit that configuration file. And now we're going to set our web server configuration. So PeerTube works by using the Nginx web server. And with Nginx, there's two directories you got to configure that being Etsy Nginx sites available, which contains all the websites that are available and Etsy Nginx sites enabled. So these are the actual websites that are on and the Nginx is served. So we're going to create a new file and sites available. Actually we're going to copy it over from the default. So just copy paste this command over here and paste it into here. And we're going to use these two set commands to change a few things. So this first set command, you want to go all the way back down here where it says PeerTube domain, delete the square brackets too. And we're going to put test.denshi.live or whatever domain you're using for your PeerTube. Press enter. And the next one you can basically just copy paste because I'm assuming we're not going to be changing our PeerTube host. It runs on port 9000. And unless you want to use a different port, maybe that conflicts, then I don't think you really have to change that. If you want to do further configuration, you can edit it, but I'm not going to do that. Now we're going to run this command over here to symbolically link that file to the sites enabled directory, just like that. And now comes the certificate part. So as long as you've set that domain correctly, this step will have no issues. The first thing you are going to want to do is stop engine X if it's currently running. So I'm going to stop it right there. So that's sudo system CDL stop engine X. So that stops the payment. Now we're going to run this command over here where it generates a nice little domain for us. But you can delete this last part where the post hook because we can just do that later. Just sudo cert bot, cert only dash dash standalone. And then we can specify our domain with dash D. So in this case, we're going to specify domain test dot denti dot live, just like that. So we're going to press enter and it's going to generate a certificate. As you can see, I've already generated one. You won't get this prompt if you haven't, but in my case, I have generated one. So I'm going to renew and replace it with the option number two, just give it a second while it verifies it. And as you can see, it's done. So now we can restart engine X as soon as system CDL restart engine X just like that. We want to go to the system D section because we're going to copy over a system D Damon to run peer tube. So we're going to copy this Damon called peer tube to our system D system directory, which means we're going to be able to enable it just like we do with engine X and post-gray SQL and everything. And if you want, you can edit it, but I'm not going to edit it. And now comes the moment of truth. We're going to enable and start peer tube sudo system CDL enable dash dash now peer tube. So that means it turns it on a boot so enables it and it starts it right now, peer tube. And if you really want to check the status of peer tube you can run and and sudo system, CTL sudo journal, CTL dash FBU peer tube, which tracks peer tube and what it's doing. So if you run this command right now, you'll begin to get this prompt for what peer tube is currently doing. It started the peer tube. Damon's going to begin running everything. Give this a second to launch because it might take a second. Okay, so once it's actually started, you'll see all this stuff on screen. At some point it will tell you that it has successfully started the server. But anyway, now if we actually go to the website itself, so test.denshi.live, you'll see that yeah, it shows prompts on screen that shows that I am indeed logging in. And here we are, we're now in our own peer tube instance. Before we actually do anything we want to sign into our administrator account. So if we log in, we're going to want to, we'll type in our email address of course, which we set before in the production.yaml file. And to find the password, we can actually go check the peer tube logs. So that's quite easy to do. We're going to want to use sudo though. We're going to sudo vim storage logs and then it should be peer tube.log which is located once again in the peer tube root directory for our www peer tube. And if we look through it with our vim text editor, we can just search for the term password and there you go. It's right there. dojimoblerosema, all right then. So I guess I'm going to just put it so you can see it. Not that this is even public, so it doesn't even matter. Dojimoblerosema, just a sign into the admin account. So log in right there. You can save the password, I'm not going to do that. And as you can see there's a little peer tube guide over here. It's time to configure your instance. All right then configure my instance. You can go through a changed name of it. I guess you could call it Denchi's test tube or something. I don't really know. So congratulations. You've successfully created your own peer tube instance that is self-hosted. You can federate it, you can do everything. Thanks for watching this video. I've been Denchi, goodbye.