How VPS - How to use/setup VPS
  • 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
26
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
How VPS

How VPS

Related Posts

Debian

How to Install WonderCMS on Debian 9

November 1, 2019
Debian

Using MySQL Views on Debian 7

November 1, 2019
Debian

How to Install and Configure TaskBoard on Debian 9

November 1, 2019
Next Post

How to Install FFmpeg on Debian 8 or Debian 9

How to Install BlogoText CMS on a Debian 9 LAMP VPS

How to Install Kolab Groupware on Debian 8

Leave a Reply Cancel reply

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

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

Setup a TeamTalk Server on Linux

3 years ago

Setup Timezone and NTP on Ubuntu 14.04

3 years ago

Mount a Remote File System with SSHFS on CentOS 6

3 years ago

Switching From Windows to Nix or a Newbie to Linux – 20 Useful Commands for Linux Newbies

4 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • 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

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

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

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

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
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • 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”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • 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

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

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