How to Install Pleroma on Fedora CoreOS

Pleroma is a free, federated social networking platform. It is an alternative to popular social media sites like Twitter and Mastodon. In this tutorial, we will be installing Pleroma on Fedora CoreOS.

Before we begin, make sure you have the following requirements:

Step 1: Install PostgreSQL

Pleroma requires a PostgreSQL database to function. To install PostgreSQL, use the following command:

$ sudo rpm-ostree install postgresql-server

Once PostgreSQL is installed, initialize the database and start the service:

$ sudo postgresql-setup --initdb
$ sudo systemctl start postgresql
$ sudo systemctl enable postgresql

Step 2: Install Elixir

Pleroma is built on the Elixir programming language. Install the required dependencies for Elixir using the following command:

$ sudo rpm-ostree install elixir

Step 3: Install Nginx

Install Nginx to serve as the web server for Pleroma:

$ sudo rpm-ostree install nginx

Start and enable the Nginx service:

$ sudo systemctl start nginx
$ sudo systemctl enable nginx

Step 4: Clone Pleroma

Clone the Pleroma repository from GitHub:

$ git clone https://git.pleroma.social/pleroma/pleroma.git

Change into the Pleroma directory:

$ cd pleroma

Step 5: Configure Pleroma

Run the following commands to install the required dependencies and generate a secret key:

$ mix deps.get
$ mix phx.gen.secret

Copy the generated secret key to the configuration file:

$ cp config/{example.,}secrets.exs
$ nano config/secrets.exs

Add the generated secret key to the configuration file:

config :pleroma, :secret_key_base,
  secret_key_base: "THE_GENERATED_SECRET_KEY"

Configure the PostgreSQL database by editing the config/prod.secret.exs file:

config :pleroma, Pleroma.Repo,
  username: "USER",
  password: "PASSWORD",
  database: "pleroma_prod",
  hostname: "localhost",
  pool_size: 10

Step 6: Build and Start Pleroma

Build the Pleroma application using the following command:

$ MIX_ENV=prod mix deps.get --only prod
$ MIX_ENV=prod mix compile
$ MIX_ENV=prod mix phx.digest
$ MIX_ENV=prod mix release

Start the Pleroma application:

$ _build/prod/rel/pleroma/bin/pleroma start

Step 7: Configure Nginx

To configure Nginx to serve Pleroma, create a configuration file:

$ sudo nano /etc/nginx/conf.d/pleroma.conf

Add the following content to the file:

upstream pleroma {
    server 127.0.0.1:4000;
}

server {
    listen 80;
    server_name YOUR_SERVER_IP_OR_DOMAIN;

    error_page 400 /400.html;
    error_page 401 /401.html;
    error_page 403 /403.html;
    error_page 404 /404.html;
    error_page 500 502 503 504 /500.html;

    root /var/www/html/pleroma;
    index index.html;

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://pleroma;
    }

    location /uploads {
        root /var/lib/pleroma/;
    }

    location /api/streaming {
        fastcgi_pass unix:/run/pleroma/fcgi.socket;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param REQUEST_METHOD $request_method;
        fastcgi_param CONTENT_TYPE $content_type;
        fastcgi_param CONTENT_LENGTH $content_length;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param REQUEST_URI $request_uri;
        fastcgi_param DOCUMENT_URI $document_uri;
        fastcgi_param SERVER_PROTOCOL $server_protocol;
        fastcgi_param GATEWAY_INTERFACE CGI/1.1;
        fastcgi_param SERVER_SOFTWARE nginx;
        fastcgi_param REMOTE_ADDR $remote_addr;
        fastcgi_param REMOTE_PORT $remote_port;
        fastcgi_param SERVER_ADDR $server_addr;
        fastcgi_param SERVER_PORT $server_port;
        fastcgi_param SERVER_NAME $server_name;
        fastcgi_param SCRIPT_FILENAME /var/www/html/pleroma/api/streaming;
        fastcgi_param SCRIPT_NAME /api/streaming;
    }

    location /api/pubsub {
        proxy_pass http://localhost:4242/api/pubsub;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Save and close the file.

Restart Nginx for the changes to take effect:

$ sudo systemctl restart nginx

Conclusion

In this tutorial, we have shown you how to install Pleroma on Fedora CoreOS. Now, you are ready to start using Pleroma and create your own social network. Enjoy!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!