ウェブサイト検索

Ubuntu 22.04にCryptPadコラボレーティブオフィススイートをインストールする方法


Ubuntu 22.04にCryptPadコラボレーティブオフィススイートをインストールする方法

このページで

  1. 前提条件
  2. ステップ1 - ファイアウォールを設定する
  3. ステップ2 - Gitをインストールする
  4. ステップ3 - Nodejsをインストールする
  5. ステップ4 - Bowerをインストールする
  6. ステップ5 - Cryptpadをインストールする
  7. ステップ6 - Cryptpadの設定
  8. ステップ7 - Nginxをインストールする
  9. ステップ8 - SSLをインストールする
  10. ステップ9 - Nginxを設定する
  11. ステップ10 - CryptpadのSystemdサービスを作成する
  12. ステップ11 - Cryptpadにアクセスして設定する
  13. ステップ12 - Cryptpadを更新する
  14. 結論

Cryptpadは、Office 365の代替となるオープンソースの共同作業オフィススイートです。ウェブブラウザを通じてオフィスアプリケーションにアクセスすることができます。CryptpadとOffice 365の違いは、Cryptpadはエンドツーエンドで暗号化されているため、個人情報が漏洩するリスクなしに、他の人と文書を作成し共有できるということです。Cryptpadで提供されるアプリケーションには、リッチテキスト、スプレッドシート、コード/Markdown、カンバン、スライド、ホワイトボード、フォームが含まれています。

このチュートリアルでは、Ubuntu 22.04サーバーにCryptpadスイートをインストールする方法を学びます。

前提条件

    最小2GBのRAMと2つのCPUコアを備えたUbuntu 22.04を実行しているサーバー。

    sudo権限を持つ非ルートユーザー。

    example.com と docs.example.com のような2つの完全修飾ドメイン名 (FQDN) 。

    すべてが最新であることを確認してください。

    sudo apt update
    sudo apt upgrade
    

    あなたのシステムに必要ないくつかのパッケージ。

    sudo apt install wget curl nano software-properties-common dirmngr apt-transport-https gnupg2 ca-certificates lsb-release ubuntu-keyring unzip -y
    

    これらのパッケージの一部は、すでにあなたのシステムにインストールされている可能性があります。

ステップ1 - ファイアウォールを設定する

最初のステップはファイアウォールを設定することです。Ubuntuにはデフォルトでufw(簡易ファイアウォール)が付属しています。

ファイアウォールが実行中かどうか確認してください。

sudo ufw status

次の出力を得るべきです。

Status: inactive

SSHポートを許可して、ファイアウォールが有効にした際に現在の接続が切れないようにしてください。

sudo ufw allow OpenSSH

HTTPおよびHTTPSポートも許可してください。

sudo ufw allow http
sudo ufw allow https

ファイアウォールを有効にする

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/tcp                     ALLOW       Anywhere
443                        ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
80/tcp (v6)                ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)

ステップ2 - Gitをインストールする

Gitは通常Ubuntu 22.04にプリインストールされていますが、インストールされていない場合は、次のコマンドを実行してインストールします。

sudo apt install git -y

Gitのバージョンを確認してください。

git --version
git version 2.34.1

次のコマンドを実行して、Gitに名前とメールアドレスを追加するように設定します。

git config --global user.name "Your Name"
git config --global user.email "[email "

ステップ3 - Nodejsをインストールする

Node Version Manager (NVM) を使用して Nodejs をインストールします。次のコマンドを使用して NVM スクリプトをインストールします。

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

NVMの最新バージョンはGitHubリポジトリから入手できます。

使用するには、.bashrcファイルをソースする必要があります。

source ~/.bashrc

利用可能なノードのバージョンのリストを確認してください。

nvm list-remote

あなたは同様の出力を得るでしょう。

.....
        v18.9.0
        v18.9.1
       v18.10.0
       v18.11.0
       v18.12.0   (LTS: Hydrogen)
       v18.12.1   (LTS: Hydrogen)
       v18.13.0   (LTS: Hydrogen)
       v18.14.0   (LTS: Hydrogen)
->     v18.14.1   (Latest LTS: Hydrogen)
        v19.0.0
        v19.0.1
        v19.1.0
        v19.2.0
        v19.3.0
        v19.4.0
        v19.5.0
        v19.6.0
        v19.6.1

