Mastodon is an open-source, decentralized social network that has gained popularity as a federated platform, allowing users to manage their own communities. In this guide, we will walk you through the process of installing Mastodon using Docker on Rocky Linux 9. Whether you are setting up a local instance or deploying Mastodon on a Windows VPS UK, this tutorial will guide you through the necessary steps to get started.

Step 1: Install Docker and Docker Compose

Before installing Mastodon, you need to ensure Docker and Docker Compose are installed on your Rocky Linux 9 server. Run the following commands to install Docker:


sudo dnf update -y
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf install -y docker-ce docker-ce-cli containerd.io
            

Once Docker is installed, enable and start the Docker service:


sudo systemctl enable docker
sudo systemctl start docker
            

Now install Docker Compose using the following command:


sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
            

Verify the installation by checking the Docker and Docker Compose versions:


docker --version
docker-compose --version
            

This setup prepares your server to run Docker containers, whether locally or on a VPS Windows Servers platform.

Step 2: Set Up Mastodon Docker Environment

Create a directory for Mastodon and navigate into it:

mkdir ~/mastodon && cd ~/mastodon

Clone the Mastodon repository from GitHub:

git clone https://github.com/mastodon/mastodon.git .

Switch to the latest stable release branch:

git checkout $(git tag | grep -v rc | tail -1)

Step 3: Configure Environment Variables

Copy the sample environment configuration file to use for your instance:

cp .env.production.sample .env.production

Edit the .env.production file to configure your domain, email, and database information. Make sure to set up your domain name, for example:


LOCAL_DOMAIN=yourdomain.com
SMTP_SERVER=smtp.yourmailprovider.com
SMTP_PORT=587
SMTP_LOGIN=yourlogin
SMTP_PASSWORD=yourpassword
            

Configure other necessary settings, including database passwords. This configuration ensures Mastodon will work correctly when deployed, whether locally or on a UK VPS Windows hosting solution.

Step 4: Build and Start Mastodon with Docker Compose

Now that the environment is set up, you can build and start the Mastodon containers. Run the following commands to build the containers:


docker-compose build
docker-compose run --rm web rake db:setup
docker-compose run --rm web rake db:migrate
docker-compose run --rm web rake assets:precompile
            

Once the containers are built, start Mastodon:

docker-compose up -d

Mastodon will now be running in the background using Docker. Whether you're deploying locally or using a Windows Virtual Private Server hosting platform, your Mastodon instance will be accessible.

Step 5: Configure Nginx as a Reverse Proxy

To make your Mastodon instance publicly accessible, you can configure Nginx as a reverse proxy. Install Nginx with the following command:

sudo dnf install nginx

After installation, create a configuration file for Mastodon in Nginx:

sudo nano /etc/nginx/conf.d/mastodon.conf

Add the following configuration, replacing yourdomain.com with your domain:


server {
    listen 80;
    server_name yourdomain.com;
    
    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
            

Enable and restart Nginx:


sudo systemctl enable nginx
sudo systemctl restart nginx
            

This will allow users to access your Mastodon instance through your domain, whether it's hosted locally or on a VPS Windows hosting UK platform.

Step 6: Secure Your Mastodon Instance with SSL

For security, you should enable SSL on your Mastodon instance using Let’s Encrypt. Install Certbot and its Nginx plugin:

sudo dnf install certbot python3-certbot-nginx

Obtain the SSL certificate and configure Nginx with the following command:

sudo certbot --nginx -d yourdomain.com

Certbot will automatically configure SSL for your domain, securing your Mastodon instance with HTTPS, whether hosted on a local server or a Windows VPS hosting UK.

Mastodon is now installed and running on Rocky Linux 9, providing a fully functional social network platform. For reliable and scalable hosting, consider using Windows VPS UK. They offer various hosting plans, including windows virtual private servers, windows vps hosting, and windows virtual dedicated server hosting. Whether you're looking for windows vps italy or uk vps windows solutions, their hosting services provide the performance and flexibility needed to support your Mastodon instance.

¿Fue útil la respuesta? 0 Los Usuarios han Encontrado Esto Útil (0 Votos)