Mastodon is a free and open-source, self-hosted social media platform that supports decentralized social networking. This tutorial will guide you step-by-step through the installation process of Mastodon on Fedora Server.
Before starting to install Mastodon, you will need:
The first step is to install the necessary dependencies required to install Mastodon. Open a terminal and run the following command:
sudo dnf install -y curl wget git glibc-langpack-en patch
This installs the required software packages needed to install Mastodon.
Mastodon requires Node.js, and the version of Node.js supplied pre-installed on Fedora may not be compatible with Mastodon. Therefore, we must remove the installed version and install the latest version available.
Remove the installed Node.js using the following command:
sudo dnf remove -y nodejs nodejs-devel
Now download and install the latest version of Node.js using the following command:
curl -sL https://rpm.nodesource.com/setup_lts.x | sudo bash -
sudo dnf install -y nodejs
Verify the installation by checking the Node.js version:
node -v
Mastodon needs Ruby installed on the server for the installation process, and Fedora Server comes with the latest version of Ruby pre-installed.
However, we need to install the Ruby development packages to facilitate the Mastodon installation process. Run the following command to install the Ruby development packages.
sudo dnf install -y gcc make redhat-rpm-config ruby-devel zlib-devel
The next step is to clone the Mastodon Git repository to your Fedora Server. Choose the directory you wish to install Mastodon in, and then run the following command:
git clone https://github.com/tootsuite/mastodon.git ~/mastodon
Once the repository is cloned, we need to navigate to the directory and install all of the necessary Mastodon dependencies. Use the following command to navigate to the directory:
cd ~/mastodon
Mastodon requires several dependencies, including PostgreSQL, Redis, and ImageMagick. Run the following command to install these dependencies:
sudo dnf install -y postgresql-server postgresql-devel redis ImageMagick
Mastodon requires a PostgreSQL instance running to create and manage its database. We will use the PostgreSQL instance running on the Fedora Server for simplicity.
First, initialize the PostgreSQL instance and set it to start automatically on boot:
sudo postgresql-setup –-initdb
sudo systemctl enable postgresql.service
Start the PostgreSQL service using this command:
sudo systemctl start postgresql.service
Next, we need to create a user and database for Mastodon to use. Replace mastodonuser
and mastodondb
with your desired username and database name respectively.
sudo su - postgres
createuser mastodonuser -P --interactive
createdb -O mastodonuser mastodondb
exit
Mastodon requires Redis for caching and background job processing. Start the Redis service and enables it to start automatically at system startup.
sudo systemctl start redis
sudo systemctl enable redis
Now that all necessary dependencies have been installed, and we have created the necessary databases and users, we can install Mastodon. Execute the bundle installation command as shown:
bundle install --deployment --without development test
After the installation is complete, we need to generate a new set of secret keys.
bundle exec rake mastodon:setup
Next, we need to compile assets,
NODE_ENV=production bundle exec rails assets:precompile
After installing all of the dependencies, we are ready to start Mastodon.
systemctl enable --now mastodon-*.service
This command starts all Mastodon services, including the web interface, streaming service, and background tasks. You can now access your Mastodon site via your domain with HTTPS enabled.
Congratulations, you have successfully installed Mastodon on Fedora Server!
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!