mastodon
誰にも公開する事なく独り丼でひっそりと運用していたりします。
使い道がよくわからんってのがあったので、連盟組むこともなく、ぼっち丼。
この世にぼっち丼を増やすという意図をもって
mastodonインストールのログ化したものを公開。
■ Mastodon Production Guide
(Mastodon が必要とするパッケージのインストールとか)
このリンク先に必要なものが記載されておりまして、
一つずつ片付けていく感じになります。
- DNSの設定
- tmux推奨
- node.js
- Yarn
- Redis
- その他のさまざまな依存関係
なお、前提条件に
You will need the following for this guide: A server running Ubuntu Server 16.04.
とあるのでOSはUbuntu16.04 amd64を使用します。
まずはパッケージの更新。
$ sudo aptitude update $ sudo aptitude upgrade
mastodon ユーザを作成します。
ついでにmastodonユーザーをsudoグループに追加します。
$ sudo adduser mastodon $ sudo gpasswd -a mastodon sudo
必要なポートも開放します。
自分がインストールしたUbuntu 16.04 は iptables を利用してますのでiptables の設定を行います。
今回は TCP 22/80/443/3000 番ポートを開放します。
※sshのポートはお好きにどうぞ。
$ sudo vim /etc/iptables/rules.v4
※既存のルールに追加
*filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
変更を反映します。
※パーミッションでエラーが出る場合は、sudo -iをして権限を上げて実行する。
# 変更の反映
$ sudo iptables-restore < /etc/iptables/rules.v4
# 現在適用されているルールの確認
$ sudo iptables -L -n -v
※パーミッションでエラーが出る場合は、sudo -iをして権限を上げる。
以後の作業は mastodon ユーザーでログインし直して行います。
$ su - mastodon
ではmastodonに必要なパッケージのインストールを行います。
$ apt -y install curl $ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - $ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list $ apt update
$ apt -y install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc-6 autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev nginx redis-server redis-tools postgresql postgresql-contrib nginx letsencrypt yarn libidn11-dev libicu-dev
Mastodon 用の postgres 内ユーザを作成します
ユーザ名は mastodon です
まずは、postgres ユーザになり、
コマンドライン管理ツール psql でターミナルから接続します。
$ sudo su - postgres psql
下記のSQLを実行して、Postgresの接続を終了します。
# CREATE USER mastodon CREATEDB; # \q
exitしてmastodonユーザに。
※Note that we do not set up a password of any kind, this is because we will be using ident authentication. This allows local users to access the database without a password.
パスワードは何も設定していないことに注意してください。これは、ident認証を使用するためです。これにより、ローカルユーザーはパスワードなしでデータベースにアクセスできます。
postgresは接続できるクライアントを設定するといった事が可能です。
pg_hba.confは1行で1レコードを構成しておりフォーマットは下記になります。
KIND DATABASE USER CIDR-ADDRESS METHOD
$ sudo vim /etc/postgresql/9.5/main/pg_hba.conf
# identに変更 # IPv4 local connections: #host all all 127.0.0.1/32 md5 host all all 127.0.0.1/32 ident # trustに変更 # IPv6 local connections: #host all all ::1/128 md5 host all all ::1/128 trust
ident 認証方式を行うので、pidentdの実装を行う。
$ sudo aptitude install pidentd
pidentd.service is not a native service, redirecting to systemd-sysv-install Executing /lib/systemd/systemd-sysv-install enable pidentd
pidentd.serviceはネイティブサービスではなく、systemd-sysv-installにリダイレクトされます。
/ lib / systemd / systemd-sysv-installを実行すると、pidentdが有効になります。
と自分の環境ではこんなエローが出たのでそのまま受け入れる。
$ sudo /lib/systemd/systemd-sysv-install enable pidentd $ sudo systemctl enable pidentd $ sudo systemctl start pidentd $ sudo systemctl restart postgresql
お次はruby の実行環境のセットアップになります。