Skip to content

Instantly share code, notes, and snippets.

@imolein
Last active February 4, 2018 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imolein/c5c9c7f89c3510b56dee82490816e10b to your computer and use it in GitHub Desktop.
Save imolein/c5c9c7f89c3510b56dee82490816e10b to your computer and use it in GitHub Desktop.

!!! Outdated !!!

Please visit https://git.pleroma.social/pleroma/pleroma/wikis/home for up to date guides.

How to install PleromaBE

Pleroma is a lightwight OStatus implementation, written in Elixir by lain and others. It's currently in Beta status.

This guide was written during an installation on Ubuntu 16.04, but I think this should work for Debian too.

Dependencies

  • git
  • make
  • gcc
  • nginx
  • postgres
  • erlang-dev
  • erlang-parsetools
  • elixir

Install dependencies

  • Download and install the erlang repository package
wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb \
&& sudo dpkg -i erlang-solutions_1.0_all.deb
  • Update the package lists: apt update
  • Install erlang and elixir: apt install elixir erlang-dev erlang-parsetools
  • Install the remaining dependencies: apt install git make gcc nginx postgresql

Prepare the system

Configure nginx

Example config with redirect from http to https and letsencrypt:

server {
        listen 80 default;
        listen [::]:80 default;
        server_name p.example.com;

        return 301 https://$host$request_uri;
}

server {
  listen 443 ssl;
  listen [::]:443 ssl;
  server_name p.example.com;

  ssl_certificate /etc/letsencrypt/certs/p.example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/certs/p.example.com/privkey.pem;

  root /var/www/pleroma/priv/static/;

# set max upload size
  client_max_body_size 5M;
  fastcgi_buffers 64 4K;

# Lets encrypt
  location ^~ /.well-known/acme-challenge/ {
      allow all;
      auth_basic off;
      alias /var/www/dehydrated/;
  }

  location /media {
          alias /var/www/pleroma/uploads;
  }

  location / {
          proxy_http_version 1.1;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_set_header X-Cluster-Client-Ip $remote_addr;

# The Important Websocket Bits!
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_pass http://127.0.0.1:4000;
  }
}

Restart nginx after you safed the configuration.

Create Database

root@p.example.com# su postgres

postgres@p.example.com# createuser --interactive -P pleroma
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) y

postgres@p.example.com# createdb -O pleroma pleroma_dev

SUPERUSER rights are needed, otherwise you get an error during the installation.

Clone the git, configure, install and run

  • Clone the git to your favorited location, for example /var/www/pleroma
cd /var/www
git clone https://gitgud.io/lambadalambda/pleroma.git
  • Go into the folder: cd pleroma
  • Edit config/dev.exs and insert your url and database settings
watchers: [],
url: [host: "p.example.com", scheme: "https", port: 443]
  • Save the file and then run mix ecto.create and answer the questions with Y
    • During the installation of hex it'll show the following error message:
    the dependency is not available, run "mix deps.get"
    
    • So run mix deps.get and when it's done run mix ecto.create again
    • You can ignore the warning warning: the dependency :calendar requires Elixir "~> 1.4.0-dev or ~> 1.3.0 or ~> 1.3.0-rc.1" but you are running on v1.5.0 which will appear, if Elixir 1.5 ist used
  • After that run mix ecto.migrate, which will show an error when it's executed the first time:
** (RuntimeError) oid `16590` was not bootstrapped and lacks type information
    (ecto) lib/ecto/adapters/postgres/connection.ex:86: Ecto.Adapters.Postgres.Connection.prepare_execute/5
    (ecto) lib/ecto/adapters/sql.ex:243: Ecto.Adapters.SQL.sql_call/6
    (ecto) lib/ecto/adapters/sql.ex:431: Ecto.Adapters.SQL.execute_and_cache/7
    (ecto) lib/ecto/repo/queryable.ex:130: Ecto.Repo.Queryable.execute/5
    (ecto) lib/ecto/repo/queryable.ex:35: Ecto.Repo.Queryable.all/4
    _build/dev/lib/pleroma/priv/repo/migrations/20170719152213_add_follower_address_to_user.exs:20: Pleroma.Repo.Migrations.AddFollowerAddressToUser.up/0
    (stdlib) timer.erl:197: :timer.tc/3
    (ecto) lib/ecto/migration/runner.ex:26: Ecto.Migration.Runner.run/6
    (ecto) lib/ecto/migrator.ex:127: Ecto.Migrator.attempt/6
    (ecto) lib/ecto/migrator.ex:72: anonymous fn/4 in Ecto.Migrator.do_up/4
    (ecto) lib/ecto/adapters/sql.ex:620: anonymous fn/3 in Ecto.Adapters.SQL.do_transaction/3
    (db_connection) lib/db_connection.ex:1275: DBConnection.transaction_run/4
    (db_connection) lib/db_connection.ex:1199: DBConnection.run_begin/3
    (db_connection) lib/db_connection.ex:790: DBConnection.transaction/3
    (ecto) lib/ecto/migrator.ex:250: anonymous fn/4 in Ecto.Migrator.migrate/4
    (elixir) lib/enum.ex:1255: Enum."-map/2-lists^map/1-0-"/2
    (elixir) lib/enum.ex:1255: Enum."-map/2-lists^map/1-0-"/2
    (ecto) lib/mix/tasks/ecto.migrate.ex:84: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
    (elixir) lib/enum.ex:675: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:675: Enum.each/2
    ```
Just run the command again and then it'll run till the end.
* Now run `mix phx.server` to run Pleroma and if your nginx is running, you'll be able to open Pleroma in a browser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment