How to set up a diaspora* pod on Debian and Ubuntu
6 min read

How to set up a diaspora* pod on Debian and Ubuntu

Full tutorial to setup your own Diaspora* pod on your Linux server.
How to set up a diaspora* pod on Debian and Ubuntu

In this tutorial, we will install a diaspora* pod on a Debian/Ubuntu server. I use the official Debian 8 guide as a base, and I used it myself on Debian 9 for, but it should work on most recent Debian and Ubuntu versions.

Our setup will use Nginx, PostgreSQL and Systemd.

Table of content

Hardware requirements

Obviously, they depend on the size of your instance and the activity of the users.

For a tiny instance (a few users):

  • Memory: 1.5 GB
  • CPU: About everything is enough
  • Storage: depends on the DB size and the images the users will upload. A few gigabytes are enough to start.



apt install build-essential libssl-dev libcurl4-openssl-dev libxml2-dev libxslt-dev imagemagick ghostscript curl libmagickwand-dev git libpq-dev redis-server nodejs


Diaspora* supports MySQL, MariaDB and PostgreSQL. We will use the latter.

Install it:

apt-get install postgresql-server

Then connect to PostgreSQL via the postgres user:

sudo -u postgres psql

Create a postgresql diaspora user:


We will create the database later.

Creating the diaspora user

We will install and run diaspora* under this user.

adduser --disabled-login diaspora

To login:

su - diaspora

Ruby installation

There are multiple ways to install Ruby. We will use rbenv to manage Ruby versions and environment.

We need these dependencies (run this command as root) to install Ruby.

apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev

Log back to your diaspora user.

Install rbenv:

git clone ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Login again to load your new PATH:

su - diaspora

Then, we will install the ruby-build plugin for rbenv that allows us to compile Ruby:

git clone ~/.rbenv/plugins/ruby-build

We can now install Ruby!

rbenv install 2.4.3
rbenv global 2.4.3

The diaspora* project recommends the 2.4 branch. Ruby 2.5 has been out for a few weeks but I got issue running diaspora* with it, so I recommend sticking with 2.4 for now. Please check here if 2.4.3 is the latest 2.4.x when you're reading this tutorial.

Install exim4

I use exim4 as a SMTP relay.

As root, install the package, and then configure it. It's pretty straightforward.

apt install exim4
dpkg-reconfigure exim4-config

Download diaspora*

It's time!

Download the diaspora* source code and get into the directory:

cd ~
git clone -b master
cd diaspora

Configure diaspora*

Copy the example files:

cp config/database.yml.example config/database.yml
cp config/diaspora.yml.example config/diaspora.yml

They are quite long but well commented. Please read them.

In config/database.yml, set your PostgreSQL user (diaspora) and the password you chose. PostgreSQL is selected by default so you don't need to do anything else.

You will need to configure more stuff in config/diaspora.yml.

Here are the lines I changed for


    url: ""
    certificate_authorities: '/etc/ssl/certs/ca-certificates.crt'

    rails_environment: 'production'

  statistics: #enable public stats
    user_counts: true
    comment_counts: true

    liberapay_username: "angristan"
      enable: false #disabling captcha because of imagemagick issues
    source_url: ''

    enable: true
    sender_address: 'contact[at]'
    method: 'sendmail' #exim4

    account: "angristan"
    podmin_email: 'angristan[at]'

      subscribe: true
      scope: all

A lot of options are fine by default.

Install bundle and the gems

Install bundle, a Ruby libraries manager:

gem install bundler

If you run into issues regarding your Ruby version, just edit the .ruby-version file and put yours.

Then install all the gems:

bin/bundle install --full-index

Setup the database

This rake command will create and setup the database:

RAILS_ENV=production bin/rake db:create db:migrate

Precompile assets

This rake command will generate static assets:

RAILS_ENV=production bin/rake assets:precompile

Systemd services

There are mulitple ways of managing diaspora* as a service. We'll use systemd.

Create the following files:


Description=Diaspora social network



Description=Diaspora social network (unicorn)

