Free and open-source, Mastodon is a decentralized social media network where users can run their own instances and communicate with others. Thanks to its foundation in the ActivityPub protocol, users of various Mastodon instances(installations) may easily communicate and exchange ideas, media, and more with one another.
1.1 Benefits of setting up a Mastodon server
A Mastodon server gives you the power to manage your own data and privacy settings, adjust your social media experience, and create your own online community. Using a Mastodon server, you may create a social network that reflects your ideals and connect with link-minded users.
1.2 Purpose of the blog post
The purpose of this article is to provide comprehensive instructions for installing your very own Mastodon server. We’ll cover everything from the basics to advanced topics including community development and instance tweaks. Read this instruction and you’ll be using Mastodon in no time, regardless of your level of technical expertise.
What is Mastodon?
2.1 Overview of Mastodon
Mastodon is a decentralized social networking platform with the goal of providing an alternative to existing social media platforms that is more accessible, user-friendly, and secure. It is designed to cooperate with a distributed system of instances, each of which is managed by a distinct entity. The result is a decentralized and federated design, in contrast to the centralized nature of most social networking sites.
2.2 Comparison to other social media platforms
Mastodon varies significantly from other competing social media platforms in a number of important areas. Unlike other social media platforms, Mastodon is neither owned or managed by a central authority, and it does not rely on a single stumbling block. Mastodon users have considerable autonomy over their personal information and privacy settings, and they may alter their social media behavior to suit their taste. As opposed to other social media platforms, Mastodon has a clear code of behavior and a guarantee to encourage communities that are accessible to everyone.
2.3 Key features of Mastodon
Some of the key features of Mastodon include:
- Decentralization and privacy: Mastodon is not run by a single entity, as its system is decentralized. A further benefit of Mastodon is that it places the power of information and privacy in the hands of its users.
- Customization: When using Mastodon, users may personalize the platform to their preference by adjusting the settings and installing additional themes and plugins.
- Code of conduct: Mastodon has rules that everyone must follow, and these rules promote friendly and open communities.
- Interoperability: Mastodon is based on the ActivityPub protocol, which facilitates communication and content sharing across independent Mastodon instances.
Setting Up Your own Mastodon Server
3.1 Prerequisites
Hosting Requirements
- VPS - With root access, you may host your Mastodon instance on a VPS running either Ubuntu 20.04 or Debian 11. Mastodon’s server-side code will continuously operate in the background. On the other hand, you can run it using a docker-compose configuration, which is a type of containerization that allows you to package up an application with all of its dependencies and share multi-container applications on any server.
- Domain name - It enables others to easily connect to your server and learn about your instance. Domain name registration is a simple process. When you’ve already purchased a server, it’s a simple matter of clicking a few buttons.
- Email provider - Mastodon relies on an email provider to give out important notifications and confirmation links to the community. In addition, administrators must configure an SMTP server or email delivery service for that. It is recommended to configure NGINX(can proxy SMTP protocol) to host mail accounts in order to be used as a single endpoint for email users.
- Additional storage - Having extra disk space is always a good backup as Mastodon saves data on the hard drive of your VPS host. Given that, anything with an API that can communicate with S3 or OpenStack Swift, such as Amazon S3, Exoscale, Wasabi, Google Cloud, etc.
3.2 Prerequisite software and tools
A solid web server is essential, but you’ll also need specific programs and other tools to get it going. These include things like docker-compose, postgreSQL, nginx, TLS certificate. How to install them into your server are explained thoroughly in the following steps:
- Setting up Mastodon:
To download the Mastodon code you must switch to the user Mastodon in the following command line:
su - mastodon
Now, you will need to clone the Mastodon Git repository into the home directory using the following command line:
git clone https://github.com/mastodon/mastodon.git live && cd live
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
Where all commands related to Docker Compose should be executed.
- Set up docker-compose configuration:
It is recommended to use the docker-compose configuration as it will help you build and share multi-container applications(services) containing your database, redis(Remote Dictionary Server), etc. You can configure all of this by simply manually configuring a single YAML file. A sample of this file to guide you through can be found here:
https://github.com/mastodon/mastodon/blob/main/docker-compose.yml
Also, Mastodon runs based on several environment variables for its configuration, to customize your instance and make it unique you’ll have to manually edit an env.production file to be placed in the Mastodon repository later on. A sample of this file for you to use as an example can be found here:
https://github.com/mastodon/mastodon/blob/main/.env.production.sample
3.3 Installation and Configuration
Setting up the server
The process of setting up a server includes preparing the hosting environment, installing the required software and tools, which was already covered. Now, you have to set up HTTPS Proxy as the installation does not have https enabled by itself. For that, you will need NGINX to enable it for you through reverse proxy. Your reverse proxying configuration should be largely based on the following example provided by Mastodon:
https://github.com/mastodon/mastodon/blob/main/dist/nginx.conf
Optional Features
One of the optional features Mastodon supports is the full-text search, however the docker-compose configuration covered earlier makes elasticsearch optional. If you want to enable it to support full text search it is explained thoroughly in the following Mastodon blog post:
https://docs.joinmastodon.org/admin/optional/elasticsearch/
Using a different domain name for Mastodon
Additionally, if your available domain is different from the url used in the mastodon usernames you will have to write an additional entry on your main domain in the nginx settings. To add that you should take a look at the following Mastodon Production Guide:
https://github.com/felx/mastodon-documentation/blob/master/Running-Mastodon/Production-guide.md
Conclusion
5.1 Recap of the Key Points Covered
In this post, we covered how to install and configure your very own Mastodon server. We began by discussing the main functions of Mastodon. Finally, we went on to discuss your server’s prerequisites, installation, and initial setup.
5.2 Final Thoughts and Next Steps
Creating your own Mastodon server is a fun and rewarding way to take charge of your online social life. If you’re patient and have a basic understanding of technology, you can set up your own Mastodon instance in no time. Once your Mastodon server is up and running, the next step is to promote it so that you can attract additional users and grow a thriving community of like-minded people.
5.3 Additional Resources for Further Learning
If you’re looking for additional resources to help you set up your Mastodon server or learn more about Mastodon, make sure to read the Mastodon documentation, community, blog, and GitHub repository for further information.
References:
- “Running Your Own Server On Mastodon And The Fediverse | Fedi.Tips – An Unofficial Guide To Mastodon And The Fediverse “. Fedi.Tips, 2023, https://fedi.tips/running-your-own-server-on-mastodon-and-the-fediverse/#HowDoICreateMyOwnServer.
- “Mastodon Documentation”. Docs.Joinmastodon.Org, 2022, https://docs.joinmastodon.org/.
- “Running Your Own Server - Mastodon Documentation”. Docs.Joinmastodon.Org, 2022, https://docs.joinmastodon.org/user/run-your-own/.
- Preparing your machine - Mastodon documentation “Preparing Your Machine - Mastodon Documentation”. Docs.Joinmastodon.Org, 2022, https://docs.joinmastodon.org/admin/prerequisites/.
- “Installing From Source - Mastodon Documentation”. Docs.Joinmastodon.Org, 2022, https://docs.joinmastodon.org/admin/install/#setting-up-nginx.
- Configuring your environment - Mastodon documentation “Configuring Your Environment - Mastodon Documentation”. Docs.Joinmastodon.Org, 2023, https://docs.joinmastodon.org/admin/config/.
- Configuring nginx as a mail proxy server (no date) NGINX Docs. Available at: https://docs.nginx.com/nginx/admin-guide/mail-proxy/mail-proxy/