Atlantic.Net Blog

How to Install Pleroma Social Network Platform on Ubuntu 20.04

Hitesh Jethva
by Atlantic.Net (243 posts) under Dedicated Server Hosting
0 Comments

Pleroma is a free, open-source and self-hosted social networking platform. It consists of two components, a backend which is called Pleroma and a frontend which is called Pleroma-FE. It is compatible with Mastodon and other ActivityPub implementations.

In this post, we will show you how to install Pleroma with Nginx and Let’s Encrypt SSL on Ubuntu 20.04.

Prerequisites

  • A fresh Ubuntu 20.04 server on the Atlantic.Net Cloud Platform
  • A valid domain name pointed with your server IP.
  • A root password configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Ubuntu 20.04 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your Ubuntu 20.04 server, run the following command to update your base system with the latest available packages.

apt-get update -y

Step 2 – Install Nginx and PostgreSQL

First, install Nginx and PostgreSQL with the following command:

apt-get install postgresql nginx -y

Once both packages are installed, install other dependencies with the following command:

apt-get install wget curl gnupg2 ca-certificates lsb-release gnupg zip libncurses5 libmagic-dev unzip -y

After installing all the dependencies, you can proceed to the next step.

Step 3 – Download Pleroma

First, create a user for Pleroma with the following command:

adduser --system --shell  /bin/bash --home /opt/pleroma pleroma

Next, switch the user to Pleroma and download the latest version of Pleroma with the following command:

su - pleroma
curl "https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job=amd64" -o pleroma_amd64.zip

Next, create a directory for Pleroma and extract the downloaded file to the pleroma directory:

mkdir pleroma
unzip pleroma_amd64.zip -d pleroma

Next, move all the contents from pleroma to /opt/pleroma with the following command:

mv pleroma/release/* /opt/pleroma/

Next, exit from the Pleroma user with the following command:

exit

Next, create other required directories with the following command:

mkdir -p /var/lib/pleroma/{uploads,static}
mkdir -p /etc/pleroma

Next, set proper ownership to all created directories:

chown -R pleroma /var/lib/pleroma /etc/pleroma

Step 4 – Configure Pleroma

Next, switch the user to Pleroma and install the Pleroma using the following command:

su - pleroma
./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql

You will be asked several questions as shown below:

What domain will your instance use? (e.g pleroma.soykaf.com) [] pleroma.linuxbuz.com
What is the name of your instance? (e.g. The Corndog Emporium) [pleroma.linuxbuz.com] 
What is your admin email address? [] [email protected]                                           
What email address do you want to use for sending email notifications? [[email protected]] 
Do you want search engines to index your site? (y/n) [y] y
Do you want to store the configuration in the database (allows controlling it from admin-fe)? (y/n) [n] n
What is the hostname of your database? [localhost] 
What is the name of your database? [pleroma] 
What is the user used to connect to your database? [pleroma] 
What is the password used to connect to your database? [autogenerated] password
Would you like to use RUM indices? [n] n
What port will the app listen to (leave it if you are using the default setup with nginx)? [4000] 
What ip will the app listen to (leave it if you are using the default setup with nginx)? [127.0.0.1] 
What directory should media uploads go in (when using the local uploader)? [/var/lib/pleroma/uploads] 
What directory should custom public files be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)? [/var/lib/pleroma/static] 
Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as not installed, please install it if you answer yes. (y/n) [n] n
Do you want to anonymize the filenames of uploads? (y/n) [n] y
Do you want to deduplicate uploaded files? (y/n) [n] y
Writing config to /etc/pleroma/config.exs.
Writing the postgres script to /tmp/setup_db.psql.
Writing /var/lib/pleroma/static/robots.txt.

 All files successfully written! Refer to the installation instructions for your platform for next steps.

Once Pleroma is installed, exit from the Pleroma user with the following command:

exit

Step 5 – Migrate the Database

Next, log in to PostgreSQL and import the Pleroma database to PostgreSQL:

su - postgres
psql -f /tmp/setup_db.psql

Output:

CREATE ROLE
CREATE DATABASE
You are now connected to database "pleroma" as user "postgres".
CREATE EXTENSION
CREATE EXTENSION
CREATE EXTENSION

Next, exit from the PostgreSQL with the following command:

exit

Next, log in to Pleroma user and migrate the database with the following command:

su - pleroma
./bin/pleroma_ctl migrate

Next, exit from the Pleroma user with the following command:

exit

Step 6 – Install And Configure Let’s Encrypt

First, install the Certbot client with the following command:

apt-get install python3-certbot-nginx -y

Next, stop the Nginx service and download the Let’s Encrypt SSL for your domain with the following command:

systemctl stop nginx
certbot certonly --standalone --preferred-challenges http -d pleroma.linuxbuz.com

Next, copy the sample Pleroma configuration file to the Nginx configuration location:

cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/conf.d/pleroma.conf

Next, replace the word “example.tld” with your domain name in pleroma.conf file:

sed -i 's/example\.tld/pleroma.linuxbuz.com/g'  /etc/nginx/conf.d/pleroma.conf

Next, verify the Nginx for any syntax errors:

nginx -t

Output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Note: If you get this error message, you need to edit the /etc/nginx/nginx.conf file and change the value server_names_hash_bucket_size to 64:

nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed

Next, restart the Nginx service to apply the changes:

systemctl restart nginx

Step 7 – Start Pleroma Service

First, copy the Pleroma service file from the Pleroma directory to the system location:

cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service

Next, start the Pleroma service and enable it to start at system reboot:

systemctl start pleroma
systemctl enable pleroma

Next, check the status of the Pleroma service with the following command:

systemctl status pleroma

You should see the following output:

● pleroma.service - Pleroma social network
     Loaded: loaded (/etc/systemd/system/pleroma.service; disabled; vendor preset: enabled)
     Active: active (running) since Sun 2021-06-20 08:15:21 UTC; 4s ago
   Main PID: 12086 (beam.smp)
      Tasks: 20 (limit: 2353)
     Memory: 129.0M
     CGroup: /system.slice/pleroma.service
             ├─12086 /opt/pleroma/erts-10.7.2.1/bin/beam.smp -- -root /opt/pleroma -progname erl -- -home /opt/pleroma -- -noshell -s elixir s>
             ├─12134 /opt/pleroma/erts-10.7.2.1/bin/epmd -daemon
             └─12137 erl_child_setup 1024

Step 8 – Create an Admin User

Next, you will need to create an admin user for the Pleroma web interface.

First, log in to Pleroma user with the following command:

su - pleroma

Next, create an admin user with the following command:

./bin/pleroma_ctl user new admin [email protected] --password mypassword --admin

You should see the following output:

A user will be created with the following information:
  - nickname: admin
  - email: [email protected]
  - password: mypassword
  - name: admin
  - bio: 
  - moderator: false
  - admin: true

Continue? [n] y
User admin created

Step 9 – Access Pleroma Web Interface

Now, open your web browser and access the Pleroma web interface using the URL https://pleroma.linuxbuz.com. You should see the following screen:
Pleroma Login Page
Provide your admin username, password and click on the Log in button. You should see the Pleroma dashboard on the following screen:

Pleroma Dashboard Page

Conclusion

Congratulations! You have successfully installed and configured Pleroma with Nginx and Let’s Encrypt SSL on Ubuntu 20.04. You can now host your own social networking platform with Pleroma on dedicated hosting from Atlantic.Net.

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources