How to Setup Quassel on Debian 9

Published on: Fri, Sep 15, 2017 at 1:00 pm EST
Debian Linux Guides Server Apps

IRC is popular among developers and users of open source software. One of the disadvantages of IRC is when you're not on-line, you may miss important conversations or mentions of your nickname. With Quassel and a small VPS, you can have IRC persistence, complete with a web based UI and a searchable backlog.

I'm going to assume you already know how to create a VPS in the Vultr control panel.

First, you'll need to login to your Vultr control panel and create yourself a brand new VPS. In this example, I have set-up a Debian 9, $2.50/month VPS. You can choose any size, but the aim for this is to be as low cost as possible. You'll need to give it a name, such as quassel.example.net and make sure you have a DNS A record configured.

Since these instructions are focused around Debian, you will have to modify them slightly if you plan to use a different Linux distribution such as Ubuntu or CentOS.

Once your VPS is running, you'll want to install a few packages to get the basics going.

You will need to install Quassel-Core, PostgreSQL, Apache and PHP, along with a couple more libraries to talk to the SQL server.

apt-get install quassel-core postgresql libqt5sql5-psql apache2 php php-pgsql

You're also going to need Node.js. The web portion of your personal IRC cloud server requires Node. Complete instructions to install can be found here, but these are the only two lines you'll need:

# curl -sL https://deb.nodesource.com/setup_8.x | bash -
# apt-get install -y nodejs

Next, you will need to create a database for the Quassel core. Switch to the Postgres user and run psql.

# su - postgres
$ psql

Once you're at the PostgreSQL prompt, you'll need to create a user for Quassel and it's database:

CREATE USER quassel ENCRYPTED PASSWORD 'somepassword';
CREATE DATABASE quassel WITH OWNER quassel ENCODING 'UTF8';

Now that the basics are configured, you can now launch the Quassel client and connect to your core.

When you start the Quassel client on your local machine, you will be presented with a connection dialog. Enter the IP address or host name of your VPS and the port number (default: 4242) and select SSL. If you have a proxy server, you can enter the proxy details in the dialog.

During the first connection, you will be guided though another wizard to configure the core. Enter your first Quasselcore username and password. The first user will be the administrator. Next, select the PostgreSQL database backend and provide the Quassel database username and password as defined in the previous step.

Once you have configured the basics of your core, you can now set-up the web portion. This allows you to connect to your core from any web browser. We're going to use Quassel-Webserver.

Create a user for the web service:

# useradd -d /opt/quassel-webserver -M -r quassel-webserver

Now pull down the Quassel webserver and change the ownership to the previously created user:

# git clone https://github.com/magne4000/quassel-webserver.git /opt/quassel-webserver
# chown -R quassel-webserver:quasselweb-server /opt/quassel-webserver

You then need to "install" the Node.js application:

# su - quassel-webserver
$ npm install --production

Copy the settings.js to settings-user.js and change the host, forcedefault and prefixpath values:

host: 'localhost',
forcedefault: 'true',
prefixpath: '/app'

While in the /opt/quassel-webserver path as root, you can install the service file for Systemd.

# cp scripts/quassel-webserver.service /lib/systemd/system/quassel-webserver.service

You will need to edit /lib/systemd/system/quassel-webserver.service and change the ExecStart line:

ExecStart=/usr/bin/node /opt/quassel-webserver/app.js -l 127.0.0.1 -m http

You can now enable and start the Quassel webserver:

systemctl enable quassel-webserver.service
systemctl start quassel-webserver.service

You can check that the quassel-webserver is running by executing systemctl status quassel-webserver.service. If you see Active: active (running), you're all set!

Next, we're going to configure Apache.

You'll need to enable a few modules to begin, such as proxy_http, proxy_wstunnel and rewrite.

# a2enmod proxy_http proxy_wstunnel rewrite

Create a new configuration file for Quassel:

# nano /etc/apache2/sites-available/quassel.conf

<VirtualHost *:80>

        ServerName quassel.example.net
        ServerAdmin quassel@example.net
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # Enable Rewrite
        RewriteEngine on

        # Redirect to /app by default
        RedirectMatch ^/$ /app

        # Quassel Webserver
        RewriteRule /app/p/socket(.*) ws://127.0.0.1:64080/app/p/socket$1 [P,L]
        ProxyPass /app http://127.0.0.1:64080/app

</VirtualHost>

And enable your site:

a2ensite quassel

Restart Apache to apply the changes:

systemctl restart apache2

If all has gone well, you can now browse to your quassel-webserver instance at http://quassel.example.net.

Next, we're going to set-up a backlog search. This will require modifications to the quassel-core database. First, let's begin with cloning the source code:

# git clone https://github.com/justjanne/quassel-rest-search.git /opt/quassel-rest-search

Once cloned, rename the file qrs_config.default.php to qrs_config.php and edit the file. You will need to define your database db_name, db_user, db_path and path_prefix. It should end up looking something like this:

<?php
define('db_host', 'localhost');
define('db_port', 5432);
define('db_name', 'quassel');

//Only change this if you know what you are doing
define('db_connector', null);

define('db_user', 'quassel');
define('db_pass', 'somepassword');

define('backend', 'pgsql-smart');

define('path_prefix', '/search');

Next, we modify the database to be used by quassel-rest-search:

Switch to the postgres user and run psql:

# su - postgres
$ psql quassel

First, add a new column to the backlog table:

ALTER TABLE backlog ADD COLUMN tsv tsvector;

Second, add the two new indices:

CREATE INDEX backlog_tsv_idx
  ON backlog
  USING gin(tsv);
CREATE INDEX backlog_tsv_filtered_idx
  ON backlog
  USING gin(tsv)
  WHERE (type & 23559) > 0;

Third, set up a trigger to populate the tsv column:

CREATE TRIGGER tsvectorupdate
  BEFORE INSERT OR UPDATE
  ON backlog
  FOR EACH ROW
  EXECUTE PROCEDURE tsvector_update_trigger('tsv', 'pg_catalog.english', 'message');

Fourth, populate the "tsv" column:

UPDATE backlog SET messageid = messageid;

Now you can update the Apache configuration that we created earlier and add:

# Quassel Search
Alias /search /opt/quassel-rest-search
<Directory /opt/quassel-rest-search>
        Require all granted
</Directory>

Restart Apache:

systemctl restart apache2

If all went well, you can navigate to http://quassel.example.net/search and you will see a log-in screen.

Now may be a good time to secure your web server using Let's Encrypt. Details on how to install and configure Let's Encrypt can be found on the EFF web site or here on Vultr docs.

In case you're worried about running out of RAM, you may want to enable swap on your VPS. Please follow this Linux swap tutorial.

Want to contribute ?

You could earn up to $300 by adding new articles