You decide which services we may enable for analytics, personalization, and external content.
We use cookies and similar technologies on our website to personalize content, embed external media, and better understand how individual areas are used.
Necessary cookies
These entries support essential functions such as security, stability, and form processing.
Optional sections
AnalyticsMarketingPersonalizationExternal media
Your data may be processed with your consent or on the basis of legitimate interests. In the cookie settings, you can reject or explicitly allow each optional category.
Some services process personal data in third countries. By consenting, you also agree to this transfer. You can find more information in our Privacy Policy.
You can reopen and change your selection at any time. · 1.0.2
Setting Up Mastodon on a Linux Server – Launch Your Own Social Networking Platform
Discover how to set up a secure, self-hosted Mastodon social network on Debian-based servers for independent microblogging → Learn more now
10 November 20264 min read0 Views0 helpful
Introduction
Mastodon is free and open-source software for running self-hosted social networking services.
It offers microblogging features similar to the service X (formerly Twitter), provided by a variety of independently operated nodes called instances – each with its own code of conduct, terms of use, privacy policies, privacy settings, and moderation guidelines.
Info
This guide focuses on installation on a Debian-based distro. Examples include Debian and Ubuntu. The instructions vary depending on the operating system used.
FAQ
Frequently asked questions
You need your own domain, a Linux-based server, and a mail server.
Mastodon is free open-source software for running self-hosted social networking services with microblogging features similar to X (formerly Twitter), provided through independently operated instances.
Yes, it is recommended because password login on servers accessible from the internet is a security risk. You can disable it in the web interface under Information -> Access & Security -> Disable Password Login.
It focuses on installation on Debian-based distributions, such as Debian or Ubuntu.
Feedback
Was this article helpful?
Your feedback helps us prioritize and improve content.
0 of 0 Users found this article helpful.
Personal support
Need more help than the guide provides?
Our ZAP support team knows your product — briefly describe your issue and we'll help you personally.
Navigation
Software
System Requirements
To set up a Mastodon instance on your server, you need the following:
Domain
Linux-based server
Mail server
Preparing Your System
It is recommended to disable password login via SSH beforehand, as using password login on servers accessible from the internet poses a security risk.
You can disable this in your server's web interface under Information -> Access & Security -> Disable Password Login.
Then update your packages with the following command:
Let the packages install; this may take some time. Then configure yarn, the package manager for the previously installed Node.js:
bash
corepack enable
yarn set version stable
Installing Ruby
We create a separate user because managing Ruby versions is much easier this way. First, create a user named mastodon with login disabled. Then switch to the mastodon user. Use these commands:
bash
# You can leave the fields empty
adduser --disabled-login mastodon
su - mastodon
Now install the Ruby manager rbenv, which greatly simplifies managing Ruby versions. Install it with these commands:
Now comes the tricky part: the web server configuration. First, create an A record and/or AAAA record in your DNS pointing directly to your server. Alternatively, you can point the root record to your server.
Then copy and enable the Mastodon web server configuration with these two commands:
Edit the file /etc/nginx/sites-available/mastodon with a text editor like vim or nano and replace example.com with your desired domain.
Next, obtain an SSL certificate for your domain easily with:
bash
certbot --nginx -d <your domain>
Enter your domain. You will be asked for some information. At the end, you will be asked whether HTTP requests should be automatically redirected to HTTPS – we recommend enabling this.
Creating the Mastodon Service
Finally, create a Mastodon system service. This is quite straightforward.
Copy the default service configuration into your distribution’s service directory: