• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Friday, May 9, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System Debian

Build Your Social Network With Diaspora on Debian 9

How VPS by How VPS
November 1, 2019
in Debian
0
0
SHARES
27
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Using a Different System?
  2. Prerequisites
  3. Install Prerequisite Packages
  4. Install PostgreSQL
  5. Add a Dedicated Diaspora User
  6. Install Ruby
  7. Install Exim4
  8. Install and configure Diaspora
  9. Install Required Gems
  10. Setup Database
  11. Pre-compile the assets
  12. Diaspora systemd Services
  13. Nginx Reverse Proxy
  14. Create a Diaspora User
  15. Sidekiq
  16. Logrotate
  17. Update Diaspora
  18. Want to contribute?

Using a Different System?

  • Build Your Social Network With Diaspora on CentOS 7

Are we missing a guide for your target system? Request one, or submit your own!


Diaspora is a privacy-aware, open source social network. In this tutorial, you will learn how to set up and configure a Diaspora pod on Debian 9.

Prerequisites

  • A Debian 9 server instance.
  • Running an average-sized pod, your server should have, at the very least, 512MB of RAM (+1GB swap space) and a decent multi-core CPU.
  • A sudo user.

Install Prerequisite Packages

First, update the system and install the necessary packages.

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

Install PostgreSQL

Diaspora supports MySQL, MariaDB, and PostgreSQL. In this guide, we will use PostgreSQL.

Install PostgreSQL.

sudo apt-get install PostgreSQL-server

Connect to PostgreSQL with the postgres user.

sudo -u postgres psql

Create a Diaspora user.

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

Add a Dedicated Diaspora User

This is the user account that will run Diaspora.

sudo adduser --disabled-login diaspora

Switch to the new user.

sudo  su - diaspora

Install Ruby

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

First, you will need to install the packages Ruby requires.

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

Install 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_profile

Reconnect to reload the path.

exit
sudo su - diaspora

Install the ruby-build plugin for rbenv to compile Ruby:

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

Install Ruby.

rbenv install 2.4.3
rbenv global 2.4.3

Install Exim4

We will use Exim4 as an SMTP relay to send emails to users.

Install and configure the package.

sudo apt-get install exim4
sudo dpkg-reconfigure exim4-config

Install and configure Diaspora

Clone the source code for Diaspora.

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

Copy the example database configuration file to the location required by Diaspora.

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

Open the database configuration file in a text editor to edit some of the settings.

nano config/database.yml

Change the database settings to match the PostgreSQL user and password that you created earlier.

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

Open the Diaspora configuration file.

nano config/diaspora.yml

You will need to update a few settings in this file for Diaspora to work properly.

  • url: Set the public facing URL to your pod here.
  • certificate_authorities: Remove the leading # to uncomment it.
  • rails_environment: You must set this to production.
  • require_ssl: Set this to false to prevent a redirect from http:// to https://.

Install Required Gems

Install Bundle, the Ruby library manager.

gem install bundler
script/configure_bundler

Note: If you have errors concerning your Ruby version, edit .ruby-version and put your own (here 2.4.3 instead of 2.4).

Setup Database

Create and configure the database.

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

Pre-compile the assets

This rake command will precompile the assets.

RAILS_ENV=production bin/rake assets:precompile

Diaspora systemd Services

There are many ways to manage Diaspora as a service. In this tutorial, we will use Systemd.

First, create the following files.

  • systemd target file: touch /etc/systemd/system/diaspora.target
  • systemd web service file: touch /etc/systemd/system/diaspora-web.service
  • systemd sidekiq service file: touch /etc/systemd/system/diaspora-sidekiq.service

Paste in the following configuration text for each file that you created earlier.

target file:

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

[Install]
WantedBy=multi-user.target

web service file:

[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

sidekiq service file:

[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 boot services.

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

Restart the services.

sudo systemctl restart diaspora.target

Ensure that they are running correctly.

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

Nginx Reverse Proxy

We will use Nginx as a reverse proxy to serve static resources.

We will use acme.sh to get a Let’s Encrypt certificate.

Download the acme.sh source code.

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

Generate a Let’s Encrypt 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.com

Install Nginx.

sudo apt-get install nginx

Create a new Nginx configuration file for our Diaspora pod.

nano /etc/nginx/conf.d/diaspora.conf

Populate the file with the following content.

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;
  }
}

Note: change example.com to your own registered domain name.

After all modifications have been completed, check the configuration file for any errors.

sudo nginx -t

Restart Nginx to apply the changes.

sudo systemctl restart nginx

If you now visit your Diaspora pod’s domain name in your browser (example: https://example.com), you will reach the Diaspora welcome page.

Create a Diaspora User

Click the link in Start by creating an account., and fill in the details to create a new Diaspora user. Then, you will be able to view your user’s home page and start using the Diaspora social network.

After you create an account, give it admin rights:.

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

You now have access to the admin dashboard.

https://example.com/admins/dashboard

Sidekiq

Sidekiq, which handles background jobs processing, has a web interface available at https://example.com/sidekiq. The pod stats are available at https://example.com/statistics.

Logrotate

We will use logrotate to manage Diaspora logs.

Create a new logrotate file for Diaspora.

nano /etc/logrotate/diaspora

Then, add the following lines.

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

This will rotate the logs weekly, compress them, and keep them for 52 weeks.

Update Diaspora

When it comes time to update Diaspora, follow these steps.

First, update the system.

sudo apt-get update
sudo apt-get dist-upgrade

Update the Diaspora source code with git.

su - diaspora
cd diaspora
git pull

Update the gems.

gem install bundler
bin/bundle --full-index

Migrate the database and recompile the assets.

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

Finally, restart Diaspora.

systemctl restart diaspora.target

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

Setting up a Chroot on Debian

Next Post

How to Install FFmpeg on Debian 8 or Debian 9

Next Post

How to Install FFmpeg on Debian 8 or Debian 9

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In
Thabet