Configuring Prosody
This article is part of an ongoing series of posts, there’s an index here.
Environment
I’ve started with Ubuntu 14.04 as the platform for this project, mainly due to it having a good selection of the packages we’ll need at suitable versions, and it’s a well-tested option for the software we’ll be deploying.
I have registered a new domain name for this project, chinwag.im. For those unfamiliar with the term, “chinwag” is an Australian slang term for a chat, or conversation.
Installation
I’ve got a new virtual server dedicated for this project, but I’m not going into too much detail about general system setup. I’m going to assume you’ve got some basic background in running a server. I’ll also install Prosody pretty much by the book according to their own instructions for their repository. Please see their site for detail, this is just a quick overview.
Create /etc/apt/sources.list.d/prosody.list with the contents:
deb http://packages.prosody.im/debian trusty main
Install Prosody and Dependencies:
# apt-get update
# apt-get install prosody-0.10
# apt-get install mysql-server
# apt-get install lua-event
# apt-get install lua-dbi-mysql
This is broken up into multiple lines for clarity, don’t feel you have to copy and paste this as-is, OK? Note that I’ve also installed the MySQL libraries for Lua that we’ll need to use that as our data storage, and also that I’ve specified the 0.10 branch of Prosody. If 0.10 has released by the time you’re reading this, you’ll just want to install the “prosody” package.
I’m anticipating there will someone asking “why MySQL?” at some point, so here we go – I’ll be using it for WordPress later anyway, so might as well make use of it here as well. The intent of this project is to identify end-user issues and presentation, and I’m going to take the most well-trodden path to get there. Maybe we can have a series on the “most technically excellent backend” XMPP server at a later date.
Configuration
First up, quickly create a new database for Prosody and set a password and user. If you want a thorough guide to that, try this one for Debian 7, it’s the same deal.
mysql> create database prosody;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on prosody.* to prosody@localhost identified by 'secret';
Query OK, 0 rows affected (0.00 sec)
So right now I’m going to charge ahead and set up the bare minimum to make Prosody functional. I’m going to trash the supplied /etc/prosody/prosody.cfg.lua file and build up something very simple. Here’s our starter config file:
admins = { "admin@chinwag.im" }
use_libevent = true
modules_enabled = {
"roster";
"saslauth";
"tls";
"dialback";
"disco";
"private";
"vcard";
"version";
"uptime";
"time";
"ping";
"pep";
"admin_adhoc";
}
allow_registration = false
ssl = {
key = "/etc/prosody/certs/localhost.key";
certificate = "/etc/prosody/certs/localhost.crt";
}
c2s_require_encryption = true
s2s_secure_auth = false
pidfile = "/var/run/prosody/prosody.pid"
authentication = "internal_plain"
storage = "sql"
sql = {
driver = "MySQL",
database = "prosody",
username = "prosody",
password = "secret",
host = "localhost"
}
log = {
info = "/var/log/prosody/prosody.log";
error = "/var/log/prosody/prosody.err";
"*syslog";
}
VirtualHost "chinwag.im"
enabled = true
Do we have a workable service here? No, but we have enough to press “start” and ensure that everything actually looks like it’s going to run.
# service prosody start
* Starting Prosody XMPP Server prosody [ OK ]
# prosodyctl status
Prosody is running with PID 1309
We have an XMPP server! It’s terribly configured, uses self-signed certificates, and has no user accounts … but we’re underway! I have also glossed over a log entry warning about the version of LuaExpat in use, but I’ll address that when we start adding extra modules in the next post. Let’s add our first user account, which should probably be the JID you specified in the “admins” line at the top of the config.
# prosodyctl adduser admin@chinwag.im
chinwag.im:storage_sql info Initialized new MySQL database with prosody table
Enter new password:
Retype new password:
No errors from that (aside from the Expat stuff I mentioned)? Looks like we’re all good. The Prosody daemon runs, the backend storage works, we’re in a fine position to start actually making things work properly. I know I’m glossing over things a lot. I’m not trying to write a step-by-step guide in insane detail, but just clearly illustrate what the steps are. If I’ve casually jumped over something you consider critical, please comment and let me know.
What’s in the next post? A few more tweaks to our configuration, and setting up a bunch of extra modules that’ll make everyone’s lives easier.