Mastodon
  • Mastodonの使い方
    • Signing up for an account
    • Setting up your profile
    • Posting toots
    • Using the network features
    • Dealing with unwanted content
    • Promoting yourself and others
    • Set your preferences
    • その他の設定
    • Using Mastodon externally
    • Moving or leaving accounts
  • Mastodonの構築
    • マシンの準備
    • ソースからインストール
    • 環境設定
    • オプションのインストール
      • 全文検索
      • 秘匿サービス
      • シングルサインオン
    • セットアップを完了する
    • 開発者向けコマンドラインを利用する
    • 新しいバージョンへアップグレード
    • サーバのバックアップ
    • 新しいマシンへの移行
    • サーバーのスケールアップ
    • モデレーション
    • トラブルシューティング
  • アプリケーションの開発
    • Getting started with the API
    • Playing with public data
    • Obtaining client app access
    • ログイン
    • ガイドラインとベストプラクティス
    • ライブラリ等
  • コントリビューション
    • 技術的情報
    • 開発環境のセットアップ
    • ソースコードの構造
    • ルーティング
  • スペック
    • ActivityPub
    • WebFinger
    • Security
    • Microformats
    • OAuth
  • REST API
    • OAuthスコープ
  • API一覧
    • apps
      • oauth
    • accounts
      • bookmarks
      • favourites
      • mutes
      • blocks
      • domain_blocks
      • filters
      • reports
      • follow_requests
      • endorsements
      • featured_tags
      • preferences
      • suggestions
    • statuses
      • media
      • polls
      • scheduled_statuses
      • streaming
    • timelines
      • conversations
      • lists
      • markers
    • notifications
      • push
    • search
    • instance
      • trends
      • directory
      • custom_emojis
    • admin
    • proofs
    • oembed
  • APIエンティティ
    • Account
    • Activity
    • Admin::Account
    • Admin::Report
    • Application
    • Attachment
    • Card
    • Context
    • Conversation
    • Emoji
    • Error
    • FeaturedTag
    • Field
    • Filter
    • History
    • IdentityProof
    • Instance
    • List
    • Marker
    • Mention
    • Notification
    • Poll
    • Preferences
    • PushSubscription
    • Relationship
    • Report
    • Results
    • ScheduledStatus
    • Source
    • Status
    • Tag
    • Token

ソースからインストール

Mastodonを立ち上げるためのガイド。

前提

  • rootアクセスのあるUbuntu 18.04マシン
  • Mastodonサーバーに使うドメイン(サブドメインも可): example.comなど
  • メール配送サービスやSMTPサーバー

rootでコマンドを実行します。rootでないなら、以下を実行します。

sudo -i

システムリポジトリ

curlをインストール

apt install -y curl

Node.js

curl -sL https://deb.nodesource.com/setup_10.x | bash -

Yarn

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 install -y \
  imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \
  g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf \
  bison build-essential libssl-dev libyaml-dev libreadline6-dev \
  zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev \
  nginx redis-server redis-tools postgresql postgresql-contrib \
  certbot python-certbot-nginx yarn libidn11-dev libicu-dev libjemalloc-dev

Rubyのインストール

rbenvを使用してRubyのバージョンを管理します。これは、適切なバージョンを使用でき、新しいリリースがリリースされたらすぐに更新できるためです。rbenvは単一のLinuxユーザー用にインストールする必要があるため、最初にMastodonを実行するユーザーを作成する必要があります。

adduser --disabled-login mastodon

ユーザーを変更します

su - mastodon

And proceed to install rbenv and rbenv-build:

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec bash
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

O インストール後に特定のRubyをインストールするには

RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.6.5
rbenv global 2.6.5

規定のgemバージョンはruby_2.6.0となっていて最新のbundlerには対応していません。よってgemをアップデートします。

gem update --system

bundlerをインストール

gem install bundler --no-document

rootに戻る

exit

セットアップ

PostgreSQLをセットアップ

パフォーマンスチューニング (任意)

最適なパフォーマンスを得るために、pgTuneで設定ファイルを生成し、 /etc/postgresql/9.6/main/postgresql.confをsystemctl restart postgresqlで再起動する前に編集します。

ユーザー作成

Mastodonが使用できるPostgreSQLユーザーを作成する必要があります。単純な設定で「ident」認証を使用するのが最も簡単です。つまり、PostgreSQLユーザーは個別のパスワードを持たず、同じユーザー名のLinuxユーザーが使用できます。

プロンプトを開きます

sudo -u postgres psql

In the prompt, execute:

CREATE USER mastodon CREATEDB;
\q

完了です!

Mastodonのセットアップ

mastodonユーザーに切り替えましょう。ついにMastodonの本体をインストールです。

su - mastodon

チェックアウト

最終安定版に切り替えます。

git clone https://github.com/tootsuite/mastodon.git live && cd live
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)

最新の依存関係のインストール

RubyとNode.jsの依存関係をインストールします。

bundle install \
  -j$(getconf _NPROCESSORS_ONLN) \
  --deployment --without development test
yarn install --pure-lockfile

設定ファイルを作成

インタラクティブな設定ウィザードを使用できます。

RAILS_ENV=production bundle exec rake mastodon:setup

できること

  • 設定ファイルの作成
  • アセットのプリコンパイル
  • データベースのスキーマの作成

設定ファイルは.env.productionに保存されます。好きなように編集してください。documentation on configurationも参照。

rootに戻ります。

exit

Nginxの設定

MastodonのディレクトリからNginxの設定ファイル例をコピーします。

cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon
ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon

そして、/etc/nginx/sites-available/mastodonを開いてexample.comを自分のドメイン名に変更するなど、任意の設定をしてください。

Nginxの設定を再読込します。

systemctl reload nginx

SSL証明書の取得

無料のLet’s Encrypt証明書を使用します。

certbot --nginx -d example.com

これにより、証明書が取得されます。そして、/etc/nginx/sites-available/mastodonは新しい証明書を使用するように自動的に更新され、nginxがリロードされて変更が有効になります。

この時点で、ブラウザーでドメインにアクセスし、象がコンピューター画面のエラーページにヒットするのを確認できるはずです。これは、マストドンのプロセスをまだ開始していないためです。

systemdサービスを作成

systemdサービステンプレートをMastodonディレクトリからコピーします。

cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/

次に、ファイルを編集して、ユーザー名とパスが正しいことを確認します。

  • /etc/systemd/system/mastodon-web.service
  • /etc/systemd/system/mastodon-sidekiq.service
  • /etc/systemd/system/mastodon-streaming.service

最後に、新しいsystemdサービスを開始して有効にします。

systemctl start mastodon-web mastodon-sidekiq mastodon-streaming
systemctl enable mastodon-*

マシンの起動時にも自動で起動します。

お疲れ様です!ブラウザであなたのMastodonにアクセスできるはずです!

最終更新 February 12, 2020 · このページを改善する
他の言語: English

Merch

Tシャツとステッカー(英語)

Mastodonに参加しよう · ブログ · ·

ソースコード · CC BY-SA 4.0 · インプリント