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
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:
sudo yum install epel-releaseInstall the essential packages:
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-develActivate Redis at system startup:
sudo systemctl enable redis
sudo systemctl start redisInstall and Configure PostgreSQL
While Diaspora also works with MySQL or MariaDB, this guide uses PostgreSQL.
Install PostgreSQL server and tools:
sudo yum install postgresql-server postgresql-contrib postgresql-setup initdbEnable PostgreSQL to run at startup:
sudo systemctl enable postgresql
sudo systemctl start postgresqlAccess the PostgreSQL prompt:
sudo -u postgres psqlCreate a new PostgreSQL user for Diaspora:
CREATE USER diaspora WITH CREATEDB PASSWORD '<password>';Add a Dedicated Diaspora User
Create a local system user for running Diaspora:
sudo adduser --disabled-login diasporaSwitch to this user session:
sudo su - diasporaInstall Ruby with rbenv
Install all required dependencies for Ruby:
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-develClone and set up rbenv:
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_profileReconnect as the Diaspora user to apply environment changes:
exit
sudo su - diasporaInstall ruby-build plugin for rbenv:
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-buildInstall Ruby 2.4.3 and make it the global version:
rbenv install 2.4.3
rbenv global 2.4.3Set 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:
cd ~
git clone -b master https://github.com/diaspora/diaspora.git
cd diasporaCopy sample config files:
cp config/database.yml.example config/database.yml
cp config/diaspora.yml.example config/diaspora.ymlModify the database config file with your database credentials:
nano config/database.ymlExample PostgreSQL configuration block:
postgresql: &postgresql
adapter: postgresql
host: localhost
port: 5432
username: diaspora
password: __password__
encoding: unicodeEdit Diaspora config file with required values:
nano config/diaspora.ymlMake these changes:
- Set the
urlto your pod's public address - Uncomment
certificate_authorities - Set
rails_environmentto production - Set
require_sslto false
Install Gems with Bundler
Install bundler and configure the environment:
gem install bundler
script/configure_bundlerNote: If you receive version errors, edit .ruby-version and specify 2.4.3.
Set Up the Database
Create the database and run migrations:
RAILS_ENV=production bin/rake db:create db:migratePrecompile Assets
Run this Rake command to generate the production-ready assets:
RAILS_ENV=production bin/rake assets:precompileSet Up Diaspora with systemd
To manage Diaspora as a service, we’ll use systemd. Begin by creating the following files:
Create the target unit:
touch /etc/systemd/system/diaspora.targetSet up the web service unit:
touch /etc/systemd/system/diaspora-web.serviceCreate the sidekiq service file:
touch /etc/systemd/system/diaspora-sidekiq.servicediaspora.target
[Unit]
Description=Diaspora social network
Wants=postgresql.service
Wants=redis-server.service
After=redis-server.service
After=postgresql.service
[Install]
WantedBy=multi-user.targetdiaspora-web.service
[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.targetdiaspora-sidekiq.service
[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.targetEnable and Start Services
Activate all Diaspora-related services at boot:
sudo systemctl enable diaspora.target diaspora-sidekiq.service diaspora-web.service
sudo systemctl restart diaspora.targetCheck service status:
sudo systemctl status diaspora-web.service
sudo systemctl status diaspora-sidekiq.serviceConfigure 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
git clone https://github.com/Neilpang/acme.sh.gitRequest a Certificate
./.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.comInstall and Configure Nginx
sudo yum install nginx
nano /etc/nginx/conf.d/diaspora.confPaste this configuration:
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
sudo nginx -t
sudo systemctl restart nginxAllow Web Traffic Through Firewall
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reloadAccess 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:
Role.add_admin User.where(username: "your_username").first.personAccess 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:
nano /etc/logrotate/diasporaInsert the following configuration:
/home/diaspora/diaspora/log/*.log {
notifempty
copytruncate
missingok
compress
weekly
rotate 52
}Update Diaspora
To upgrade Diaspora:
- Update all installed system packages:
sudo yum update- Update the source code and gems:
su - diaspora
cd diaspora
git pull
gem install bundler
bin/bundle --full-indexApply database changes and recompile:
RAILS_ENV=production bin/rake db:migrate
RAILS_ENV=production bin/rake assets:precompileRestart Diaspora:
systemctl restart diaspora.targetConclusion
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.
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.