このチュートリアルを書いている時点で、最新のLTSバージョン(v18.xまたはそれ以降)をNodeにインストールしてください。

nvm install lts/hydrogen

インストールを確認してください。

node -v
v18.14.1

ステップ4 - Bowerをインストールする

BowerはCryptpadで使用されるフロントエンドコンポーネントのためのパッケージマネージャーです。以下のコマンドを使用してインストールします。

npm install -g bower

ステップ5 - Cryptpadをインストールする

CryptpadのGitHubリポジトリをクローンしてください。

git clone https://github.com/xwiki-labs/cryptpad.git cryptpad

ディレクトリに切り替えます。

cd cryptpad

リポジトリを最新バージョンに切り替えてください。

git checkout $(git tag -l | grep -v 'v1.*$' | sort -V | tail -n 1)

以下のコマンドを使用してCryptpadをインストールしてください。

npm install
bower install

Cryptpadの静的ページを構築し、次のコマンドを使用してソーシャルメディアリンクのプレビューを有効にします。

npm run build

ステップ6 - Cryptpadの設定

提供されたサンプルファイルを使用して構成ファイルを作成してください。

cp /home/$USER/cryptpad/config/config.example.js /home/$USER/cryptpad/config/config.js

設定ファイルを編集するために開いてください。

nano ~/cryptpad/config/config.js

行 httpUnsafeOrigin: 'http://localhost:3000', を見つけて、その値をあなたのメインドメインに変更してください。

httpUnsafeOrigin: 'https://example.com',

次の行 // httpSafeOrigin: "https://some-other-domain.xyz", を見つけ、その前のスラッシュを削除してコメントを解除し、値をあなたのサブドメインに変更してください。

httpSafeOrigin: "https://docs.example.com",

httpSafeOrigin 変数のすぐ下に以下の行を追加してください。

httpSafeOrigin: "https://docs.example.com",
    adminEmail: "[email ",

作業が完了したら、Ctrl + Xを押してファイルを保存し、求められたときにYを入力してください。

さらに設定を行うには、~/cryptpad/customize.dist/application_config.jsのコピーを~/cryptpad/customizeディレクトリに作成してください。

cp ~/cryptpad/customize.dist/application_config.js ~/cryptpad/customize

編集のために ~/cryptpad/customize/application_config.js ファイルを開いてください。

nano ~/cryptpad/customize/application_config.js

必ず return AppConfig; 行の前にすべての設定を追加してください。

Cryptpadの未登録使用を無効にするには、次の行を追加してください。

AppConfig.registeredOnlyTypes = AppConfig.availablePadTypes;

プライバシーポリシー、利用規約、インプリントページへのリンクを追加してください。

// Privacy Policy
AppConfig.privacy = 'https://example.com/privacy-policy/';
// Terms of Service
AppConfig.terms = 'https://example.com/terms-of-service/';
// Imprint / Legal Notice
AppConfig.imprint = 'https://example.com/imprint/';

Cryptpadを保護するためにパスワードソルトを追加してください。

AppConfig.loginSalt = 'ggkljerthhkletho0the90hoserhtgse90rh4ohzisdofh90-43kbdf9009io';

パスワードの最小長を増やすには、次の行を追加してください。

AppConfig.minimumPasswordLength = 10;

ファイルを保存するには、Ctrl + X を押し、完了したらプロンプトが表示された時にYを入力してください。Cryptpadを始める前に、まずNginxをインストールし、SSL証明書を作成し、Nginxサーバーを設定してCryptpadのドメインにアクセスできるように準備する必要があります。

ステップ7 - Nginxをインストールする

Ubuntu 22.04には古いバージョンのNginxが付属しています。最新バージョンをインストールするには、公式のNginxリポジトリをダウンロードする必要があります。

Nginxの署名キーをインポートします。

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
	| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

Nginxの安定版のリポジトリを追加してください。

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg arch=amd64] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

システムリポジトリを更新してください。

sudo apt update

Nginxをインストールします。

sudo apt install nginx

インストールを確認してください。

nginx -v
nginx version: nginx/1.22.1

Nginxサーバーを開始します。

sudo systemctl start nginx

ステップ8 - SSLをインストールする

SSL証明書を生成するためにCertbotをインストールする必要があります。Ubuntuのリポジトリを使用してCertbotをインストールするか、Snapdツールを使用して最新バージョンを取得することができます。私たちはSnapdバージョンを使用します。