ExecStart=/bin/bash -lc "bin/bundle exec unicorn -c config/unicorn.rb -E production"



Description=Diaspora social network (sidekiq)

ExecStart=/bin/bash -lc "bin/bundle exec sidekiq"


Enable the services at boot:

systemctl enable diaspora-sidekiq.service diaspora-web.service

Restart the services:

systemctl restart

Check if they are running correctly:

systemctl status diaspora-web.service
systemctl status diaspora-sidekiq.service

Nginx reverse proxy

We will use Nginx as a reverse proxy for HTTPS and serving static assets.

I used to get a Let's Encrypt certificate.

After installing it, run:

./ --issue --dns -d -d --keylength ec-256 --cert-file /etc/nginx/https/cert.pem --key-file /etc/nginx/https/key.pem --fullchain-file /etc/nginx/https/fullchain.pem --log

Install Nginx:

apt install nginx

Here is my /etc/nginx/conf.d/ file:

upstream diaspora_server {
  server unix:/home/diaspora/diaspora/tmp/diaspora.sock;

server {
  listen 80;
  listen [::]:80;  
  return 301$request_uri;

  access_log  /dev/null;
  error_log /dev/null;

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  if ($host = {
    return 301$request_uri;

  access_log /var/log/nginx/dspr-access.log;
  error_log /var/log/nginx/dspr-error.log;

  ssl_certificate     /etc/nginx/https/fullchain.pem;
  ssl_certificate_key /etc/nginx/https/key.pem;

  ssl_protocols TLSv1.2;
  ssl_ecdh_curve X25519:P-521:P-384:P-256;
  ssl_prefer_server_ciphers on;
  ssl_stapling on;
  ssl_stapling_verify on;
  resolver valid=300s;
  resolver_timeout 5s;
  ssl_session_cache shared:SSL:10m;

  root /home/diaspora/diaspora/public;

  client_max_body_size 5M;
  client_body_buffer_size 256K;

  try_files $uri @diaspora;

  location /assets/ {
    expires max;
    add_header Cache-Control public;

  location @diaspora {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://diaspora_server;

Of course, adapt it to your domain.

Your pod should now be accessible!



Nice tip: use logrotate to keep your logs clean.

Add this in /etc/logrotate/diaspora

/home/diaspora/diaspora/log/*.log {
  rotate 52

This will rotate your logs every week, compress them, and keep them for 52 weeks. You can tune this as you want.

Admin stuff

After signing up you should make yourself an admin:

Role.add_admin User.where(username: "the_username").first.person

You should now have access to your admin dashboard at https://<diaspora>/admins/dashboard, and a bunch of options.

Sidekiq, which is the software that handles background tasks, is available at https://<diaspora>/sidekiq.


Pod stats are available at https://<diaspora>/statistics.

Add your pod to and!

Update diaspora*

The basics:

apt update && apt full-upgrade

If you need to update Ruby, just run rbenv install again with the new version.

You have multiple ways to verify the installed and used Ruby version:

[email protected]:~$ rbenv version
2.4.3 (set by /home/diaspora/.rbenv/version)
[email protected]:~$ rbenv versions
* 2.4.3 (set by /home/diaspora/.rbenv/version)
[email protected]:~$ ruby -v
ruby 2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]

Then it's similar to the install process.

Update the source code:

su - diaspora
cd diaspora
git pull

Update the gems:

gem install bundler
bin/bundle --full-index

Update the database and compile the assets:

RAILS_ENV=production bin/rake db:migrate
RAILS_ENV=production bin/rake assets:precompile

Restart diaspora* (as root):

systemctl restart

Please look at the documentation if you're doing a major upgrade.


It's easy. Make a dump of your database:

sudo -u postgres pg_dump diaspora_production > diaspora.sql

And backup your /home/diaspora/diaspora folder. Technically, just public/uploads is enough.

Make sure to automatize the process and to back up to another location!


That's it, you're ready to interact with the fediverse!

I'm [email protected], I'd be glad if you shared with me. :)