Docs / CMS & Website Platforms / How to Set Up Mastodon Social Network on a VPS

How to Set Up Mastodon Social Network on a VPS

By Admin · Mar 1, 2026 · Updated Apr 23, 2026 · 28 views · 2 min read

What Is Mastodon?

Mastodon is a free, open-source decentralized social network. It allows you to host your own instance that can federate with thousands of other servers across the Fediverse. Users enjoy a Twitter-like experience with 500-character posts, media sharing, and granular privacy controls.

Requirements

  • A Breeze with at least 4 GB RAM and 2 CPU cores
  • Ubuntu 22.04 or later
  • A domain name with DNS pointed to your Breeze
  • An SMTP email service for user notifications

Step 1: Install System Dependencies

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget gnupg apt-transport-https lsb-release ca-certificates
sudo apt install -y imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev \
  file git g++ make libicu-dev libidn11-dev libreadline-dev libssl-dev \
  libyaml-dev zlib1g-dev libgdbm-dev libncurses5-dev libffi-dev

Step 2: Install Node.js, PostgreSQL, and Redis

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs postgresql redis-server
sudo npm install -g yarn

Step 3: Create the Mastodon User and Database

sudo adduser --disabled-login --gecos 'Mastodon' mastodon
sudo -u postgres psql -c "CREATE USER mastodon CREATEDB;"

Step 4: Install Ruby and Mastodon

sudo su - mastodon
git clone https://github.com/mastodon/mastodon.git ~/live
cd ~/live
git checkout $(git tag -l | grep -v rc | tail -n 1)
bundle config deployment true
bundle config without development test
bundle install -j$(getconf _NPROCESSORS_ONLN)
yarn install --pure-lockfile

Step 5: Run the Setup Wizard

RAILS_ENV=production bundle exec rake mastodon:setup

The wizard will ask for your domain, database settings, Redis connection, SMTP configuration, and will create the first admin account. It also prepares the database and precompiles assets.

Systemd Services

sudo cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming

Nginx and SSL

Copy the provided Nginx configuration and obtain a certificate:

sudo cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon
sudo ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/
sudo certbot --nginx -d social.yourdomain.com

Was this article helpful?