Introduction
Mastodon is a decentralized social network platform that allows users to create their own communities. Installing Mastodon with Docker simplifies the deployment process, making it easier to manage and scale. In this guide, you will learn how to install Mastodon on Rocky Linux 9 using Docker, which can be effectively hosted on a Windows VPS UK.
Prerequisites
- A Rocky Linux 9 server with root access
- Docker and Docker Compose installed
- Basic knowledge of Linux commands
Step 1: Update Your System
Start by updating your package index and upgrading existing packages:
sudo dnf update -y
Step 2: Install Docker
If Docker is not installed, you can install it using the following commands:
sudo dnf install -y dnf-utils
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io -y
sudo systemctl start docker
sudo systemctl enable docker
Step 3: Install Docker Compose
To install Docker Compose, run the following commands:
sudo dnf install -y python3-pip
sudo pip3 install docker-compose
Step 4: Clone the Mastodon Repository
Clone the Mastodon repository from GitHub:
git clone https://github.com/mastodon/mastodon.git
Change into the Mastodon directory:
cd mastodon
Step 5: Configure Environment Variables
Create a file named .env.production
based on the example file:
cp .env.production.sample .env.production
Edit the environment variables in .env.production
to suit your setup:
nano .env.production
Make sure to set the following variables:
LOCAL_DOMAIN=yourdomain.com
SECRET_KEY_BASE=your_secret_key
DATABASE_URL=postgres://user:password@db:5432/mastodon_production
REDIS_URL=redis://redis:6379/0
Replace yourdomain.com
and the database credentials with your actual values.
Step 6: Set Up Docker Containers
Run Docker Compose to set up the containers:
docker-compose build
Start the Mastodon services:
docker-compose up -d
Step 7: Database Migration
Run the following command to migrate the database:
docker-compose run --rm web rails db:migrate
Step 8: Precompile Assets
Precompile assets for production:
docker-compose run --rm web rails assets:precompile
Step 9: Access Mastodon
Open your web browser and navigate to http://yourdomain.com
. You should see the Mastodon interface. Follow the on-screen instructions to complete the setup.
Step 10: Conclusion
You have successfully installed the Mastodon social network on Rocky Linux 9 using Docker. This decentralized social media solution can greatly benefit from being hosted on a Windows VPS. For additional options, explore various VPS UK Windows solutions, including Windows Virtual Private Server Hosting and Windows VPS Hosting UK for optimal performance and security.