ConoHa VPSでMisskeyを構築する
ConoHa VPSでMisskeyを構築していきます。
Misskey用の設定があるので、それを使います。
WebとSSH用のセキュリティグループを割り当てます。
VPSにSSHログインすると、Misskeyの設定情報が出てきます。
$ ssh root@160.251.211.12 -i .ssh/conoha.pem
...
================================================
Misskey Apprication
This Misskey template image is configured and running as Developer mode.
When you run Misskey server as production, You should configure domain name and SSL/TLS certification.
Please check official installation guide.
https://misskey-hub.net/docs/install/ubuntu-manual.html
MisskeyURL : http://160.251.211.12:3000
Misskey Directory : /home/misskey/misskey/
Misskey db name : misskey
Misskey user name : **********
Misskey user password : **********
To delete this message: rm -f /etc/motd
================================================
...
TLS証明書を設定します。ドメインはkentarok.orgを用います(以前使っていたけど使わなくなったものを再利用します)。
まずはcertbotをインストール。
apt install certbot
「Misskeyアプリケーションイメージを使う|ConoHa VPSサポート」にある通り実行しましょう。
certbot certonly --manual -d kentarok.org --preferred-challenges dns
メールアドレスなどをきかれるので回答します。さらに、_acme-challenge.kentarok.org
に指定された値でTXTレコードを指定するよう指示されます。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.kentarok.org with the following value:
K1FVCnQDopt4LgTu0Cpn4P-4Nu_2H_gVUhdgtUtbAYE
Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
ムームードメインで以下の通り指定します。
設定したあとにターミナルに戻ってEnterを押します。
Waiting for verification...
Cleaning up challenges
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/kentarok.org/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/kentarok.org/privkey.pem
Your cert will expire on 2024-04-07. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew *all* of your certificates, run
"certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
認証が完了しました。
証明書を取得できているかどうか、確認します。
ls -la /etc/letsencrypt/live/kentarok.org/
total 12
drwxr-xr-x 2 root root 4096 Jan 8 23:36 .
drwx------ 4 root root 4096 Jan 8 23:36 ..
lrwxrwxrwx 1 root root 36 Jan 8 23:36 cert.pem -> ../../archive/kentarok.org/cert1.pem
lrwxrwxrwx 1 root root 37 Jan 8 23:36 chain.pem -> ../../archive/kentarok.org/chain1.pem
lrwxrwxrwx 1 root root 41 Jan 8 23:36 fullchain.pem -> ../../archive/kentarok.org/fullchain1.pem
lrwxrwxrwx 1 root root 39 Jan 8 23:36 privkey.pem -> ../../archive/kentarok.org/privkey1.pem
-rw-r--r-- 1 root root 692 Jan 8 23:36 README
TXTレコードは消しておきましょう。
ドキュメントにある通り、NginxとMisskeyの設定ファイルを更新します。
ドキュメントでは触れられていませんでしたが、証明書のパスも指定したドメインに合わせて変更しておきましょう。
# To use Let's Encrypt certificate
ssl_certificate /etc/letsencrypt/live/kentarok.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/kentarok.org/privkey.pem;
設定ファイルを編集したら、サービスをリスタートします。
systemctl restart misskey
systemctl restart nginx
これでいけるはずなのだが、connection refusedになる。セキュリティグループで443を通しているのだが……。
「Misskey Hub – Misskeyプロジェクト 公式サイト」にある通りUbuntuの方のファイアーウォールを開放したらいけた(なんでだ?)。
ufw allow 443
ともあれ、Misskeyの画面が表示された。
ドメインについて、kentarokuribayashi.comのほうがやっぱいいなあと思い、misskey.kentarokuribayashi.comに変更した。
misskey.kentarokuribayashi.comのAレコードを設定した。
Let's Encryptの設定は上記した内容を再度おこなった。
ついでにオブジェクトストレージを使ってみる。Cloudflare R2を使う。
10GB/月まで無料とのことで、個人利用なので使い切ることはなさそう。
バケットを作成。
APIトークンを作成。上記のバケットの読み書き権限をつける。
ファイルへのアクセス用ドメインは、r2.devを使う。
制限があるようだけど、こちらも個人利用なら問題なさそう。
Misskeyのオブジェクトストレージの設定画面で、以下の通り設定。
- Base URL: https://pub-4babc3d0927c485fac6e21e87af5cae6.r2.dev/misskey-kentarokuribayashi-com
- Bucket: misskey-kentarokuribayashi-com
- Prefix: files
- Endpoint: d5c6d3f1021af73c52574f0b912a81f1.r2.cloudflarestorage.com/misskey-kentarokuribayashi-com
- Region: us-east-1(リージョンはR2が自動的にいい感じにしてくれるが、とりあえず設定しておく必要がある)
- Access Key: APIトークンページのものを設定
- Secret Key: 同上
これでノートに画像を添付してみると、こんなURLで参照できるようになった。
Misskey本体のアップデートをする。
公式ドキュメント「Misskeyのアップデート方法 」に従ってやっていく。
masterのHEADにしたのち、以下のコマンドでエラー。Node.jsのバージョンが古い。しかし、Ubuntuパッケージではこれが最新版。
NODE_ENV=production pnpm install --frozen-lockfile
ERR_PNPM_UNSUPPORTED_ENGINE Unsupported environment (bad pnpm and/or Node.js version)
Your Node version is incompatible with "/home/misskey/misskey/packages/backend".
Expected version: >=20.10.0
Got: v20.5.1
This is happening because the package's manifest has an engines.node field specified.
To fix this issue, install the required Node version.
「【Mastodon・Misskey・Firefish】Node.jsのアップデート方法をおさらいする | ほしぱそ。」にならってやっていく。
無事更新できた。