How to install Misskey in Ubuntu 22.04 (Manual without Docker)

Step-by-step installing Misskey, an open-source social media platform that has been making waves in the world of fediverse enthusiasts
On this page

Misskey is an open-source social media platform that has been making waves in the world of fediverse enthusiasts. As someone who has recently discovered Misskey, I can confidently say that it has quickly become my favorite social media platform. From its customizable interface to its community-driven approach, Misskey offers a unique and refreshing experience for users.

In this article, I want to share my experience installing Misskey. There are several ways to create / deploy Misskey instance, from using Docker to manually install all required dependencies. In tis article I choose to use manual installation method.

Why use the manual installation method, when there is an easier way using docker?

  1. Overhead. Because running a containerized app inside a containerized operating system can create additional layers of abstraction, which can lead to increased overhead and reduced performance. This is because each layer adds a small amount of overhead, and the more layers you have, the more overhead you will incur.
  2. I want to run multiple Misskey instance under one linux container. Imagine if I run 5 instances and in the same time I should install and run containerized NodeJS and PostgreSQL for each instance.

While running containerized apps inside a containerized operating system can be a convenient way to manage applications, it may not always be the most optimal approach from a performance perspective.

Requirements

  • NodeJS 18.13.x (we will use NVM for this)
  • PostgreSQL 15.x
  • Redis
  • FFmpeg
  • PM2 (optional)

Install PostgreSQL 15

PostgreSQL 15 is not available in official Ubuntu 22.04, you need to enable it’s official repository from PostgreSQL itself.

1sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
2wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
3sudo apt update
4sudo apt install postgresql postgresql-client -y

Don’t forget to start PostgreSQL and make it run on system startup.

1sudo systemctl status postgresql
2sudo systemctl enable postgresql

Install Redis and FFmpeg

Simply run :

1sudo apt install redis ffmpeg

make sure to start Redis and make it run on system startup.

1sudo systemctl start redis-server.service
2sudo systemctl enable redis-server.service

Install NodeJS 18 using NVM

Install NVM and nodeJS as regular user. Running commands below as root is not recommended!

Download and run NVM install script:

1curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

When the script is executed, it clones the nvm repository to ~/.nvm, and attempts to add the source lines your profile file (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).

Relogin to your server so you can use nvm command.

Install required NodeJS version, in this article we need to use NodeJS 18.

1nvm install 18

You also need to enable corepack :

1npm install -g corepack
2corepack enable

Install and build Misskey

Clone the Misskey repository

1git clone --recursive https://github.com/misskey-dev/misskey.git

Navigate to the repository, and check out the latest version of Misskey:

1cd misskey
2git checkout master

Download submodules and install Misskey’s dependencies.

1git submodule update --init
2pnpm install --frozen-lockfile

Run this following command to build misskey. (python is required).

1NODE_ENV=production pnpm run build

Configure Misskey

You need to create the appropriate PostgreSQL users with respective passwords, and an empty database for Misskey. The encoding of the database should be UTF-8.

1sudo -u postgres psql
1CREATE DATABASE <your_db_name> WITH ENCODING = 'UTF8';
2CREATE USER <your_misskey_db_user> WITH ENCRYPTED PASSWORD '<YOUR_PASSWORD>';
3GRANT ALL PRIVILEGES ON DATABASE <your_db_name> TO <your_misskey_db_user>;
4\c <your_db_name>
5GRANT ALL ON SCHEMA public TO <your_misskey_db_user>;
6\q

IMPORTANT: In PostgreSQL 15, a fundamental change took place which is relevant to every user who happens to work with permissions: The default permissions of the public schema have been modified.

The GRANT ALL ON SCHEMA public TO ... is needed, otherwise you’ll find : ERROR: permission denied for schema public message when running database initialisation.

After that, copy .config/example.yml to .config/default.yml under your Misskey repository.

Edit .config/default.yml to fit with your need and environment.

Finally, run the database initialisation:

1pnpm run init

Auto start Misskey

Last, but not least, we need to start Misskey when the system start. You can auto start Misskey with systemd as described on it’s official documentation.

Using PM2 to manage Misskey

Because I love to use PM2 as my NodeJS application manager, I’ll use that instead of systemd. To install PM2:

1npm install pm2 -g

To auto run PM2 at startup as your current user, run pm2 startup and follow the output insruction.

Then to run Misskey using PM2:

1pm2 start "NODE_ENV=production pnpm run start" --name <your_process_name>

Dont forget to save managed process by PM2 using pm2 save command.

Updating Misskey

To update Misskey that run using NodeJS (via NPM and PM2), you can follow my another article: Misskey NodeJS (NVM with PM2) update steps.

That’s it, and welcome to another awesome Fediverse project!

Resources