DeasileX

How To Set Up A Mastodon Instance On Linux? Steps Explained!

How to Set Up a Mastodon Instance on Linux

Are you not sure how to set up a mastodon instance on Linux? Well, In this article, let us see how to set up a mastodon instance on Linux.

Mastodon is the most popular social networking service as it eliminates the hazards of having your communication monopolized by a single corporation as a decentralized substitute for commercial platforms. Choose a server you can rely on; whichever option you select, you can communicate with other users. Running their own Mastodon instance and engaging in the social network are both completely open to everyone.

To set up a Mastodon instance on Linux, establish an SSH connection and install docker, configure with Docker compose, install Mastodon, add your Mailgun configuration, enable Nginx, get an SSL certificate and run Mastodon.

Continue reading further to understand how to set up a mastodon instance on Linux. 

How To Set Up A Mastodon Instance On Linux?

Mastodon gives you the privilege to run your account on different servers as u like by choosing from the list of available instances, you can also create your own servers and change servers in Mastodon. To set up a mastodon server on Linux, followed the below-mentioned steps carefully:

  • Establish SSH connection and install Docker
  • Configure with Docker Compose
  • Install mastodon
  • Add your Mailgun configuration
  • Enable Nginx
  • Get an SSL certificate and run Mastodon

Establish SSH Connection And Install Docker

Create mastodon user & give root access > Install administrative tools > Obtain GPG key > Include the docker repository > Few lines of text will appear and search for “active (running)”.

Step 1: You must use SSH to connect to your server, and the standard admin credentials must be used to get in. Create a user called “mastodon,” give it root access, and then log in as the new user.

  •  add mastodon user
  •  usermod -aG sudo mastodon
  •  su – mastodon

Step 2: Next, install the administrative tools and update the package database.

  • sudo apt-get update
  • sudo apt-get install apt-transport-https software-properties-common

Step 3: A GPG key is necessary for the Docker repository and may be obtained via.

  • sudo apt-key adv –keyserver hkp://p80.pool.sks-keyservers.net:80 –recv-keys 58118E89F3A912897C070ADBF76221572C52609D

Step 4: Afterward, include the Docker repository in the sources and do another update.

  • sudo apt-add-repository ‘deb https://apt.dockerproject.org/repo ubuntu-xenial main’
  • sudo apt-get update

Step 5: Instead of using the version in the standard Ubuntu 16.04 repository, Docker must be installed in its own repository for this to function properly. This regulation will make sure that this occurs:

  • sudo apt-cache policy docker-engine

Step 6: You can now set up Docker.

  • sudo apt-get install -y docker-engine

Step 7: Please be patient while this finishes. A daemon that launches Docker when the server boots up is part of the installation. Examine the situation with:

  • sudo systemctl status docker

A few lines of text will appear; search for “active (running)” to ensure that everything is in order.

Configure With Docker Compose

Create a new user group > Log out of SSH and back in > Docker Compose is offered > Make sure the version number matches with the one you downloaded.

Step 1: To avoid having to input the Sudo command each time a Docker statement is performed in this configuration, create a new user group. 

  • sudo usermod -aG docker $(whoami)

Step 2: After completing this, log out of SSH and back in.

Step 3: To control the execution of multi-container Docker applications, Docker Compose is offered. You will find the latest release version at github.com/docker/compose/releases. Note the number, as you will need to enter it in the following command, replacing it with “xxx”.

  • sudo curl -o /usr/local/bin/docker-compose -L “https://github.com/docker/compose/releases/download/xxx/docker-compose-$(uname -s)-$(uname – meter)”

Step 4: Make it actionable by:

  • sudo chmod +x /usr/local/bin/docker-compose

Step 5: You may utilize to confirm the installation of Docker Compose.

Step 6: When the version number is displayed, make sure it matches the one you downloaded by looking for the digits you changed.

Install Mastodon

Change to mastodon subdirectory > Mastodon.git should be cloned > Generate 3 secret keys > Paste each key into each text editor.

Step 1: The preparation is complete. Installing Mastodon is now possible. Change to the mastodon subdirectory.

Step 2: Mastodon.git should then be copied to the directory, opened, and the.env.production.sample file should be copied.

  • git clone “https://github.com/tootsuite/mastodon.git” target=”_blank”>https://github.com/tootsuite/mastodon.git
  • cd mastodon
  • cp .send.production.sample .send.production

Step 3: In a moment, you can use that file before that create the Docker image first.

Step 4: It will take some time. You can use this command to generate three secret keys after that is finished:

  • docker-compose run –rm web rake secret

Step 5: Run this three times, pasting each distinct key into a text editor each time. Start nano and run the.env.production file once all three are prepared.

  • sudo nano .env.output

Step 6: The fields PAPERCLIP_SECRET, SECRET_KEY_BASE, and OTP _SECRET should be searched for. One of the hidden keys needs to be placed against each of these.

Add Your Mailgun Configuration

Enter details for your maligun email account > Locate default SMTP login and default password > Add the domain using for this project > Press Ctrl + X > Data migration and asset precompile will function > Turn on the container.

Step 1: It’s time to enter the details for your Mailgun email account. Click on the domain at https://app.mailgun.com/app/domains. To add entries for SMTP_LOGIN and SMTP_PASSWORD in the.env.production file, locate the default SMTP login and default password.

Step 2: Then, verify that the item for SMTP_FROM_ADDRESS contains a name that begins with “notifications,” such as [email protected]. A final step is to add the domain name you are using for this project to LOCAL_DOMAIN.

Step 3: Press CTRL+X to save and exit when finished, then rebuild Docker.

Step 4: The data migration and asset precompile will be guaranteed to function as expected by the following commands.

  • docker-compose run –rm web rails db:migrate
  • docker-compose run –rm active web rails: precompile

Step 5: It will take a while to execute these tasks. When finished, turn on the container.

Enable Nginx

Delete default Nginx profile > create a new profile > Build a symbolic link > Go to the GitHub page to copy content > Click Ctrl + X.

Step 1: In this configuration, Nginx serves as a reverse proxy.

Implement it using:

  • sudo apt-get install nginx

Step 2: You must delete the default profile for Nginx.

  • sudo rm /etc/nginx/available-sites/default
  • sudo rm /etc/nginx/sites-enabled/default

Step 3: Make a fresh profile using:

  • sudo touch /etc/nginx/available-sites/mastodon

Step 4: To access the profile, you must next build a symbolic link:

  • sudo ln -s /etc/nginx/sites-enabled/mastodon /etc/nginx/sites-enabled/mastodon

Step 5: A configuration file is then available for you to copy into the text editor. Go to this GitHub page, copy the content, and then use Sudo nano to put it into the /etc/nginx/sites-available/mastodon directory. Find every instance of example.com in the file while it is open and replace it with the one you are using. Make sure the “www” is missing.

Step 6: To save and leave, click on CTRL+X.

Get An SSL Certificate And Run Mastodon

Launch the mastodon instance with SSL certificate > Install certbot > Nginx should be stopped > enter your domain name > return to mastodon directory > Execute commands and then start Nginx.

Step 1: You may now start your own social network by launching your own Mastodon instance. But you will need an SSL certificate in order to be believed.

Step 2: Install certbot first, and then the certbot PPA after that.

  • sudo add-apt-repository ppa:certbot/certbot
  • sudo apt-get update sudo apt-get install certbot

Step 3: Nginx should then be stopped so that SSL certificates can be created.

  • sudo systemctl stop nginx.service

Step 4: Put your own domain name in place of example.com in the command that comes after this.

  • sudo letsencrypt certonly –standalone -d example.com

Step 5: To finish the procedure, adhere to the instructions. Return to the mastodon directory when finished.

  • cd /home/mastodon/mastodon

Step 6: Just execute these commands all at once because we’re almost done.

  • docker-compose build
  • docker-compose run –rm active web rails: precompile
  • docker-compose run –rm web rails db:migrate
  • docker-compose until -d

Step 7: Wait for these commands to finish, then restart Nginx.

  • sudo systemctl restart nginx.service

By following these steps, you will be able to set up a mastodon instance on Linux. If everything goes according to plan, you should now be able to launch your browser and visit the fresh Mastodon instance on Linux. Note that you won’t be able to run Mastodon until these issues are fixed if your domain is incorrectly configured with your domain registrar and with Mailgun.

Wrapping Up

We hope this guide has given you a detailed explanation on how to set up a mastodon instance on Linux. You can create Mastodon server as well. For more informative and interesting articles, check out our page at Deasilex.

Frequently Asked Questions

Q1. How Much Does It Cost To Run A Mastodon Instance?

Ans. You can have your own Mastodon server for $6 per month.

Q2. How Do You Message On A Mastodon?

Making a text post, often known as a Toot, is the most fundamental way to communicate on Mastodon. Simply type your message into the “What is on your mind?” text box in the Compose column and click “TOOT” to toot.

Q3. What Is An Instance Domain Mastodon?

You log into a certain “instance” on Mastodon. Consider Mastodon as a network of interconnected nodes, with instances representing the particular node where your account is located. Mastodon. social, which has more than 41,700 users, is regarded as the flagship instance.

Q4. How Do I Join A Mastodon Server?

Step 1:  Go to the Mastodon official website.
Step 2:  Choose “Get started” to continue.
Step 3:  Next, pick a server from the list under “category”.
Step 4:  Choose your favorite “Language”.
Step 5:  Depending on the category and language you have chosen, a list of servers will show up on the screen.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top