How to Install Misskey on Debian Latest

Misskey is a decentralized, open-source, and feature-rich social networking platform. It allows users to share and interact with content in a safe, decentralized environment. In this tutorial, we’ll walk you through the process of installing Misskey on Debian Latest using Docker.

Prerequisites

Before you begin, make sure you have the following:

Step 1: Create a New User

The first step is to create a new non-root user on your server. Run the following command to create a new user:

adduser misskey

Set a strong password, and fill out the additional information as necessary.

Step 2: Install Docker and Docker Compose

Next, install Docker and Docker Compose. You can do this by following these steps:

Step 2.1: Install Docker

Update your system package manager and install the required dependencies:

apt-get update
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y

Add the Docker GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

Add the Docker repository:

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

Update the repository and install Docker:

apt-get update
apt-get install docker-ce -y

Step 2.2: Install Docker Compose

Download the Docker Compose binary:

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

Make the binary executable:

chmod +x /usr/local/bin/docker-compose

Verify the Docker Compose installation by running the following command:

docker-compose --version

You should see a version number printed on the console.

Step 3: Set Up the Database

Misskey requires a MariaDB or MySQL database to store its data. You can use Docker to set up a database container for this purpose.

Step 3.1: Create a Database

Create a new database and user for Misskey:

mysql -u root -p

Enter the MariaDB root password when prompted to log in to the MySQL shell.

CREATE DATABASE misskey;
GRANT ALL PRIVILEGES ON misskey.* TO 'misskey'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

Make sure to replace password with a strong password of your choice.

Step 3.2: Run a Database Container

Create a new directory for the database container:

mkdir /opt/db
cd /opt/db

Create a new docker-compose.yml file with the following content:

version: "3.9"

services:
  db:
    image: mariadb
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: misskey
      MYSQL_USER: misskey
      MYSQL_PASSWORD: password
    volumes:
      - db_data:/var/lib/mysql

volumes:
  db_data:

Make sure to replace rootpassword and password with strong passwords of your choice.

Start the database container by running the following command:

docker-compose up -d

Step 4: Install Misskey

Now that you have set up a database container, you can proceed to install Misskey. We’ll use Docker Compose to set up a container for Misskey.

Step 4.1: Create a Directory for Misskey

Create a new directory for Misskey:

mkdir /opt/misskey
cd /opt/misskey

Step 4.2: Create a Configuration File

Create a new config.yml file with the following content:

sharedSecret: s3cr3t
passwordSalt: salt
allowBots: false

Make sure to replace s3cr3t and salt with secure values of your choice.

Step 4.3: Create a Docker Compose File

Create a new docker-compose.yml file with the following content:

version: "3.9"

services:
  app:
    image: misskey/misskey:latest
    restart: always
    environment:
      DATABASE_URL: mysql://misskey:password@db:3306/misskey
      NODE_ENV: production
      CONFIG_DIR: /config
      CREATE_ADMIN_ACCOUNT: true
      ADMIN_USERNAME: admin
      ADMIN_EMAIL: admin@example.com
      ADMIN_PASSWORD: adminpassword
      ADMIN_HOST: example.com
      DOMAIN: example.com
      MAIL_DRIVER: smtp
      MAIL_FROM: admin@example.com
      MAIL_HOST: smtp.example.com
      MAIL_PORT: 587
      MAIL_USERNAME: smtp_username
      MAIL_PASSWORD: smtp_password
    volumes:
      - app_data:/misskey
      - ./config.yml:/config/config.yml

  nginx:
    image: nginx:latest
    ports:
      - "80:80"
      - "443:443"
    restart: always
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - app_data:/misskey
      - /etc/letsencrypt:/etc/letsencrypt

  certbot:
    image: certbot/certbot:latest
    volumes:
      - /opt/letsencrypt:/etc/letsencrypt
    command: certonly --webroot --webroot-path=/var/www/certbot --email admin@example.com --agree-tos --no-eff-email --force-renewal -d example.com

volumes:
  app_data:

Make sure to replace the values for password, adminpassword, example.com, admin@example.com, smtp_username, and smtp_password with the appropriate values for your setup.

The above Docker Compose file sets up the following components:

Step 4.4: Create a Nginx Configuration File

Create a new nginx.conf file with the following content:

user nginx;

worker_processes auto;
error_log /dev/stderr notice;

events {
  worker_connections 1024;
}

http {
  server {
    listen 80;
    listen [::]:80;
    server_name example.com;

    location /.well-known/acme-challenge/ {
      root /var/www/certbot;
    }

    location / {
      return 301 https://$host$request_uri;
    }
  }

  server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name example.com;

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;

    location / {
      proxy_pass http://app:5000/;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header X-Real-IP $remote_addr;
    }
  }
}

Make sure to replace the values for example.com with your own domain.

Step 4.5: Start the Misskey Container

Start the Misskey container by running the following command:

docker-compose up -d

Misskey should now be up and running!

Step 5: Access and Secure Misskey

Step 5.1: Access Misskey

Open your web browser and navigate to https://example.com. Misskey should now be accessible.

Step 5.2: Secure Misskey

You should take the following steps to secure your Misskey instance:

Conclusion

Congratulations! You’ve successfully installed Misskey on Debian Latest using Docker. With Misskey, you can enjoy a decentralized and secure social networking experience.

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!