Bringing the Social Network Revolution to Your Own Server: A Step-by-Step Guide to Setting Up Your Mastodon Instance

In the world of social media, Mastodon is a unique platform that's gaining popularity as a decentralized alternative to the big players like Twitter and Facebook. The platform runs on open-source software, allowing users to host their own instances, much like how WordPress powers countless personal blogs.

If you're interested in joining the Mastodon community and setting up your own instance, this guide will take you through the process step by step. Here's what you'll need to get started:

  1. A server: This can be a virtual private server (VPS) or a dedicated server that you rent from a hosting provider. It should have at least 1 GB of RAM and 100 GB of storage.
  2. A domain name: You'll need a domain name that will be used to access your Mastodon instance.
  3. A basic understanding of Linux commands: You'll need to be comfortable with using the terminal to set up your Mastodon instance.

With these three things in hand, let's get started.

Step 1: Install Required Software

Before you can launch your Mastodon instance, you'll need to install some required software. The software you'll need to install depends on the operating system you're using, but for this guide, we'll assume you're using a Debian-based distribution of Linux.

To start, log into your server and update your package lists:

sudo apt update
sudo apt upgrade

Next, install the required dependencies:

sudo apt install git curl ruby ruby-dev zlib1g-dev libpq-dev nodejs yarn postgresql postgresql-contrib redis-server

Step 2: Create a PostgreSQL Database

Mastodon uses PostgreSQL as its database, so you'll need to create a database and a user for Mastodon to use. To do this, log into the PostgreSQL shell:

sudo -u postgres psql

Next, create a database user:


And create a database for Mastodon:

CREATE DATABASE mastodon_production OWNER mastodon;

Exit the PostgreSQL shell:


Step 3: Clone Mastodon from GitHub

The next step is to clone Mastodon from GitHub to your server. To do this, run the following command:

git clone

This will create a mastodon directory containing the Mastodon code.

Step 4: Launch Mastodon

Once you have completed the above steps, you can now proceed to launch your Mastodon instance. This process involves setting up the environment, installing dependencies, and configuring the application to ensure that it runs smoothly. To get started, you'll need to run a few commands in the terminal.

The first command you'll run sets up the environment and installs all the necessary dependencies. This can take a few minutes to complete, so be patient. In the terminal, type the following:

cd ~/live

Once the setup process is complete, you'll need to configure the application by creating a configuration file. This file contains all the settings required to run Mastodon, including database credentials, email settings, and more. To create the configuration file, run the following command:

RAILS_ENV=production bundle exec rake mastodon:setup

You'll be prompted to enter the necessary information for the configuration file. This includes database credentials, email settings, and more. Once you have entered all the required information, the configuration file will be created.

Finally, you can launch Mastodon by running the following command:

RAILS_ENV=production bundle exec rails s -b

This command starts the Mastodon application, and you should now be able to access it by visiting http://your-server-ip:3000 in your web browser. If everything has been set up correctly, you should see the Mastodon login page.

Congratulations! You now have your own Mastodon instance up and running. You can customize it to suit your needs, and invite users to join your social network. Enjoy!