Installing Pleroma on Ubuntu Server
Pleroma is a decentralized social networking platform that uses the ActivityPub protocol to enable users to interact with each other. In this tutorial, we'll show you how to install Pleroma on the Ubuntu Server.
Prerequisites
- A VPS or dedicated server running Ubuntu 18.04 or higher
- A non-root user with sudo privileges
Step 1 - Update the Server
Before we begin, let's make sure our server is up to date.
sudo apt-get update
sudo apt-get upgrade -y
Step 2 - Install Required Dependencies
To run Pleroma, we need to install a few required dependencies:
sudo apt-get install -y \
postgresql \
postgresql-client \
postgresql-contrib \
build-essential \
libjansson-dev \
libssl-dev \
libreadline-dev \
libyaml-dev \
git \
imagemagick \
curl \
sudo
Step 3 - Install Elixir
Pleroma is built with Elixir, so we need to install it first. We’ll use ASDF to manage and install Elixir.
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1
echo -e '\n. $HOME/.asdf/asdf.sh' >> .bashrc
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> .bashrc
Once the installation is complete, close and reopen the terminal, and then install Elixir:
asdf plugin-add elixir
asdf install elixir 1.11.2-otp-23
asdf global elixir 1.11.2-otp-23
Step 4 - Install Pleroma
Clone the Pleroma repository and navigate to the directory:
git clone https://git.pleroma.social/pleroma/pleroma.git ~/pleroma
cd ~/pleroma
We'll now install the dependencies:
mix local.hex --force
mix local.rebar --force
mix deps.get
Configure the Pleroma instance:
mix pleroma.instance gen
Run the database migrations:
sudo -u postgres psql -c "CREATE ROLE pleroma WITH LOGIN PASSWORD 'pleroma';"
sudo -u postgres psql -c "CREATE DATABASE pleroma WITH OWNER = pleroma;"
sudo -u postgres psql -c "ALTER ROLE pleroma CREATEDB;"
sudo -u postgres psql -c "ALTER DATABASE pleroma OWNER TO pleroma;"
sudo -u postgres psql -d pleroma -c "CREATE EXTENSION IF NOT EXISTS citext;"
MIX_ENV=prod mix ecto.migrate
Step 5 - Configure Nginx
Pleroma uses Nginx as a reverse proxy. We need to configure it to forward requests to Pleroma.
Install Nginx:
sudo apt-get install -y nginx
Remove the default Nginx configuration:
sudo rm /etc/nginx/sites-enabled/default
Create a new Pleroma configuration file:
sudo nano /etc/nginx/sites-available/pleroma
Add the following configuration:
upstream pleroma {
server 127.0.0.1:4000;
}
server {
listen 80;
server_name yourdomain.com;
root /home/yourusername/pleroma;
location /.well-known {
root /home/yourusername/pleroma/priv/static/;
}
location / {
proxy_pass http://pleroma;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location /proxy/ {
proxy_pass http://pleroma;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}
Save and close the file. Enable the configuration:
sudo ln -s /etc/nginx/sites-available/pleroma /etc/nginx/sites-enabled/pleroma
Restart Nginx to apply the changes:
sudo systemctl restart nginx
Step 6 - Start Pleroma
We're now ready to start Pleroma:
MIX_ENV=prod mix pleroma.server
And that’s it! You’ve installed Pleroma on Ubuntu Server.
You can now access Pleroma in your web browser by entering your server's IP address or domain name in the address bar.
Conclusion
In this tutorial, we've shown you how to install Pleroma on Ubuntu Server. With these steps, you can now get started with building your own decentralized social networking platform.