Pleromaは、オープンソースのフェデレーションソーシャルネットワーキングプラットフォームであり、Mastodonやその他のActivityPubプラットフォームと互換性があります。これは、共通のプロトコルを使用して通信できるインスタンスのフェデレーションネットワークであるFediverseの一部です。 1つのインスタンスの1つのアカウントで、Fediverseネットワーク全体と通信できます。
このガイドでは、Ubuntu20.04ベースのサーバーにインストールして独自のPleromaインスタンスを作成する方法を説明します。
-
Ubuntu20.04を実行しているサーバー。
-
ルート以外のsudoユーザー。
-
すべてが更新されていることを確認してください。
$ sudo apt update $ sudo apt upgrade
-
Pleromaをインストールする前に必要なパッケージと依存関係はほとんどありません。
$ sudo apt install wget curl gnupg2 ca-certificates lsb-release gnupg zip libncurses5 libmagic-dev -y
最初のステップは、ファイアウォールを構成することです。 Ubuntuにはデフォルトでufw(Uncomplicated Firewall)が付属しています。
ファイアウォールが実行されているかどうかを確認します。
$ sudo ufw status
次の出力が得られるはずです。
Status: inactive
SSHポートを許可して、ファイアウォールが有効にしたときに現在の接続を切断しないようにします。
$ sudo ufw allow OpenSSH
HTTPポートとHTTPSポートも許可します。
$ sudo ufw allow 80
$ sudo ufw allow 443
ファイアウォールを有効にする
$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup
ファイアウォールのステータスをもう一度確認してください。
$ sudo ufw status
同様の出力が表示されるはずです。
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
80 ALLOW Anywhere
443 ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
443 (v6) ALLOW Anywhere (v6)
公式のPostgreSQLリポジトリをUbuntuソースリストに追加します。
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
リポジトリのGPGキーを追加します。
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
システムパッケージリストを更新します。
$ sudo apt update
Ubuntu 20.04には、デフォルトでNginx18安定バージョンが付属しています。
$ sudo apt install nginx
このガイドでは、OTPリリースからPleromaをインストールします。最初のステップは、ログイン機能のないPleromaユーザーを作成することです。また、/opt/pleroma
にホームディレクトリを作成します 。
$ sudo adduser --system --shell /bin/false --home /opt/pleroma pleroma
Pleromaユーザーに切り替えます。ただし、最初に、rootユーザーに切り替える必要があります。
$ sudo su
$ su pleroma -s $SHELL -l
プレローマを一時的な場所にダウンロードします。
$ curl "https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job=amd64" -o /tmp/pleroma_amd64.zip
アーカイブを解凍します。
$ unzip /tmp/pleroma_amd64.zip -d /tmp/
Pleromaをインストールします。
$ mv /tmp/release/* /opt/pleroma
一時ファイルを削除します。
$ rm -rf /tmp/pleroma_amd64.zip /tmp/release
rootユーザーに切り替えます。
$ exit
アップロードと公開ファイル用のディレクトリを作成します。
$ mkdir -p /var/lib/pleroma/{uploads,static}
Pleroma構成用のディレクトリを作成します。
$ mkdir -p /etc/pleroma
Pleromaディレクトリの所有権をPleromaユーザーに変更します。
$ chown -R pleroma /var/lib/pleroma /etc/pleroma
Pleromaユーザーに戻ります。
$ su pleroma -s /bin/bash -l
次のコマンドを実行して、Pleromaインスタンスの構成ファイルを生成します。
$ ./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql
プレローマの設定についていくつか質問があります。構成ファイルが見つからないという警告が表示された場合は、無視してください。
[email protected]:~$ ./bin/pleroma_ctl instance gen --output /etc/pleroma/config.exs --output-psql /tmp/setup_db.psql
!!! /etc/pleroma/config.exs not found! Please ensure it exists and that PLEROMA_CONFIG_PATH is unset or points to an existing file
What domain will your instance use? (e.g pleroma.soykaf.com) [] example.com
What is the name of your instance? (e.g. The Corndog Emporium) [nspeaks.com] Howtoforge Pleroma
What is your admin email address? [] [email protected]
What email address do you want to use for sending email notifications? [[email protected]] <Press Enter>
Do you want search engines to index your site? (y/n) [y] y
Do you want to store the configuration in the database (allows controlling it from admin-fe)? (y/n) [n] n
What is the hostname of your database? [localhost] localhost
What is the name of your database? [pleroma] pleroma
What is the user used to connect to your database? [pleroma] pleroma
What is the password used to connect to your database? [autogenerated] yourpassword
Would you like to use RUM indices? [n] n
What port will the app listen to (leave it if you are using the default setup with nginx)? [4000] <Press Enter>
What ip will the app listen to (leave it if you are using the default setup with nginx)? [127.0.0.1] <Press Enter>
What directory should media uploads go in (when using the local uploader)? [/var/lib/pleroma/uploads] <Press Enter>
What directory should custom public files be read from (custom emojis, frontend bundle overrides, robots.txt, etc.)? [/var/lib/pleroma/static] <Press Enter>
Do you want to strip location (GPS) data from uploaded images? This requires exiftool, it was detected as not installed, please install it if you answer yes. (y/n) [n] n
Do you want to anonymize the filenames of uploads? (y/n) [n] n
Do you want to deduplicate uploaded files? (y/n) [n] y
Writing config to /etc/pleroma/config.exs.
Writing the postgres script to /tmp/setup_db.psql.
Writing /var/lib/pleroma/static/robots.txt.
All files successfully written! Refer to the installation instructions for your platform for next steps.
要件に応じて、さまざまなオプションのセットを選択できます。データベースの強力なパスワードを選択してください。管理パネルからインスタンスを構成する場合は、y
を選択します データベースへの構成の保存に関する質問。
PostgreSQLのインストール時に作成されたデフォルトのPostgreSQLユーザーに切り替えます。
$ exit
$ su postgres -s /bin/bash -l
Pleromaが提供するSQLファイルを使用してデータベースを作成します。
$ psql -f /tmp/setup_db.psql
Pleromaユーザーに戻ります。
$ exit
$ su pleroma -s /bin/bash -l
作成したデータベースを初期化します。
$ ./bin/pleroma_ctl migrate
ルートユーザーに終了します。
$ exit
Let's Encryptを使用してSSL証明書をインストールするには、Certbotツールをダウンロードする必要があります。
Certbotをインストールするには、Snapdパッケージインストーラーを使用します。 Certbotの公式リポジトリは非推奨になり、UbuntuのCertbotパッケージは1年以上前のものです。 Snapdは常に最新の安定バージョンのCertbotを搭載しているため、これを使用する必要があります。幸い、Ubuntu20.04にはSnapdがプリインストールされています。
Snapdのバージョンが最新であることを確認してください。
$ snap install core
$ snap refresh core
古いバージョンのCertbotをすべて削除します。
$ apt remove certbot
Certbotをインストールします。
$ snap install --classic certbot
次のコマンドを使用して、/usr/bin
へのシンボリックリンクを作成してCertbotコマンドを実行できるようにします。 ディレクトリ。
$ ln -s /snap/bin/certbot /usr/bin/certbot
Nginxサービスを停止します。
$ systemctl stop nginx
SSL証明書を生成します。
$ certbot certonly --standalone --preferred-challenges http -d example.com
上記のコマンドは、証明書を/etc/letsencrypt/live/example.com
にダウンロードします。 サーバー上のディレクトリ。
Let'sEncryptの自動更新用のチャレンジWebルートディレクトリを作成します。
$ mkdir -p /var/lib/letsencrypt
Cronジョブを作成してSSLを更新します。証明書を確認し、必要に応じて更新するために毎日実行されます。そのためには、まず、ファイル/etc/cron.daily/certbot-renew
を作成します。 開いて編集します。
$ nano /etc/cron.daily/certbot-renew
次のコードを貼り付けます。
#!/bin/sh
certbot renew --cert-name example.com --webroot -w /var/lib/letsencrypt/ --post-hook "systemctl reload nginx"
Ctrl + Xを押してファイルを保存します Yと入力します プロンプトが表示されたら。
タスクファイルの権限を変更して実行可能にします。
$ chmod +x /etc/cron.daily/certbot-renew
Pleromaには、デフォルトのNginx構成ファイルが付属しています。 /etc/nginx/sites-available
に移動してインストールします ディレクトリ。
$ mv /opt/pleroma/installation/pleroma.nginx /etc/nginx/sites-available/pleroma.conf
example.tld
のすべての出現箇所を置き換えます ドメインで。
$ sed -i 's/example\.tld/example.com/g' /etc/nginx/sites-available/pleroma.conf
編集のために構成ファイルを開きます。
$ nano /etc/nginx/sites-available/pleroma.conf
location ~ /\.well-known/acme-challenge
のコメントを解除します ブロック。 server
構成ファイルのブロックは次のようになります。
server {
server_name example.com;
listen 80;
listen [::]:80;
location ~ /\.well-known/acme-challenge {
root /var/lib/letsencrypt/;
}
location / {
return 301 https://$server_name$request_uri;
}
}
Ctrl + Xを押してファイルを保存します Yと入力します プロンプトが表示されたら。
シンボリックリンクを作成して、PleromaNginx構成を有効にします。
$ ln -s /etc/nginx/sites-available/pleroma.conf /etc/nginx/sites-enabled/pleroma.conf
Nginxサーバーが起動時に起動できるようにします。
$ systemctl enable nginx.
Nginxサーバーを起動します。
$ systemctl start nginx
ディストリビューションで提供されているPleromasystemdサービスユニットファイルをインストールします。
$ mv /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
Pleromaサービスを有効にして開始します。
$ systemctl enable pleroma
$ systemctl start pleroma
プレローマサイトが利用可能になるまで約30秒かかる場合があります。これで、https://example.com
を開くことができます ウェブブラウザでプレローマにアクセスします。次のようになります。
コマンドラインから管理ユーザーを作成できます。最初にPleromaユーザーに切り替えます。
$ su pleroma -s /bin/bash -l
管理者ユーザーを作成します。 example
を置き換えます ユーザー名を使用して、[email protected]
メールアドレスとpassword123
強力なパスワードを使用します。
$ ./bin/pleroma_ctl user new example [email protected] --password password123 --admin
終了したら、rootユーザーに切り替えます。
$ exit
データベースに構成を保存するの回答として「いいえ」を選択した場合 、つまり、プレローマの管理パネルから設定を変更することはできません。設定を変更するには、/etc/pleroma/config.exs
を変更する必要があります ファイル。
$ nano /etc/pleroma/config.exs
ファイルの編集が完了したら、Pleromaサービスも再起動する必要があります。サービスが再開されるまで、しばらく待つ必要がある場合があります。
$ systemctl restart pleroma
Pleromaを更新するための最初のステップは、新しいリリースをダウンロードすることです。次のコマンドを実行して、Pleromaの新しいリリースをダウンロードします。
$ su pleroma -s $SHELL -lc "./bin/pleroma_ctl update"
プレローマインスタンスを停止します。
$ systemctl stop pleroma
次のステップは、データベースを移行することです。
$ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
Pleromaインスタンスを開始します。
$ systemctl start pleroma
プレローマサービスを停止します。
$ systemctl stop pleroma
プレローマのディレクトリに切り替えます。
$ cd /opt/pleroma
次のコマンドを実行して、データベースをバックアップします。
$ sudo -Hu postgres pg_dump -d <pleroma_db> --format=custom -f </path/to/backup_location/pleroma.pgdump>
ファイルpleroma.pgdump
をコピーします 、config/prod.secret.exs
、config/setup_db.sql
およびuploads
バックアップ先のフォルダ。
プレローマサービスを再開します。
$ systemctl start pleroma
Pleromaを復元するには、Pleromaを再インストールし、Pleromaサービスが機能していないことを確認する必要があります。
次に、バックアップしたファイルを元の場所にコピーして戻します。
次のコマンドを使用して、既存のデータベースとユーザーを削除します。
$ sudo -Hu postgres psql -c 'DROP DATABASE <pleroma_db>;';` `sudo -Hu postgres psql -c 'DROP USER <pleroma_db>;'
バックアップされたsetup_db.sql
を使用して、データベーススキーマとPleromaPostgresの役割を復元します。 ファイル。
$ sudo -Hu postgres psql -f config/setup_db.psql
次に、Pleromaインスタンスのデータを復元します。
$ sudo -Hu postgres pg_restore -d <pleroma_db> -v -1 </path/to/backup_location/pleroma.pgdump>
新しいバージョンに移行する場合に備えて、実行する必要のある移行が残っている場合は、データベースを移行します。
$ su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
Pleromaサービスを再起動します。
$ systemctl restart pleroma
Postgresがクエリを適切に計画できるように統計を生成します。
$ sudo -Hu postgres vacuumdb --all --analyze-in-stages
これで、Ubuntu20.04を搭載したサーバーにPleromaソーシャルネットワークプラットフォームをインストールするためのチュートリアルは終了です。質問やフィードバックがある場合は、以下のコメントに投稿してください。