Mastodon is a free and open-source social media platform that allows users to communicate with each other in a decentralized manner. In this tutorial, we will go through the steps to install Mastodon on Debian Latest.
Before we begin, you will need:
The first step is to update your Debian system to the latest version. You can do this by running the following commands:
sudo apt-get update
sudo apt-get upgrade
In order to run Mastodon, you will need to install the following software:
You can install these packages by running the following command:
sudo apt-get install -y postgresql postgresql-contrib redis-server nodejs yarnpkg imagemagick ffmpeg
Note that we're installing yarnpkg
specifically, not just yarn
, as the latter may conflict with another package. You can check if yarnpkg is installed by running yarnpkg -v
.
Mastodon is built on the Ruby on Rails framework, so you will need to install Ruby as well. You can do this by running the following commands:
sudo apt-get install -y build-essential libssl-dev libreadline-dev zlib1g-dev
sudo apt-get install -y ruby-full
The next step is to clone the Mastodon GitHub repository and install the necessary Ruby gems. Run the following commands to do so:
sudo apt-get install -y git-core
git clone https://github.com/tootsuite/mastodon.git
cd mastodon
git checkout $(git tag -l | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | tail -n 1)
gem install bundler
bundle install --deployment --without development test
yarn install --pure-lockfile
Now that Mastodon is installed, you need to configure it. Copy the example configuration files and edit them to match your environment:
cp .env.production.sample .env.production
cp config/database.yml.sample config/database.yml
You need to create a PostgreSQL user and database for Mastodon. This can be done by running the following commands:
sudo -u postgres createuser mastodon -P
sudo -u postgres createdb mastodon_production -O mastodon
sudo -u postgres psql -c "ALTER USER mastodon WITH ENCRYPTED PASSWORD 'your_password';"
In the config/database.yml
file, change the username
, password
, and database
fields to match the username, password, and database you just created.
In the .env.production
file, change the REDIS_URL
field to point to your Redis server. It should be in the format redis://your_redis_server:6379/0
.
In the .env.production
file, change the LOCAL_DOMAIN
field to the domain name you want to use for your Mastodon instance. Set the LOCAL_HTTPS
field to true
.
Set up a Let's Encrypt SSL certificate for your domain using Certbot. You can find instructions here. Once you have your SSL certificate installed, set the LOCAL_HTTPS
field to true
in the .env.production
file.
In the .env.production
file, change the SMTP_*
fields to match your email provider's settings. You can also use Sendgrid or Mailgun by setting the corresponding SMTP_SENDGRID_*
or SMTP_MAILGUN_*
fields.
Finally, precompile the Mastodon assets:
RAILS_ENV=production bundle exec rake assets:precompile
Once you've completed the configuration steps, you can start Mastodon:
RAILS_ENV=production bin/tootctl start
Mastodon should now be up and running, accessible from the domain name you specified in the configuration.
That's it! You've now installed Mastodon on your Debian Latest server. Keep in mind that Mastodon is a complex application that requires a significant amount of resources to run smoothly. If you're running Mastodon on a small server, it may take some time to load or respond to requests.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!