Guide to Installing Mastodon on Ubuntu 24.04

**Guide to Installing Mastodon on Ubuntu 24.04**

Mastodon offers a decentralized social networking experience, letting users build communities and engage in a secure, private space. If you’re a tech enthusiast eager to create your own social media platform, installing Mastodon on an Ubuntu 24.04 server can be an exciting challenge. This article will provide you with a comprehensive and engaging guide to achieve that.

### Step 1: Setting Up Your Environment

To begin, it’s essential to have an Ubuntu 24.04 server ready. You can opt for a virtual private server (VPS) from providers like DigitalOcean, Linode, or Vultr. Ensure that SSH is installed to facilitate remote server access.

### Step 2: System Update

Log in to your server and update the system with these commands:

sudo apt update
sudo apt upgrade

This ensures all your software packages are up to date.

### Step 3: Install Necessary Packages

Mastodon operates with several required software packages. You’ll need to install `Node.js`, `PostgreSQL`, `Redis`, and `Yarn`. Enter the following commands:

sudo apt install -y curl gnupg2
curl -sSL //deb.nodesource.com/setup_16.x | sudo -E bash –
sudo apt install -y nodejs postgresql redis-server yarn

### Step 4: Creating a PostgreSQL User

As Mastodon uses PostgreSQL for its database, you must create a PostgreSQL user. Execute these commands:

sudo -u postgres createuser –createdb –pwprompt mastodon

When prompted, provide a password for the user. Then, you’ll create a database for Mastodon:

sudo -u postgres createdb –owner mastodon mastodon_production

### Step 5: Download and Configure Mastodon

Next, download the Mastodon source code from GitHub and set it up. Use the following commands:

git clone //github.com/mastodon/mastodon.git ~/mastodon
cd ~/mastodon
git checkout $(git tag | grep -v ‘\-‘ | tail -n 1)

Then, copy the sample configuration file and modify it:

cp .env.development .env
nano .env

Inside the `.env` file, configure your database details along with parameters like `LOCAL_DOMAIN` (for instance, `yourdomain.com`).

### Step 6: Ruby Package Installation

Since Mastodon is built using Ruby on Rails, you need to install Ruby and Bundler:

sudo apt install -y ruby-full build-essential
gem install bundler

Within the Mastodon directory, run this command:

bundle install

### Step 7: Creating Database Tables

To set up the necessary database tables, run these commands:

RAILS_ENV=production rails db:migrate
RAILS_ENV=production rails db:seed

### Step 8: Starting Mastodon

You can now start Mastodon with these commands:

RAILS_ENV=production bundle exec rails assets:precompile
RAILS_ENV=production bin/tootctl feed refresh

Additionally, consider setting up a service to ensure Mastodon starts automatically with the server.

### Conclusion

While setting up Mastodon on an Ubuntu 24.04 server might seem daunting, this comprehensive guide equips you to successfully establish a personalized social media platform. Dive in, explore, and share your newfound knowledge with the community. This is not only a chance to enhance your technological skills, but also to connect with others who share your passions. So why wait? Start today!

Leave a Comment