ユーザ用ツール

サイト用ツール


mastodon

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
mastodon [2022/09/18 07:10] – [導入] arakimastodon [2022/11/16 14:04] (現在) – [更新] araki
行 29: 行 29:
  
 そこで、本サイトは手作業で全てを構築することとした。 そこで、本サイトは手作業で全てを構築することとした。
 +
 +その後、さすがに Vine Linuxを使い続けるのは困難になり Ubuntuへ、また、Raspberry Pi2Bはさすがに非力となったため、Tinker Boardを経て、結局x64の Ubuntuへと移行し、Ubuntu(x64)の二台で、リバースプロキシー+Mastodon とバックエンドのサービスとをそれぞれ担い運用している。
 +
 +なお、今現在も Dockerを利用することなく、構築している。
  
 ===== Nginx  ===== ===== Nginx  =====
行 50: 行 54:
  
 ARM用のバイナリは提供されていないようなので、sourceのレポジトリだけを追加する。 ARM用のバイナリは提供されていないようなので、sourceのレポジトリだけを追加する。
 +x64環境の場合は普通にバイナリパッケージを取得すればいい。
 /etc/apt/souces.list.d/nginx.list をつくり、次の行を書き込む。 /etc/apt/souces.list.d/nginx.list をつくり、次の行を書き込む。
  
行 73: 行 78:
 ==== 設定  ==== ==== 設定  ====
  
-/etc/nginx/conf.d/mastodon.conf を次のように作成する。mastodon本体は /var/www/mastodon/prodに置き、SSL証明書はLet's Encryptで取得することとする。+/etc/nginx/conf.d/mastodon.conf を次のように作成する。mastodon本体は /var/www/mastodon/liveに置き、SSL証明書はLet's Encryptで取得することとする。
  
 なお、minioをMastodon本体と別のサーバ上に構築するのでなければ、証明書はオレオレ証明書でも問題は無い。((詳しくは後述するが、オレオレ証明書で minioとMastodonとを別のサーバ上に構築すると画像へのアクセスのためのSSL証明書が信頼できないため、アバターを含めて一切の画像が表示されないことになる。)) なお、minioをMastodon本体と別のサーバ上に構築するのでなければ、証明書はオレオレ証明書でも問題は無い。((詳しくは後述するが、オレオレ証明書で minioとMastodonとを別のサーバ上に構築すると画像へのアクセスのためのSSL証明書が信頼できないため、アバターを含めて一切の画像が表示されないことになる。))
 +
 +なお、古い実装((3.5より前?))では、mstdn_streaming がなかったので streaming についても、mstdn_handler に渡していたが、現在は変わっているので、古い実装から新しいバージョンへ移行する際には注意が必要である。((本体の置き場所も prodではなくliveになっていたりする。prodのままにすることもできるが。))
  
 <code> <code>
 upstream mstdn_handler { upstream mstdn_handler {
-    server localhost:3000;+    server 127.0.0.1:3000
 +
 + 
 +upstream mstdn_streaming { 
 +    server 127.0.0.1:4000 fail_timeout=0;
 } }
  
行 113: 行 124:
    client_max_body_size 0;    client_max_body_size 0;
  
-   root /var/www/mastodon/prod/public;+   root /var/www/mastodon/live/public;
  
    gzip on;    gzip on;
行 153: 行 164:
        proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;        proxy_set_header X-Forwarded-For        $proxy_add_x_forwarded_for;
        proxy_set_header Proxy "";        proxy_set_header Proxy "";
-       proxy_pass http://mstdn_handler;+       proxy_pass http://mstdn_streaming;
        proxy_buffering off;        proxy_buffering off;
        proxy_redirect off;        proxy_redirect off;
行 226: 行 237:
 <code> <code>
 # su - nginx # su - nginx
-$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv +$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv 
-$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build+$ mkdir ~/.rbenv/plugins 
 +$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build 
 +$ git clone https://github.com/rbenv/rbenv-default-gems.git ~/.rbenv/plugins/rbenv-default-gems 
 +$ echo bundler > ~/.rbenv/default-gems 
 +$ echo byebug >> ~/.rbenv/default-gems
 </code> </code>
  
行 578: 行 593:
 # mkdir /var/www/mastodon # mkdir /var/www/mastodon
 # cd mastodon # cd mastodon
-# git clone https://github.com/tootsuite/mastodon.git prod+# git clone https://github.com/mastodon/mastodon.git live
 # chown -R nginx.nginx /var/www/mastodon # chown -R nginx.nginx /var/www/mastodon
 </code> </code>
  
-当サイトでは、/var/www/mastodon/prod に展開して使っている。+当サイトでは、/var/www/mastodon/live に展開して使っている。
 実行権限は nginxにすることにした。 実行権限は nginxにすることにした。
  
行 589: 行 604:
 <code> <code>
 # su - nginx # su - nginx
-$ cd /var/www/mastodon/prod+$ cd /var/www/mastodon/live
 $ gem install bundler $ gem install bundler
 $ bundle install --deployment --without development test $ bundle install --deployment --without development test
行 653: 行 668:
 Type=simple Type=simple
 User=nginx User=nginx
-WorkingDirectory=/var/www/mastodon/prod+WorkingDirectory=/var/www/mastodon/live
 Environment="RAILS_ENV=production" Environment="RAILS_ENV=production"
 Environment="PORT=3000" Environment="PORT=3000"
行 673: 行 688:
 Type=simple Type=simple
 User=nginx User=nginx
-WorkingDirectory=/var/www/mastodon/prod+WorkingDirectory=/var/www/mastodon/live
 Environment="RAILS_ENV=production" Environment="RAILS_ENV=production"
 Environment="DB_POOL=5" Environment="DB_POOL=5"
行 693: 行 708:
 Type=simple Type=simple
 User=nginx User=nginx
-WorkingDirectory=/var/www/mastodon/prod+WorkingDirectory=/var/www/mastodon/live
 Environment="NODE_ENV=production" Environment="NODE_ENV=production"
 Environment="PORT=4000" Environment="PORT=4000"
行 708: 行 723:
 <code> <code>
 # su - nginx # su - nginx
-$ cd /var/www/mastodon/prod+$ cd /var/www/mastodon/live
 $ RAILS_ENV=production bundle exec rails db:setup $ RAILS_ENV=production bundle exec rails db:setup
 $ RAILS_ENV=production bundle exec rails assets:precompile $ RAILS_ENV=production bundle exec rails assets:precompile
行 793: 行 808:
  
 <code> <code>
-$ RAILS_ENV=production bundle exec rails db:migrate+SKIP_POST_DEPLOYMENT_MIGRATION=true RAILS_ENV=production bundle exec rails db:migrate
 </code> </code>
  
行 799: 行 814:
 $ RAILS_ENV=production bundle exec rails assets:precompile $ RAILS_ENV=production bundle exec rails assets:precompile
 </code> </code>
 +
 +DBのマイグレーションは二段階に分けて行うようになっています。
 +プロセスを再起動する前の分と、再起動後の分とをSKIP_POST_DEPLOYMENT_MIGRATIONという環境変数で切り替えて行います。
  
 <code> <code>
行 804: 行 822:
 </code> </code>
  
 +<code>
 +$ RAILS_ENV=production bundle exec rails db:migrate
 +</code>
 ==== メモ  ==== ==== メモ  ====
  
mastodon.1663452621.txt.gz · 最終更新: 2022/09/18 07:10 by araki