How to Install and Configure Diaspora on Alibaba Cloud


  1. You must have Alibaba Cloud Elastic Compute Service (ECS) activated and verified your valid payment method. If you are a new user, you can get a free account in your Alibaba Cloud account. If you don’t know about how to setup your ECS instance, you can refer to this tutorial or quick-start guide. Your ECS instance must have at least 1.5GB RAM and 2 Core processor.
  2. A domain name registered from Alibaba Cloud. If you have already registered a domain from Alibaba Cloud or any other host, you can update its domain nameserver records.
  3. Domain name must be pointed to your Alibaba Cloud ECS’s IP address
  4. Access to VNC console in your Alibaba Cloud or SSH client installed in your PC
  5. Set up your server’s hostname and create user with root privileges.

Setting Up Your Server

Before proceeding with installation of any kind of package, use the following command to update your Ubuntu system. To execute this command, remember to login from non-root user with sudo privileges.

# sudo apt update && sudo apt upgrade
# sudo apt-get install build-essential
# sudo apt-get install libssl-dev
# sudo apt-get install libcurl4-openssl-dev
# sudo apt-get install libxml2-dev
# sudo apt-get install libxslt-dev
# sudo apt-get install imagemagick
# sudo apt-get install ghostscript
# sudo apt-get install curl
# sudo apt-get install libmagickwand-dev
# sudo apt-get install git
# git config --global "Aareez"
# git config --global ""
# sudo apt-get install libpq-dev
# sudo apt-get install autoconf
# sudo apt-get install bison
# sudo apt-get install libyaml-dev
# sudo apt-get install libreadline6-dev
# sudo apt-get install zlib1g-dev
# sudo apt-get install libncurses5-dev
# sudo apt-get install libffi-dev
# sudo apt-get install libgdbm3
# sudo apt-get install libreadline-dev
# sudo apt-get install libgdbm-dev
# sudo apt-get install redis-server
# sudo apt-get install patch
# sudo apt-get install ruby-dev
# sudo apt-get install liblzma-dev

Install Node.js

Node.js is a cross platform open source JS runtime environment that runs JS code outside the browser. A version of Node.js is available in Ubuntu’s default repository. To install Node.js follow the steps below.

# sudo apt-get install nodejs

Install PostgreSQL Database

Diaspora supports PostgreSQL, MySQL and MariaDB. In this tutorial, I will use PostgreSQL.

# sudo sh -c 'echo "deb `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
# wget -q -O - | sudo apt-key add -
# sudo apt-get -y install postgresql postgresql-contrib
# sudo systemctl start postgresql
# sudo systemctl enable postgresql
# sudo -u postgres psql

Install Exim4

To send emails to use, you will need Exim4 as STMP relay. To install Exim4, execute the command below.

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

Install Ruby

To install Ruby, you will use rbenv to manage environment and versions. Execute the following commands to download rbenv and set paths.

# git clone ~/.rbenv
# cd ~/.rbenv && src/configure && make -C src
# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
# git clone ~/.rbenv/plugins/ruby-build
# sudo apt install rbenv
# rbenv install 2.4.3
# rbenv global 2.4.3

Install and Configure Diaspora

To install and configure Diaspora, follow the steps below.

# cd ~
# git clone -b master
# cd diaspora
# cp config/database.yml.example config/database.yml
# cp config/diaspora.yml.example config/diaspora.yml
# sudo nano config/database.yml
# sudo nano config/diaspora.yml
  1. Set public facing url
  2. Uncomment by removing # from start of certificate_authorities
  3. Set value of rails_environment from development to production.
  4. Change require_ssl value from true to false.
  5. Uncomment listen: ‘http://localhost:3000'

Install Gems

Edit .ruby-version file and change value from 2.4 to 2.4.3.

# sudo nano .ruby-version
# sudo gem install bundler
# sudo script/configure_bundler
# sudo bin/bundle install --full-index

Setup Database

Now create and configure database by executing command below.

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

Precompile Assets

To precompile the assets, execute the command below.

# RAILS_ENV=production bin/rake assets:precompile

Diaspora systemd Services

We will manage Diaspora via service. First of all, create the following files: target file, web service file, and sidekiq service file.

# sudo touch /etc/systemd/system/
# sudo touch /etc/systemd/system/diaspora-web.service
# sudo touch /etc/systemd/system/diaspora-sidekiq.service
# sudo nano /etc/systemd/system/[Unit]
Description=Diaspora social network
# sudo nano /etc/systemd/system/diaspora-web.service[Unit]
Description=Diaspora social network (unicorn)
ExecStart=/bin/bash -lc "bin/bundle exec unicorn -c config/unicorn.rb -E production"
# sudo nano /etc/systemd/system/diaspora-sidekiq.service[Unit]
Description=Diaspora social network (sidekiq)
ExecStart=/bin/bash -lc "bin/bundle exec sidekiq"
# sudo systemctl enable diaspora-sidekiq.service diaspora-web.service
# sudo systemctl restart
# sudo systemctl restart diaspora-sidekiq.service
# sudo systemctl restart diaspora-web.service

Install openSSL 1.1.0f

By default, openssl v1.0.2 is installed. But in your Nginx configuration file, you will use ssl_ecdh_curve which requires openssl 1.1.0f or higher, otherwise you will get syntax error. To install openssl, execute the following set of commands.

# cd ~
# wget
# tar -xf openssl-1.1.0f.tar.gz
# cd openssl-1.1.0f
# ./config -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)'
# sudo make
# sudo make install
# openssl version

Install Apache Server

You will be required to install apache server, for this purpose, you will need to follow the steps below.

# sudo apt-get install apache2
# sudo systemctl start apache2
# sudo systemctl status apache2

Install Let’s Encrypt SSL Certificate

Certbot will require port 80 for obtaining new certificate. Hence, in the first step, you will need to stop apache server because apache uses port 80. To do so, execute the command.

# sudo systemctl stop apache2
# sudo apt-get update
# sudo apt-get install software-properties-common
# sudo add-apt-repository ppa:certbot/certbot
# sudo apt-get update
# sudo apt-get install python-certbot-apache
# sudo certbot certonly --standalone --register-unsafely-without-email -d
# openssl dhparam -out /home/aareez/ 2048
# sudo nano /etc/apache2/sites-available/diaspora.conf
<VirtualHost *:80>

RedirectPermanent /
<VirtualHost *:443>

DocumentRoot /home/aareez/diaspora/public
RewriteEngine On RewriteCond %{HTTP_HOST} !^softpedia\.xyz [NC]
RewriteRule ^/(.*)$ https://softpedia\.xyz/$1 [L,R,QSA]

RewriteRule ^/(.*)$ balancer://upstream%{REQUEST_URI} [P,QSA,L]
<Proxy balancer://upstream>
BalancerMember unix://home/aareez/diaspora/tmp/diaspora.sock|http://
ProxyRequests Off
ProxyVia On
ProxyPreserveHost On
RequestHeader set X_FORWARDED_PROTO https
<Proxy *>
Require all granted
<Directory /home/aareez/diaspora/public>
Options -MultiViews
Require all granted
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/
SSLCertificateKeyFile /etc/letsencrypt/live/
SSLCertificateChainFile /etc/letsencrypt/live/
# Based on - consider as global configuration
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCompression off
# sudo a2enmod rewrite
# a2enmod proxy_http
# sudo a2enmod headers
# sudo a2enmod ssl
# sudo a2enmod lbmethod_byrequests
# sudo a2enmod slotmem_shm
# sudo systemctl restart apache2

Start Diaspora Server

To start Diaspora, follow the steps below.

# cd /home/aareez/diaspora
# sudo ./script/server



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website: