Tutorials  /  Linux Basics

Install and Run a Diaspora Pod on CentOS 7 Step-by-Step

Ccentron Redaktion · July 2025 ·7 min read ·Linux Basics, Tutorial

Diaspora is an open-source social platform with a focus on user privacy. This tutorial explains how to install and configure a Diaspora pod on CentOS 7.

Prerequisites

  • A CentOS 7 server setup
  • At least 512MB RAM, 1GB swap space, and a multi-core CPU for standard pod operation
  • An active sudo user
VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Install Required Packages

Start by retrieving and installing the latest EPEL release:

Console
sudo yum install epel-release

Install the essential packages:

Console
sudo yum install tar make automake gcc gcc-c++ git net-tools cmake libcurl-devel libxml2-devel libffi-devel libxslt-devel wget redis ImageMagick nodejs postgresql-devel

Activate Redis at system startup:

Console
sudo systemctl enable redis
sudo systemctl start redis

Install and Configure PostgreSQL

While Diaspora also works with MySQL or MariaDB, this guide uses PostgreSQL.

Install PostgreSQL server and tools:

Console
sudo yum install postgresql-server postgresql-contrib postgresql-setup initdb

Enable PostgreSQL to run at startup:

Console
sudo systemctl enable postgresql
sudo systemctl start postgresql

Access the PostgreSQL prompt:

Console
sudo -u postgres psql

Create a new PostgreSQL user for Diaspora:

Code
CREATE USER diaspora WITH CREATEDB PASSWORD '<password>';

Add a Dedicated Diaspora User

Create a local system user for running Diaspora:

Console
sudo adduser --disabled-login diaspora

Switch to this user session:

Console
sudo  su - diaspora

Install Ruby with rbenv

Install all required dependencies for Ruby:

Console
sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel

Clone and set up rbenv:

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

Reconnect as the Diaspora user to apply environment changes:

Code
exit
sudo su - diaspora

Install ruby-build plugin for rbenv:

Console
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Install Ruby 2.4.3 and make it the global version:

Code
rbenv install 2.4.3
rbenv global 2.4.3

Set Up Mail Server

Use Postfix as the mail transfer agent. Please refer to the appropriate guide to set up Postfix with Dovecot and Sieve for handling user mail.

Install and Configure Diaspora

Clone Diaspora’s master repository:

Console
cd ~
git clone -b master https://github.com/diaspora/diaspora.git
cd diaspora

Copy sample config files:

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

Modify the database config file with your database credentials:

Code
nano config/database.yml

Example PostgreSQL configuration block:

YAML
postgresql: &postgresql
  adapter: postgresql
  host: localhost
  port: 5432
  username: diaspora
  password: __password__
  encoding: unicode

Edit Diaspora config file with required values:

Code
nano config/diaspora.yml

Make these changes:

  • Set the url to your pod's public address
  • Uncomment certificate_authorities
  • Set rails_environment to production
  • Set require_ssl to false

Install Gems with Bundler

Install bundler and configure the environment:

Code
gem install bundler
script/configure_bundler

Note: If you receive version errors, edit .ruby-version and specify 2.4.3.

Set Up the Database

Create the database and run migrations:

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

Precompile Assets

Run this Rake command to generate the production-ready assets:

Code
RAILS_ENV=production bin/rake assets:precompile

Set Up Diaspora with systemd

To manage Diaspora as a service, we’ll use systemd. Begin by creating the following files:

Create the target unit:

Code
touch /etc/systemd/system/diaspora.target

Set up the web service unit:

Code
touch /etc/systemd/system/diaspora-web.service

Create the sidekiq service file:

Code
touch /etc/systemd/system/diaspora-sidekiq.service

diaspora.target

Code
[Unit]
Description=Diaspora social network
Wants=postgresql.service
Wants=redis-server.service
After=redis-server.service
After=postgresql.service

[Install]
WantedBy=multi-user.target

diaspora-web.service

Code
[Unit]
Description=Diaspora social network (unicorn)
PartOf=diaspora.target
StopWhenUnneeded=true

[Service]
User=diaspora
Environment=RAILS_ENV=production
WorkingDirectory=/home/diaspora/diaspora
ExecStart=/bin/bash -lc "bin/bundle exec unicorn -c config/unicorn.rb -E production"
Restart=always

[Install]
WantedBy=diaspora.target

diaspora-sidekiq.service

Code
[Unit]
Description=Diaspora social network (sidekiq)
PartOf=diaspora.target
StopWhenUnneeded=true

[Service]
User=diaspora
Environment=RAILS_ENV=production
WorkingDirectory=/home/diaspora/diaspora
ExecStart=/bin/bash -lc "bin/bundle exec sidekiq"
Restart=always

[Install]
WantedBy=diaspora.target

Enable and Start Services

Activate all Diaspora-related services at boot:

Console
sudo systemctl enable diaspora.target diaspora-sidekiq.service diaspora-web.service
sudo systemctl restart diaspora.target

Check service status:

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

Configure Nginx as a Reverse Proxy

Set up Nginx to proxy Diaspora and deliver static assets. Also use acme.sh to acquire a Let's Encrypt SSL certificate.

Clone acme.sh

Console
git clone https://github.com/Neilpang/acme.sh.git

Request a Certificate

Code
./.acme.sh/acme.sh --issue --log \
--dns \
--keylength ec-256 \
--cert-file /etc/nginx/https/cert.pem \
--key-file /etc/nginx/https/key.pem \
--fullchain-file /etc/nginx/https/fullchain.pem \
-d example.com \
-d www.example.com

Install and Configure Nginx

Console
sudo yum install nginx
nano /etc/nginx/conf.d/diaspora.conf

Paste this configuration:

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

server {
  listen 80;
  listen [::]:80; 
  server_name www.example.com example.com;
  return 301 https://example.com$request_uri;

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

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name www.example.com example.com;

  if ($host = www.example.com) {
   return 301 https://example.com$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_ciphers EECDH+CHACHA20:EECDH+AESGCM:EECDH+AES;
  ssl_ecdh_curve X25519:P-521:P-384:P-256;
  ssl_prefer_server_ciphers on;
  ssl_stapling on;
  ssl_stapling_verify on;
  resolver 80.67.169.40 80.67.169.12 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;
  }
}

Replace example.com with your actual domain name.

Test and Reload Nginx

Console
sudo nginx -t
sudo systemctl restart nginx

Allow Web Traffic Through Firewall

Console
sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

Access Diaspora in Browser

Open your domain in a browser to see the Diaspora welcome screen: https://example.com

Create an Admin User

Create a Diaspora user by clicking “Start by creating an account.” After registering, assign admin rights:

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

Access the admin dashboard via:

https://example.com/admins/dashboard

Access Sidekiq Dashboard and Stats

  • Sidekiq UI: https://example.com/sidekiq
  • Pod statistics: https://example.com/statistics

Log Management with logrotate

Create a logrotate config file:

Code
nano /etc/logrotate/diaspora

Insert the following configuration:

Code
/home/diaspora/diaspora/log/*.log {
  notifempty
  copytruncate
  missingok
  compress
  weekly
  rotate 52
}

Update Diaspora

To upgrade Diaspora:

  • Update all installed system packages:
Console
sudo yum update
  • Update the source code and gems:
Code
su - diaspora
cd diaspora
git pull
gem install bundler
bin/bundle --full-index

Apply database changes and recompile:

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

Restart Diaspora:

Console
systemctl restart diaspora.target

Conclusion

By completing these steps, you've successfully deployed a private, production-grade Diaspora pod on CentOS 7. You’ve configured core components including PostgreSQL, Ruby, Nginx, and systemd services. With SSL encryption, log rotation, and proper user roles, your instance is secure, performant, and ready for use. Stay up-to-date by routinely updating the application and monitoring system health through Sidekiq and admin dashboards.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Unser Team hilft Ihnen bei Ihrem konkreten Setup weiter – von Menschen, die die Plattform selbst betreiben.

War dieses Tutorial hilfreich?

Ihre Antwort wird anonym gespeichert und hilft uns, die Tutorials zu verbessern.

Kommentare

Noch keine Kommentare – stellen Sie die erste Frage zu diesem Tutorial.

Zum Kommentieren anmelden

Kommentare stehen centron-Kunden offen. Melden Sie sich in Ihrem Konto an, um eine Frage zu diesem Tutorial zu stellen.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren