Home / How To / How to install Diaspora decentralized social media on Debian 10

How to install Diaspora decentralized social media on Debian 10



Diaspora is an open source, privacy-conscious and distributed social network. It consists of a group of independently distributed and owned nodes that work together to create the network. Diaspora is a social network that focuses on three philosophies, decentralization, freedom and integrity.

In this tutorial we will show you how to install Diaspora Distributed Social Network on Debian Buster 10. We install Diaspora using the Nginx Web Server and the PostgreSQL Database Server. In addition, we will secure the Diaspora installation with SSL Letsencrypt.

Conditions

  • Debian Buster 10
  • Min 2 GB RAM
  • Root privileges

What should we do?

  • Install package dependency
  • Create new PostgreSQL user for Diaspora
  • Create new user
  • Install Ruby with RVM (Ruby Version Manager)
  • Install and configure Diaspora decentralized social network
  • Set up Diaspora as a Systemd service
  • Set up Nginx as a reverse proxy for diaspora
  • Testing

Step 1 – Install package dependency

First, we will install some package dependencies for our Diaspora installation, including PostgreSQL, Redis, and Nginx Web Server.

Install package dependency using the apt command below.

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

When all installation is complete, start the PostgreSQL, Nginx and Redis services, and then add everything to system startup.

systemctl start redis-server
systemctl enable redis-server

systemctl start postgresql
systemctl enable postgresql

As a result, some package dependencies for the Diaspora installation have been installed on Debian Buster 10.

Start Redis and PostgreSQL Services

Step 2 – Create new PostgreSQL user for Diaspora

In this step, we change the password for the default user ‘postgres’ and create a new PostgreSQL user for Diaspora.

Log in to the PostgreSQL shell using the ‘psql’ command below.

sudo -i -u postgres psql

Change the password for the default user ‘postgres’ using the following query.

password postgres

Enter your new password now and repeat and the default user password ‘postgres‘has been configured.

Then create a new user ‘diaspora’ with the privilege ‘CREATEDB‘to create a database with the PostgreSQL query below.

CREATE USER diaspora WITH CREATEDB PASSWORD 'yourpassword';

Write ‘OUTPUT‘to log out of the PostgreSQL shell.

Create a new database for Diaspora

As a result, the new PostgreSQL user for Diaspora has been created.

Step 3 – Create a new user

After creating the PostgreSQL database user, we create a new system user called ‘diaspora’ and add it to the sudo group.

Create a new user named ‘diaspora’ and set the password for it with the following command.

adduser --disabled-login Diaspora
passwd diaspora

Now add the ‘diaspora’ user to the ‘sudo’ group.

usermod -a -G sudo diaspora

As a result, the “diaspora” user will be able to run the “sudo” command to obtain the root privileges.

Create system user slide

Step 4 – Install RVM and Ruby

Before proceeding, log in to the ‘diaspora’ user with the command below.

su - diaspora

Then we install RVM (Ruby Version Manager) and install Ruby 2.6 for the user ‘diaspora’.

Add the RVM package GPGP key using the command below.Advertisement

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Impot GPG key for RVM packages

Now install RVM (Ruby Version Manager) with the following command.

curl -sSL https://get.rvm.io | bash -s stable

Enter your ‘diaspora’ user password and press Enter.

When all installation is complete, load the rvm script to your server.

source /home/diaspora/.rvm/scripts/rvm

As a result, you can run the rvm command to install Ruby.

Install RVM Ruby Version Manager

Install Ruby 2.6 with the rvm command below.

rvm install 2.6

When all installation is complete, check your ruby ​​version.

ruby -v

Below is the result you get.

Install Ruby 2.6 with RVM Ruby Version ManagerAdvertisement

As a result, the RVM and Ruby installation under the “diaspora” user has been completed.

Step 5 – Download and configure the diaspora

Before proceeding, make sure you are logged in with the ‘diaspora’ user.

Download the Diaspora source code with the git command and enter it.

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

Now copy the example of the database configuration ‘database.yml’ and the diaspora configuration ‘diaspora.yml’.

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

Then edit the database configuration ‘database.yml’ with vim-editor.

vim config/database.yml

In the database section ‘PostgreSQL’ you change the detailed username and password with your data.

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

Save and close.

Then edit the diaspora configuration ‘diaspora.yml’.

vim config/diaspora.yml

Change the configuration as below and make sure the domain name is with your own.

configuration: ## Section
...
  environment: ## Section
...
    url: "https://pod.hakase-labs.to/"
    certificate_authorities: '/etc/ssl/certs/ca-certificates.crt'
    require_ssl: true
