Introduction
Mastodon is a decentralized social network that allows users to create their own communities. It's a powerful platform for fostering engagement and discussions without the restrictions of traditional social media. This guide will walk you through the installation of Mastodon on Debian 11, which can be effectively hosted on a Windows VPS UK for optimal performance.
Prerequisites
- A Debian 11 server with root access
- Basic knowledge of Linux commands
- PostgreSQL and Redis installed
- Node.js and Yarn installed
- Domain name pointed to your server
Step 1: Update Your System
Begin by updating your package index and upgrading existing packages:
sudo apt update && sudo apt upgrade -y
Step 2: Install Dependencies
Install the required dependencies for Mastodon:
sudo apt install -y git curl gnupg2 build-essential libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev zlib1g-dev libpq-dev libgdbm-dev
Step 3: Install PostgreSQL
Install PostgreSQL server:
sudo apt install postgresql postgresql-contrib -y
Create a PostgreSQL user and database for Mastodon:
sudo -u postgres createuser --superuser mastodon
sudo -u postgres createdb -O mastodon mastodon_production
Step 4: Install Redis
Install Redis for caching:
sudo apt install redis-server -y
Start Redis and enable it to run on boot:
sudo systemctl start redis-server
sudo systemctl enable redis-server
Step 5: Install Node.js and Yarn
Install Node.js and Yarn using the following commands:
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install nodejs -y
sudo npm install --global yarn
Step 6: Clone Mastodon Repository
Clone the Mastodon repository from GitHub:
git clone https://github.com/mastodon/mastodon.git ~/mastodon
Navigate to the Mastodon directory:
cd ~/mastodon
Step 7: Install Ruby and Bundler
Install Ruby using rbenv and the required gems:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-installer | bash
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
rbenv install 3.0.0
rbenv global 3.0.0
Now install Bundler:
gem install bundler
Step 8: Install Mastodon Dependencies
Install the required gems and npm packages:
bundle install
yarn install
Step 9: Configure Mastodon
Copy the example configuration file and edit it:
cp .env.production.sample .env.production
nano .env.production
Update the configuration file with your domain name and other necessary settings.
Step 10: Precompile Assets
Precompile assets for production:
RAILS_ENV=production bundle exec rails assets:precompile
Step 11: Start Mastodon
Finally, start Mastodon services:
RAILS_ENV=production bundle exec rails db:migrate
RAILS_ENV=production bundle exec rails server
Step 12: Conclusion
You have successfully installed Mastodon on Debian 11, allowing you to run your own social network. This setup 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 reliability.