[LINUX] [V11 ~] A memorandum to put in Misskey

Preface

Previously, I wrote the version up to Misskey v10, but the installation procedure has changed due to the use of Postgresql from v11 or later. This section describes how to install v11 or later.

Click here for v10 and earlier: https://qiita.com/YuzuRyo61/items/7105d16ac75c78899f1c

This article is based on Ubuntu and Debian series.

Step 0. Upgrade existing packages

This is a routine procedure.

sudo apt update
sudo apt upgrade -y

Reboot is recommended after the upgrade.

Step 1. Install required packages

Misskey requires Node.js (v11.10.1 or later), PostgreSQL (v10 or later), and Redis. Elasticsearch is also available as an option, but this time it is omitted. Since yarn is recommended, we will also introduce yarn.

Then use nginx as a reverse proxy.

Node.js

Install Node.js via Nodesource. For Linux on another package management system, such as CentOS, click See the README in this repository.

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt-get install -y nodejs

https://github.com/nodesource/distributions#installation-instructions

yarn

Introduced from the official yarn repository.

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn

https://classic.yarnpkg.com/ja/docs/install#debian-stable

PostgreSQL

From the default repository.

sudo apt install postgresql-10 postgresql-server-dev-10

Redis

This is also pulled from the default repository as it is.

sudo apt install redis-server

nginx

From the official nginx repository. I'm not particular about it, so I'll put in a stable version.

sudo apt install curl gnupg2 ca-certificates lsb-release
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
sudo apt-key fingerprint ABF5BD827BD9BF62 #This is for confirmation.
sudo apt update
sudo apt install nginx

http://nginx.org/en/linux_packages.html#Ubuntu

Other

Introduce build-essential.

sudo apt install build-essential

Finish

Start the service.

sudo systemctl start nginx postgresql redis-server
sudo systemctl enable nginx postgresql redis-server

Step 2. Creating an operational user

Specify the user to start. The user name is arbitrary.

sudo adduser --disabled-password --disabled-login misskey
sudo su - misskey

Step 3. Clone the repository

Clone the repository and check out for the latest release.

git clone -b master https://github.com/syuilo/misskey.git
cd misskey
#The version is https://github.com/syuilo/misskey/releases/See latest
git checkout <12.x.x>

Step 4. Install the package

Install the package with yarn. Make sure that yarn.lock is not replaced.

yarn install --pure-lockfile

Step 5. Create configuration file

Create default.yml by copying example.yml.

cp .config/example.yml .config/default.yml

Set default.yml according to the comments inside.

Step 6. Build

Build Misskey. This can take some time.

NODE_ENV=production yarn build

Step 7. Database initialization

Initialize the database so that it can be used.

yarn run init

Step 8. Start check and register with systemd

You can check the startup with the following command. If you can confirm it, press Ctrl-C to stop the server.

NODE_ENV=production yarn start

Register with systemd

/etc/systemd/system/misskey.service


[Unit]
Description=Misskey daemon

[Service]
Type=simple
User=misskey #If the user name is different, please change it
ExecStart=/usr/bin/npm start
WorkingDirectory=/home/misskey/misskey #Please change according to the environment
Environment="NODE_ENV=production"
TimeoutSec=60
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=misskey
Restart=always

[Install]
WantedBy=multi-user.target

After setting, execute systemctl daemon-reload to update the service list.

systemctl enable misskey will run misskey at startup.

Start it with systemctl start misskey.

Step 9. nginx reverse proxy settings

Finally, set up the nginx reverse proxy.

The file name is arbitrary. If there are any changes, please change accordingly.

nginx:/etc/nginx/conf.d/misskey.conf


# Sample nginx configuration for Misskey
#
# 1. Replace example.tld to your domain
# 2. Copy to /etc/nginx/sites-available/ and then symlink from /etc/nginx/sites-enabled/
#    or copy to /etc/nginx/conf.d/

# For WebSocket
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=cache1:16m max_size=1g inactive=720m use_temp_path=off;

server {
    listen 80;
    listen [::]:80;
    server_name example.tld;

    # For SSL domain validation
    root /var/www/html;
    location /.well-known/acme-challenge/ { allow all; }
    location /.well-known/pki-validation/ { allow all; }
    location / { return 301 https://$server_name$request_uri; }
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name example.tld;
    ssl_session_cache shared:ssl_session_cache:10m;

    # To use Let's Encrypt certificate
    ssl_certificate     /etc/letsencrypt/live/example.tld/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.tld/privkey.pem;

    # To use Debian/Ubuntu's self-signed certificate (For testing or before issuing a certificate)
    #ssl_certificate     /etc/ssl/certs/ssl-cert-snakeoil.pem;
    #ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;

    # SSL protocol settings
    ssl_protocols TLSv1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:AES128-SHA;
    ssl_prefer_server_ciphers on;

    # Change to your upload limit
    client_max_body_size 80m;

    # Proxy to Node
    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 https;
        proxy_http_version 1.1;
        proxy_redirect off;

        # For WebSocket
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

        # Cache settings
        proxy_cache cache1;
        proxy_cache_lock on;
        proxy_cache_use_stale updating;
        add_header X-Cache $upstream_cache_status;
    }
}

https://github.com/syuilo/misskey/blob/develop/docs/examples/misskey.nginx

Once set, apply the changes with systemctl restart nginx.


This completes the settings: tada:

Ex. To update

If there is an update, first move to the directory where Misskey is installed. Then enter the following commands in order from the top.

git fetch
git checkout <12.x.x> #Enter the latest version of the tag
yarn install --pure-lockfile
NODE_ENV=production yarn build
yarn migrate

Enter the above command, and if there are no errors, restart the misskey service. This completes the update.

Recommended Posts

[V11 ~] A memorandum to put in Misskey
To add a module to python put in Julialang
I made a script to put a snippet in README.md
A memorandum on how to use keras.preprocessing.image in Keras
A memorandum to run a python script in a bat file
[Linux] How to put your IP in a variable
Put the lists together in pandas to make a DataFrame
How to put a symbolic link
A memorandum to change to Manjaro Linux
Try to put data in MongoDB
I want to print in a comprehension
[Itertools.permutations] How to put permutations in Python
PUT gzip directly to S3 in Python
How to get a stacktrace in python
[Python] How to put any number of standard inputs in a list
How to put a half-width space before letters and numbers in Python.
A memorandum because I stumbled on trying to use MeCab in Python
A memorandum to make WebDAV only with nginx
Try to calculate a statistical problem in Python
How to clear tuples in a list (Python)
To execute a Python enumerate function in JavaScript
I want to create a window in Python
How to create a JSON file in Python
3 steps to put Python + mecab in yum only
A clever way to time processing in Python
How to implement a gradient picker in Houdini
Steps to develop a web application in Python
A memorandum of how to execute the! Sudo magic command in Jupyter Notebook
How to notify a Discord channel in Python
[Python] How to draw a histogram in Matplotlib
How to create a Rest Api in Django
Build a PYNQ environment on Ultra96 V2 and log in to Jupyter Notebook
How to write a named tuple document in 2020
How to count numbers in a specific range
Put out a shortened URL string in Python
How to read a file in a different directory
A supplement to "Camera Calibration" in OpenCV-Python Tutorials
How to Mock a Public function in Pytest
Sample to put Python Kivy in one file
A memorandum of commands, packages, terms, etc. used in linux (updated from time to time)
Understand Python yield If you put yield in a function, it will change to a generator
How to specify a schema in Django's database settings
Parse a JSON string written to a file in Python
How to convert / restore a string with [] in python
I want to embed a variable in a Python string
I want to easily implement a timeout in python
Various ways to extract columns in a NumPy array
Try to make a Python module in C language
I want to generate a UUID quickly (memorandum) ~ Python ~
I want to transition with a button in flask
I want to write in Python! (2) Let's write a test
[Python] How to expand variables in a character string
A memorandum when writing experimental code ~ Logging in python
Create a plugin to run Python Doctest in Vim (2)
I tried to implement a pseudo pachislot in Python
Create a plugin to run Python Doctest in Vim (1)
I want to randomly sample a file in Python
I want to work with a robot in python.
Things to note when initializing a list in Python
How to display DataFrame as a table in Markdown
What to do if a UnicodeDecodeError occurs in pip