...
  server: ## Section
    rails_environment: 'production'
...

Save and close.

Then install the gem and ruby ​​library needed for Diaspora using the following commands.

gem install bundler
script/configure_bundler
bin/bundle install --full-index

Install Diaspora Library

Then run the database migration for Diaspora.

RAILS_ENV=production bundle exec rake db:create db:migrate

When done, compile the access pipelines of all rails with the following command.

RAILS_ENV=production bin/rake assets:precompile

And the installation of Diaspora has been completed.

Step 6 – Configure the Slideshow as a service

After installing Diaspora, we configure Diaspora as a systemd service.

Now go to the directory ‘/ etc / systemd / system’ and create a new grouping device service file ‘diaspora.target’ using vim-editor.

cd /etc/systemd/system/
vim diaspora.target

Paste the following configuration into it.

[Unit]
Description=Diaspora social network
Wants=postgresql.service
Wants=redis-server.service
After=redis-server.service
After=postgresql.service[Install]
WantedBy=multi-user.target

Save and close.

Then create a new service file for Diaspora named ‘diaspora-web.service’ using vim-editor.

vim diaspora-web.service

Paste the following configuration into it.

[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

Save and close.Advertisement

Advertisement

Then create a new service file ‘diaspora-sidekiq.service’ for the monitoring service using the vim command below.

vim diaspora-sidekiq.service

Paste the following configuration.

[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

Save and close.

Now reload the systemd manager and add all diaspora services to system boot.

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

Set up Diaspora as a Systemd service

Then start the Diaspora service with the command below.

systemctl start diaspora.target

“Diaspora.target” automatically launches other services “diaspora-web.service” and “diaspora-sidekiq.service”.

Check diaspora services with the following command.

systemctl status diaspora-web
systemctl status diaspora-sidekiq

Below is the result you get.

Start Diaspora Service

As a result, Diaspora is now up and running as a systemd service. And finally, the configuration of Diaspora has been completed.

Step 7 – Create SSL Letsencrypt

For this tutorial, we will secure our Diaspora installation with SSL Letsencrypt. in this step we install the certbot tool and generate SSL Letsencrypt for our Diaspora domain installation.

Install Certbot using the apt command below.

sudo apt install certbot

When all installation is complete, generate SSL Letsencrypt for your Diaspora domain name using the certbot command below.

certbot certonly --rsa-key-size 2048 --standalone --agree-tos --no-eff-email --email [email protected] -d pod.hakase-labs.to

Your certificate will now be available in the directory ‘/etc/letsencrypt/live/yourdomain.com/’.

Step 8 – Create new user and download diaspora

In this step, we install and configure the Nginx Web server as a reverse proxy for Diaspora.

Install Nginx using the apt command below.

sudo apt install nginx

When all installation is complete, go to the directory ‘/ etc / nginx / sites-available’ and create a new virtual host configuration ‘diaspora’ using vim-editor.

cd /etc/nginx/sites-available/
vim diaspora

Change the domain name and path to SSL Letsencrypt with your own and then paste it.

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

server {
  listen 80;
  listen [::]:80;
  server_name pod.hakase-labs.to;
  return 301 https://pod.hakase-labs.to$request_uri;

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

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name pod.hakase-labs.to;

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

  ssl_certificate /etc/letsencrypt/live/pod.hakase-labs.to/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/pod.hakase-labs.to/privkey.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_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;
  }
}

Save and close.

Now enable the Diaspora configuration and test the Nginx configuration.

ln -s /etc/nginx/sites-available/diaspora /etc/nginx/sites-enabled/
nginx -t

Make sure there is no error, then restart the Nginx service and add it to system boot.

systemctl restart nginx
systemctl enable nginx

As a result, the configuration of the Nginx web server as a reverse proxy for Diaspora has been completed.

Set up Nginx as a reverse proxy for diaspora

Step 9 – Testing

Open your browser and enter your Diaspora domain name in the address bar.

http://pod.hakase-labs.to/

And you get the standard Diaspora website as below.

Diaspora's website

Click on the link on ‘Create an account‘section.

Now enter your email address, username and password for the first Diaspora account, then click ‘Create Account‘.

Create diaspora account

Upload your profile picture etc and then click on ‘Awesome! Take me to the diaspora‘ button.

Slide profile settings

And you get the Diaspora instrument panel as below.

Diaspora Dashboard

As can be seen, the installation of Diaspora with Nginx Reverse Proxy on Debian Buster 10 has been completed.


Source link