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 distributed social network. It consists of a set of independently deployed and owned nodes that can interoperate to create a network. Diaspora is a social network that focuses on the following three philosophies: decentralization, freedom and privacy.

In this tutorial, we will show you how to install Diaspora distributed social network on Debian Buster 10. We will install Diaspora on the Nginx web server and PostgreSQL database server. Most importantly, we will use SSL Letsencrypt to protect the installation of Diaspora.

prerequisites

  • Debian Buster 10
  • 2 GB RAM minimum
  • Root privilege

What will we do?

  • Install package dependencies
  • Create a new PostgreSQL user for Diaspora
  • Create new user
  • Install Ruby using RVM (Ruby Version Manager)
  • Install and configure Diaspora decentralized social network
  • Set Diaspora as a system service
  • Set Nginx as Diaspora’s reverse proxy
  • test

Step 1-install package dependencies

First, we will install some package dependencies for Diaspora, including PostgreSQL, Redis and Nginx web server.

Use the following apt command to install the package dependencies.

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

After completing all installations, start PostgreSQL, Nginx and Redis services, and then add all services to the system boot.

systemctl start redis-serversystemctl enable redis-serversystemctl start postgresqlsystemctl enable postgresql

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

Step 2-create a new PostgreSQL user for Diaspora

In this step, we will change the password of the default “postgres” user and create a new PostgreSQL user for Diaspora.

Log in to the PostgreSQL shell using the “psql” command below.

sudo -i -u postgres psql

Use the following query to change the password of the default user “postgres”.

password postgres

Now, enter the new password and repeat it, then enter the password of the default user”PostgresAlready configured.

Next, create a new user’diaspora’ with permissions of ‘Created‘To create a database using the following PostgreSQL query.

CREATE USER diaspora WITH CREATEDB PASSWORD 'yourpassword';

enter”ExportTo exit the PostgreSQL Shell.

Create a new database for Diaspora

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

Step 3-create a new user

After creating the PostgreSQL database user, we will create a new system user named “diaspora” and add it to the sudo group.

Create a new user named “diaspora” and set a password for it using the following command.

adduser --disabled-login Diasporapasswd 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 gain root privileges.

Create system user diaspora

Step 4-install RVM and Ruby

Before proceeding, use the following command to log in to the “diaspora” user.

su - diaspora

Next, we will install RVM (Ruby Version Manager) and install Ruby 2.6 for the user “diaspora”.

Use the following command to add the GPGP key to the RVM package.

gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Impot GPG key for RVM package

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

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

Enter the password of the “diaspora” user and press Enter.

After all installations are 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

Use the following rvm command to install Ruby 2.6.

rvm install 2.6

Once all installations are complete, please check your ruby ​​version.

ruby -v

Here are the results you will get.

Install Ruby 2.6 using RVM Ruby version manageradvertising

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

Step 5-download and configure Diaspora

Before proceeding, please make sure you are logged in with the “diaspora” user.

Use the git command to download the Diaspora source code and enter.

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

Now, copy the samples of the database configuration “database.yml” and the diaspora configuration “diaspora.yml”.

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

Next, use the vim editor to edit the database configuration’database.yml’.

vim config/database.yml

In the “PostgreSQL” database section, change the detailed user name and password with the data.

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

Save and close.

Next, edit the diaspora configuration “diaspora.yml”.

vim config/diaspora.yml

Change the configuration as follows and make sure to use your own domain name.

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.

Next, use the following commands to install the gem and ruby ​​libraries required by Diaspora.

gem install bundlerscript/configure_bundlerbin/bundle install --full-index

Install Diaspora library

After that, run Diaspora’s database migration.

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

After completing all the steps, use the following command to compile all Rails asset pipelines.

RAILS_ENV=production bin/rake assets:precompile

And the installation of Diaspora has been completed.

Step 6-Set up Diaspora as a service

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

Now go to the “/etc/systemd/system” directory and use the vim editor to create a new group unit service file “diaspora.target”.

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

Paste the following configuration into it.

[Unit]Description=Diaspora social networkWants=postgresql.serviceWants=redis-server.serviceAfter=redis-server.serviceAfter=postgresql.service[Install]WantedBy=multi-user.target

Save and close.

Next, use the vim editor to create a new service file named “diaaspora-web.service” for Diaspora.

vim diaspora-web.service

Paste the following configuration into it.

[Unit]Description=Diaspora social network (unicorn)PartOf=diaspora.targetStopWhenUnneeded=true[Service]User=diasporaEnvironment=RAILS_ENV=productionWorkingDirectory=/home/diaspora/diasporaExecStart=/bin/bash -lc "bin/bundle exec unicorn -c config/unicorn.rb -E production"Restart=always[Install]WantedBy=diaspora.target

Save and close.

advertising

Next, use the vim command below to create a new service file’diaspora-sidekiq.service’ for the monitoring service.

vim diaspora-sidekiq.service

Paste the following configuration.

[Unit]Description=Diaspora social network (sidekiq)PartOf=diaspora.targetStopWhenUnneeded=true[Service]User=diasporaEnvironment=RAILS_ENV=productionWorkingDirectory=/home/diaspora/diasporaExecStart=/bin/bash -lc "bin/bundle exec sidekiq"Restart=always[Install]WantedBy=diaspora.target

Save and close.

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

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

Set Diaspora as a system service

Then use the following command to start the Diaspora service.

systemctl start diaspora.target

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

Use the following command to check the diaspora service.

systemctl status diaspora-websystemctl status diaspora-sidekiq

Here are the results you will get.

Start Diaspora service

As a result, Diaspora is now up and running as a system service. Finally, the configuration of Diaspora is complete.

Step 7-Generate SSL Letsencrypt

For this tutorial, we will use SSL Letsencrypt to secure the installation of Diaspora. In this step, we will install the certbot tool and generate SSL Letsencrypt for Diaspora domain installation.

Use the following apt command to install Certbot.

sudo apt install certbot

After completing all the installations, use the following certbot command to generate SSL Letsencrypt for your Diaspora domain name.

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

Now your certificate will be available in the “/etc/letsencrypt/live/yourdomain.com/” directory.

Step 8-Create a new user and download Diaspora

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

Use the following apt command to install Nginx.

sudo apt install nginx

After completing all the installations, go to the “/etc/nginx/sites-available” directory and use the vim editor to create a new virtual host configuration “diaspora”.

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

Change the domain name and path of SSL Letsencrypt yourself, 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 activate the Diaspora configuration and test the Nginx configuration.

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

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

systemctl restart nginxsystemctl enable nginx

As a result, the configuration of Nginx Web server as Diaspora’s reverse proxy has been completed.

Set Nginx as Diaspora's reverse proxy

Step 9-test

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

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

You will get the default Diaspora homepage as shown below.

Diaspora homepage

Click “create an account‘ section.

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

Create account diaspora

Upload your profile picture, etc., then click “awesome! Take me to the diaspora‘Button.

Diaspora profile settings

You will get the Diaspora dashboard as shown below.

Diaspora dashboard

It can be seen that the installation of Diaspora using Nginx reverse proxy on Debian Buster 10 has been successfully completed.

Source

Sidebar