Ubuntu 22.04 はデフォルトで Snapd がインストールされています。次のコマンドを実行して、Snapd のバージョンが最新であることを確認してください。Snapd のバージョンが最新であることを確認してください。

sudo snap install core
sudo snap refresh core

Certbotをインストールします。

sudo snap install --classic certbot

次のコマンドを使用して、Certbotコマンドが実行されるように、/usr/binディレクトリへのシンボリックリンクを作成します。

sudo ln -s /snap/bin/certbot /usr/bin/certbot

次のコマンドを実行してSSL証明書を生成します。

sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email  -d example.com -d docs.example.com

上記のコマンドは、ドメインexample.comおよびdocs.example.comに対して、サーバーの/etc/letsencrypt/live/example.comディレクトリに証明書をダウンロードします。

ディフィー・ヘルマン群証明書を生成します。

sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096

SSLの更新が問題なく機能しているかどうかを確認するために、プロセスのドライランを行ってください。

sudo certbot renew --dry-run

エラーが見当たらなければ、すべて準備完了です。あなたの証明書は自動的に更新されます。

ステップ9 - Nginxを設定する

ファイル /etc/nginx/nginx.conf を編集のために開いてください。

sudo nano /etc/nginx/nginx.conf

include /etc/nginx/conf.d/*.conf;の前に次の行を追加してください。

server_names_hash_bucket_size  64;

Ctrl + X を押してファイルを保存し、促されたらYと入力します。

/etc/nginx/conf.d/cryptpad.conf ファイルを作成して編集のために開いてください。

sudo nano /etc/nginx/conf.d/cryptpad.conf

そのコードをそこに貼り付けてください。

server {
    # Redirect any http requests to https
    listen 80;
    listen [::]:80;
    server_name example.com docs.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    # CryptPad serves static assets over these two domains.
    # `main_domain` is what users will enter in their address bar.
    # Privileged computation such as key management is handled in this scope
    # UI content is loaded via the `sandbox_domain`.
    # "Content Security Policy" headers prevent content loaded via the sandbox
    # from accessing privileged information.
    # These variables must be different to take advantage of CryptPad's sandboxing techniques.
    # In the event of an XSS vulnerability in CryptPad's front-end code
    # this will limit the amount of information accessible to attackers.
    set $main_domain "example.com";
    set $sandbox_domain "docs.example.com";

    # By default CryptPad allows remote domains to embed CryptPad documents in iframes.
    # This behaviour can be blocked by changing $allowed_origins from "*" to the
    # sandbox domain, which must be permitted to load content from the main domain
    # in order for CryptPad to work as expected.
    #
    # An example is given below which can be uncommented if you want to block
    # remote sites from including content from your server
    set $allowed_origins "*";
    # set $allowed_origins "https://${sandbox_domain}";

    # CryptPad's dynamic content (websocket traffic and encrypted blobs)
    # can be served over separate domains. Using dedicated domains (or subdomains)
    # for these purposes allows you to move them to a separate machine at a later date
    # if you find that a single machine cannot handle all of your users.
    # If you don't use dedicated domains, this can be the same as $main_domain
    # If you do, they can be added as exceptions to any rules which block connections to remote domains.
    # You can find these variables referenced below in the relevant places
    set $api_domain "example.com";
    set $files_domain "example.com";

    # nginx doesn't let you set server_name via variables, so you need to hardcode your domains here
    server_name example.com docs.example.com;

    # You'll need to Set the path to your certificates and keys here
    # IMPORTANT: this config is intended to serve assets for at least two domains
    # (your main domain and your sandbox domain). As such, you'll need to generate a single SSL certificate
    # that includes both domains in order for things to work as expected.
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;

    # diffie-hellman parameters are used to negotiate keys for your session
    # generate strong parameters using the following command
    ssl_dhparam /etc/ssl/certs/dhparam.pem;

    # Speeds things up a little bit when resuming a session
    ssl_session_timeout 1d;
    ssl_session_cache shared:MozSSL:10m;
    ssl_session_tickets off;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers off;

    # HSTS (ngx_http_headers_module is required) (63072000 seconds)
    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;

    # OCSP stapling
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8 8.8.4.4 valid=300s;
    resolver_timeout 5s;

    # verify chain of trust of OCSP response using Root CA and Intermediate certs
    ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;

    # replace with the IP address of your resolver
    resolver 8.8.8.8 8.8.4.4 1.1.1.1 1.0.0.1 9.9.9.9 149.112.112.112 208.67.222.222 208.67.220.220;

    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options nosniff;
    add_header Access-Control-Allow-Origin "${allowed_origins}";
    # add_header X-Frame-Options "SAMEORIGIN";

    # Opt out of Google's FLoC Network
    add_header Permissions-Policy interest-cohort=();

    # Enable SharedArrayBuffer in Firefox (for .xlsx export)
    add_header Cross-Origin-Resource-Policy cross-origin;
    add_header Cross-Origin-Embedder-Policy require-corp;

    # Insert the path to your CryptPad repository root here
    root /home/username/cryptpad;
    index index.html;
    error_page 404 /customize.dist/404.html;

    # any static assets loaded with "ver=" in their URL will be cached for a year
    if ($args ~ ver=) {
        set $cacheControl max-age=31536000;
    }
    # This rule overrides the above caching directive and makes things somewhat less efficient.
    # We had inverted them as an optimization, but Safari 16 introduced a bug that interpreted
    # some important headers incorrectly when loading these files from cache.
    # This is why we can't have nice things :(
    if ($uri ~ ^(\/|.*\/|.*\.html)$) {
        set $cacheControl no-cache;
    }

    # Will not set any header if it is emptystring
    add_header Cache-Control $cacheControl;

    # CSS can be dynamically set inline, loaded from the same domain, or from $main_domain
    set $styleSrc   "'unsafe-inline' 'self' https://${main_domain}";

    # connect-src restricts URLs which can be loaded using script interfaces
    # if you have configured your instance to use a dedicated $files_domain or $api_domain
    # you will need to add them below as: https://${files_domain} and https://${api_domain}
    set $connectSrc "'self' https://${main_domain} blob: wss://${api_domain} https://${sandbox_domain}";

    # fonts can be loaded from data-URLs or the main domain
    set $fontSrc    "'self' data: https://${main_domain}";

    # images can be loaded from anywhere, though we'd like to deprecate this as it allows the use of images for tracking
    set $imgSrc     "'self' data: blob: https://${main_domain}";

    # frame-src specifies valid sources for nested browsing contexts.
    # this prevents loading any iframes from anywhere other than the sandbox domain
    set $frameSrc   "'self' https://${sandbox_domain} blob:";

    # specifies valid sources for loading media using video or audio
    set $mediaSrc   "blob:";

    # defines valid sources for webworkers and nested browser contexts
    # deprecated in favour of worker-src and frame-src
    set $childSrc   "https://${main_domain}";

    # specifies valid sources for Worker, SharedWorker, or ServiceWorker scripts.
    # supercedes child-src but is unfortunately not yet universally supported.
    set $workerSrc  "'self'";

    # script-src specifies valid sources for javascript, including inline handlers
    set $scriptSrc  "'self' resource: https://${main_domain}";

    # frame-ancestors specifies which origins can embed your CryptPad instance
    # this must include 'self' and your main domain (over HTTPS) in order for CryptPad to work
    # if you have enabled remote embedding via the admin panel then this must be more permissive.
    # note: cryptpad.fr permits web pages served via https: and vector: (element desktop app)
    set $frameAncestors "'self' https://${main_domain}";
    # set $frameAncestors "'self' https: vector:";

    set $unsafe 0;
    # the following assets are loaded via the sandbox domain
    # they unfortunately still require exceptions to the sandboxing to work correctly.
    if ($uri ~ ^\/(sheet|doc|presentation)\/inner.html.*$) { set $unsafe 1; }
    if ($uri ~ ^\/common\/onlyoffice\/.*\/.*\.html.*$) { set $unsafe 1; }

    # everything except the sandbox domain is a privileged scope, as they might be used to handle keys
    if ($host != $sandbox_domain) { set $unsafe 0; }
    # this iframe is an exception. Office file formats are converted outside of the sandboxed scope
    # because of bugs in Chromium-based browsers that incorrectly ignore headers that are supposed to enable
    # the use of some modern APIs that we require when javascript is run in a cross-origin context.
    # We've applied other sandboxing techniques to mitigate the risk of running WebAssembly in this privileged scope
    if ($uri ~ ^\/unsafeiframe\/inner\.html.*$) { set $unsafe 1; }

    # privileged contexts allow a few more rights than unprivileged contexts, though limits are still applied
    if ($unsafe) {
        set $scriptSrc "'self' 'unsafe-eval' 'unsafe-inline' resource: https://${main_domain}";
    }

    # Finally, set all the rules you composed above.
    add_header Content-Security-Policy "default-src 'none'; child-src $childSrc; worker-src $workerSrc; media-src $mediaSrc; style-src $styleSrc; script-src $scriptSrc; connect-src $connectSrc; font-src $fontSrc; img-src $imgSrc; frame-src $frameSrc; frame-ancestors $frameAncestors";

    # The nodejs process can handle all traffic whether accessed over websocket or as static assets
    # We prefer to serve static content from nginx directly and to leave the API server to handle
    # the dynamic content that only it can manage. This is primarily an optimization
    location ^~ /cryptpad_websocket {
        proxy_pass http://localhost:3000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # WebSocket support (nginx 1.4)
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
    }

    location ^~ /customize.dist/ {
        # This is needed in order to prevent infinite recursion between /customize/ and the root
    }
    # try to load customizeable content via /customize/ and fall back to the default content
    # located at /customize.dist/
    # This is what allows you to override behaviour.
    location ^~ /customize/ {
        rewrite ^/customize/(.*)$ $1 break;
        try_files /customize/$uri /customize.dist/$uri;
    }

    # /api/config is loaded once per page load and is used to retrieve
    # the caching variable which is applied to every other resource
    # which is loaded during that session.
    location ~ ^/api/.*$ {
        proxy_pass http://localhost:3000;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        # These settings prevent both NGINX and the API server
        # from setting the same headers and creating duplicates
        proxy_hide_header Cross-Origin-Resource-Policy;
        add_header Cross-Origin-Resource-Policy cross-origin;
        proxy_hide_header Cross-Origin-Embedder-Policy;
        add_header Cross-Origin-Embedder-Policy require-corp;
    }

    # encrypted blobs are immutable and are thus cached for a year
    location ^~ /blob/ {
        if ($request_method = 'OPTIONS') {
            add_header 'Access-Control-Allow-Origin' "${allowed_origins}";
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'application/octet-stream; charset=utf-8';
            add_header 'Content-Length' 0;
            return 204;
        }
        add_header X-Content-Type-Options nosniff;
        add_header Cache-Control max-age=31536000;
        add_header 'Access-Control-Allow-Origin' "${allowed_origins}";
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
        add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Content-Length';
        add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Content-Length';
        try_files $uri =404;
    }

    # the "block-store" serves encrypted payloads containing users' drive keys
    # these payloads are unlocked via login credentials. They are mutable
    # and are thus never cached. They're small enough that it doesn't matter, in any case.
    location ^~ /block/ {
        add_header X-Content-Type-Options nosniff;
        add_header Cache-Control max-age=0;
        try_files $uri =404;
    }

    # This block provides an alternative means of loading content
    # otherwise only served via websocket. This is solely for debugging purposes,
    # and is thus not allowed by default.
    #location ^~ /datastore/ {
        #add_header Cache-Control max-age=0;
        #try_files $uri =404;
    #}

    # The nodejs server has some built-in forwarding rules to prevent
    # URLs like /pad from resulting in a 404. This simply adds a trailing slash
    # to a variety of applications.
    location ~ ^/(register|login|settings|user|pad|drive|poll|slide|code|whiteboard|file|media|profile|contacts|todo|filepicker|debug|kanban|sheet|support|admin|notifications|teams|calendar|presentation|doc|form|report|convert|checkup)$ {
        rewrite ^(.*)$ $1/ redirect;
    }

    # Finally, serve anything the above exceptions don't govern.
    try_files /customize/www/$uri /customize/www/$uri/index.html /www/$uri /www/$uri/index.html /customize/$uri;
}

ファイルを保存するには、Ctrl + Xを押し、完了したら表示されたらYを入力してください。

Nginxの設定ファイルの構文を確認してください。

sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Nginxサービスを再起動してください。

sudo systemctl restart nginx

ステップ10 - CryptpadのSystemdサービスを作成する

ファイル ~/cryptpad/docs/cryptpad.service を編集のために開いてください。

nano ~/cryptpad/docs/cryptpad.service

それにあるコードを以下のように修正してください。Nodeバイナリの正しいパスを確認し、usernameを現在ログインしているLinuxのユーザー名に置き換えてください。

[Unit]
Description=CryptPad API server

[Service]
ExecStart=/home/username/.nvm/versions/node/v18.14.1/bin/node /home/username/cryptpad/server.js
modify to match the location of your cryptpad repository
WorkingDirectory=/home/username/cryptpad

Restart=always
Restart service after 10 seconds if node service crashes
RestartSec=2

Output to syslog
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=cryptpad
User=username
Group=username
modify to match your working directory
Environment='PWD="/home/username/cryptpad"'

systemd sets the open file limit to 4000 unless you override it
cryptpad stores its data with the filesystem, so you should increase this to match the value of `ulimit -n`
or risk EMFILE errors.
LimitNOFILE=1000000

[Install]
WantedBy=multi-user.target

作業が完了したら、Ctrl + Xを押してファイルを保存し、求められたときにYを入力してください。

ファイルをSystemdフォルダーにコピーします。

sudo cp ~/cryptpad/docs/cryptpad.service /etc/systemd/system/cryptpad.service

サービスデーモンを再読み込みします。

sudo systemctl daemon-reload

Cryptpadサービスを有効にし、開始します。

sudo systemctl enable cryptpad --now

サービスの状態を確認してください。

suddo systemctl status cryptpad

次の出力が得られます。

? cryptpad.service - CryptPad API server
     Loaded: loaded (/etc/systemd/system/cryptpad.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-02-21 08:43:50 UTC; 1h 52min ago
   Main PID: 8145 (node)
      Tasks: 33 (limit: 2237)
     Memory: 53.4M
        CPU: 2.323s
     CGroup: /system.slice/cryptpad.service
             ??8145 /home/navjot/.nvm/versions/node/v18.14.1/bin/node /home/navjot/cryptpad/server.js
             ??8158 /home/navjot/.nvm/versions/node/v18.14.1/bin/node lib/workers/db-worker
             ??8159 /home/navjot/.nvm/versions/node/v18.14.1/bin/node lib/workers/db-worker

Feb 21 08:43:50 nspeaks systemd[1]: Started CryptPad API server.
Feb 21 08:43:50 nspeaks cryptpad[8145]: Serving content for https://example.com/ via http://127.0.0.1:3000.

ステップ11 - Cryptpadにアクセスして設定する

ブラウザでhttps://example.comのURLを開くと、次の画面が表示されます。

サインアップボタンをクリックしてアカウントを作成します。資格情報を入力し、サインアップボタンをクリックしてアカウントを作成します。

以下の確認ポップアップが表示されます。アカウントの作成を完了するには赤いボタンをクリックしてください。

ログインが完了し、CryptDriveのダッシュボードに移動します。

右上隅のユーザーメニューをクリックし、設定オプションをクリックしてください。

次の設定ページが表示されます。

公開署名鍵の値をコピーし、ターミナルに戻って設定ファイルを開いてください。

nano ~/cryptpad/config/config.js

adminKeys変数を見つけて、以下のように角括弧の間にキーを貼り付けてください。

adminKeys: ["[[email /ygDc+0uabbCk6WqJYiIDO2B+gP6mYZ9FlQ94zL3UAoU=]"],

作業が完了したら、Ctrl + Xを押してファイルを保存し、求められたときにYを入力してください。

Cryptpadサービスを再起動してください。

sudo systemctl restart cryptpad

あなたのCryptpadオフィススイートは使用準備が整いました。

ステップ12 - Cryptpadを更新する

Cryptpadの更新は非常に簡単で、GitHubリポジトリから最新の更新を取得し、その後Nodeの更新コマンドを実行することが含まれます。

最初のステップは、Cryptpadサービスを停止することです。

sudo systemctl stop cryptpad

Cryptpadを更新するために、以下のコマンドを順番に実行してください。

cd ~/cryptpad
git pull
git checkout $(git tag -l | grep -v 'v1.*$' | sort -V | tail -n 1)
npm update
bower update

Cryptpadサービスを開始する。

sudo systemctl start cryptpad

結論

これでUbuntu 22.04サーバーにCryptpad Collaborative Office Suiteをインストールするためのチュートリアルは終了です。質問がある場合は、下のコメントに投稿してください。

関連記事: