 Hi, I'm Denshi. In today's video, we're gonna be setting up an XMPP chat server using eJabbered. Now, before we do anything with our server, we actually need to configure some subdomains to operate all the different components of our XMPP server. As you can see, I've created a few records over here. Obviously, I have my main record, which is denshi.org that points to this dynamic DNS. Then, of course, I have MUC, that will be my multi-user chat domain, upload, proxy, and PubSub. I'm hosting everything on one server, so I don't have to worry about giving them different addresses or setting up a software in a weird way. In addition to this, you can also set up a turn server for calling, but I've already actually made a video on that. You can go watch that. I'll have that linked in the description where I talk about how to set that up. Now, all of these are the default names. By default, it expects you to use these names, conference, upload, proxy, and PubSub. And I've used those except for the MUC, or the multi-user chat. I've used MUC instead because it's shorter. And we're gonna actually take a look at how we can modify that in the eJabberd settings. But now that you've set up your subdomains, we can move on to actually installing the eJabberd software. The software we're gonna need today is eJabberd. We're also going to want Python 3-ShirtBot, if you're using ShirtBot, and if you're using Nginx, which is what I'm using, I'm gonna add the dash Nginx right there so we have that plugin. And you're also going to want erlang-p1-pgsql. And you're also going to want the package post-gray SQL because we're gonna be using a post-gray SQL database for our eJabberd server to make it fast. Now, I've already installed all of this software, so I don't have to reinstall it, but you might have to go through that process and download it. It might take a while because those are big pieces of software. But once you have installed the eJabberd, you will have access to stuff like the eJabberd CTL command. And we're gonna start working on setting up our server in the etsee-eJabberd, eJabberd.yml file. This is the main config file used by eJabberd. So the first thing we probably wanna do in here is we wanna make sure that our hosts are set correctly. So we said before that we're using muc.example.org, which is not the expected subdomain for multi-user chats. As you can see, the expected one is conference, so we're gonna be using that one. So for that, we're gonna go down to the line that says modmuc right over here. And every single module that has a domain, that needs a domain in eJabberd, has a host option that you can give it. And we're gonna give it muc.denchi.org as our host. Now, speaking of hosts, the first thing we probably wanna do is set up our main host. So up here, it says there's this host section in the config file. We're gonna uncomment the host line, and we're gonna uncomment one of these, and we're just gonna type denchi.org. Now, obviously in your case, you can just use whatever domain you're using, but I'm using denchi.org. Now that we've done that, we probably want to delete this part that says hosts local hosts. So I'm just gonna delete those two lines. But now that we've done that, you'll notice there's a certificates section over here where we have to give eJabberd a list of certificates for it to access. Now, because I don't want to give the eJabberd user the permissions to actually read the certificates straight from the privilege directory where they're located, instead, we're gonna use a script over here to get all of our subdomains automatically and copy them over to this directory, which is the eJabberd search directory. So we're gonna create that directory, mkdir at cejabberd certs, just like that. And now we're just gonna copy paste this domain section over here. Our main domain is denchi.org. And now we're going to copy paste this over here, which is just a declaration of an array. So in here, you wanna put all of the subdomains that you want. In this script, it will automatically cycle through these and get the certificates using certbot, which we installed before. The one I'm changing is the conference one, because once again, we're using MUC instead. So now that's done, I'm gonna press enter. And now I can basically just copy paste the main part of the script and this should run automatically. Now it does give it the nginx flag because I am running a web server. It's asking me about a certificate, which I've already installed. I'm just gonna say keep the existing certificate. So we're just gonna let this run for a bit. It's gonna automatically get all the certificates as long as you've set the DNS correctly, that is. It's gonna copy them over to the directory and then we're gonna come back to this. All right, it's done getting all the certificates and copying them over. And now we actually list the Etsy eJabbert cert directory. There they are, a bunch of folders with our certificates. However, one thing we need to make sure is that these are owned by the eJabbert user because that's the user that's gonna be running the eJabbert server software. So we're just gonna copy paste this command over here, which gives it ownership over that directory. Now all we have to do is go back to eJabbert.yml and change these lines to include all of the certificates in that directory. So this line over here basically. Oh yeah, may have accidentally given this too many tabs there. Okay, now that we've added the certificates, we can move on to the next step, we're just configuring the admin user. So if we go to the ACL section, we can see that there's an admin user section and we're gonna set the user just to any username. Now in my case, I'm just gonna use the username Alex because that's the one that I'm going to register on the server. And there you go, we've created that and it should work. Now going down here, this is the database section where we have to start configuring the database. So we go down to the MAM section or message archive management. Well, first of all, we want to enable message archive management. And I'm just gonna put a little two brackets over here to enable it. And as you can see, there's a comment that starts talking about how the default database system, which eJabbert uses, which is amnesia is limited to two gigabytes, which means that it's not exactly useful for a proper deployment of eJabbert. So what we're going to do is start setting up a PostgreSQL database that we will use for all of our services in eJabbert. Not only the message archive, but everything else. We're gonna set it as a global database. So what we're gonna do first is we have to, you know, install PostgreSQL if you haven't installed it already. We want to start the service if you haven't started it already. So system CTL, start PostgreSQL, but I've already started it. So I don't need to start it again. And you need the module for Erlang to work with PostgreSQL. But once again, this has already been installed. I think there's a typo here. This is meant to say PGSQL. That will be fixed, sorry. Now we have to create the database. The first thing we want to do is create a new user by using this command, using the PostgreSQL user. And the user is gonna be called eJabbertD. So we're gonna press Enter, and yeah, it just gives an error for permissions, but we can ignore that. And we're gonna set a password here. I'm just gonna set one, two, three, four for the sake of this tutorial, but I might change that later. The next thing I'm going to do is copy paste this command. What this does is this creates a database named eJabbert and gives it to the user named eJabbert. So running this, yeah, there you go. I created the database. Now, unlike most other software, which I cover in my self-hosting series, eJabbert doesn't automatically fill its database with entries. You have to manually create them, which means all we have to do is download this raw GitHub user content thing and pipe it into PostgreSQL. Now, you don't really have to know what this is doing, but all it really does is create all the different tables that we need in a database. So going up here, though, you wanna make sure your password is set correctly and the user name and the database name if you set custom ones. So eJabbert over here, that's our user name and this eJabbert is the database. And of course, that's the port that PostgreSQL is set up on. So now if we press enter, this will begin creating all the tables and indexes for the database and that might take a second. Okay, there you go, it's done. Now that we've actually created the database, we can go back to eJabbert.yml, go to the top of the file and we're just gonna leave a little space over here where we can copy paste the database configuration, which will be this stuff over here. Now, user name is eJabbert, the database name is eJabbert and the password once again was one, two, three, four. So now we've created a database and let eJabbert use it. There's a few more things that we want to configure though. Like for example, we wanna go through and actually modify the different modules to enable stuff. So this isn't really covered in the guide because most people wanna customize this kind of stuff, but I'm gonna run you through the kind of things which I like enabling and enabling. So the first thing is I'm gonna keep all of these things enabled. However, down here, I want to enable the upload functionality for the port 5443. This allows us to upload files. If you want to enable Capsca, you can also enable Capsca. Now that we've enabled the upload though, we have to actually go to the mod. So mod underscore HTTP underscore upload, which is commented out here. We just have to uncomment all of these lines and then it will automatically just work. These are sane defaults over here. Now, one thing I'll do is I'll get rid of these little curly brackets and mod mam and I will assume mam usage true and default always because I want it to automatically archive messages when people send them. Once again, for all the modules like mod HTTP upload, the stuff that you host on a port, you can give it any domain name you want by using the host option. Now there's probably a few more things which I probably wanna go through and modify here. Yeah, I like mod register, for example, if you want to have registration enabled, I'm just gonna have this with default sending for the curly brackets. But I think this is pretty much everything we need as far as I remember. Most different services and stuff should be enabled by default and should begin working. Now, before we actually restart the daemon like it says in the guide, we wanna go through and test it out using eJabbert CTL. So running eJabbert CTL and then live, we can press enter. It'll give us a warning but we can press enter again. And it says, oh, it's already running. Oh, sorry, it must have enabled by default. So we're gonna stop eJabbert actually first. That might have happened when you install it. Now we can run eJabbert live again. And as you can see, it actually starts. It should automatically start all the connections on the different ports. It'll give you a warning about the turn server, but we can fix that later, actually. But now we just wanna make sure that it's working. So by default, eJabbert will list it on the 5.2.20 port. So if we go to denshi.org colon 5.280, actually, as you can see, it gives us a 404 not found. There's a few different things you can access from here. One thing we can access is the admin page. So over here, we can put our username and our password and log in as an admin user. But you may have remembered that while we added the admin user, we didn't give them a password. So we can do that now. And we can also disable the turn server stuff and just fine tune our server. So to exit the eJabbert live environment, you have to type Q, open bracket, close bracket, then a dot and press enter. So going back to eJabbert.yml, there's a few things which I probably want to begin disabling. The first thing we want to disable is MQTT, which is this over here. We don't actually need this. This is kind of useless functionality if we just want to chat on our server. So I'm going to get rid of it. And also our turn server. This is useful if you're running a server by yourself, something that runs independently on a VPS and you just want the basic calling functionality. However, I'm going to be setting that up externally. So I'm actually going to delete this and I'm not going to have this. But do keep it and configure it if you're using a VPS or a server with a DMZ or something like that. But anyways, now that we've done that, we want to go through and want to actually register a user. So to do that, we actually need to start eJabbert first as a daemon. So system CTL, restart eJabbert D and then it will start eJabbert. The next thing we want to do is using eJabbert CTL, we're going to use the register command within the username, the server, and then a password. So I don't know. I'm going to just put one, two, three, four, but obviously I'm going to change that later. So there you go. We've registered a user named alexaddenchi.org. And now if we go back to denchi.org colon 5,280 and go to the admin page and we type alexaddenchi.org and then put the password as one, two, three, four. As you can see, it signs us into the admin interface. Now from here, we can go to virtual hosts. There's denchi.org and we can configure the users. We can check online users. We can go and actually change users' passwords. We can do lots of things from here. But now let's actually start using it with a client. So over here, I have a client for XMPP named dino. We're going to set up an account. We're going to type in alexaddenchi.org. We're going to click next. Then we're going to put a password, which will be one, two, three, four because that's the one that we set. And here we are, our very insecure password user. And we can add more users and we can start talking to people. Because XMPP is federated, we can join chat rooms from completely different servers. We can talk to users on different servers. It's a very, very nice and useful protocol. But anyways, I've been denchi. That was how to set up your very own XMPP server with eJabberd. I hope you enjoyed this video. Goodbye.