ウェブサイト検索

Ubuntu 22.04にNginxを使用してSeafileセルフホスト型クラウドストレージをインストールする方法


Ubuntu 22.04にNginxを使用してSeafileの自己ホスト型クラウドストレージをインストールする方法

このチュートリアルはこれらのOSバージョンのために存在します

  • Ubuntu 22.04 (ジャミー・ジェリーフィッシュ)
  • Ubuntu 20.04 (フォーカルフォッサ)
  • Ubuntu 18.04 (ビオニックビーバー)
  • Ubuntu 16.04 (ゼニアル・ゼクス)
  • Ubuntu 15.04 (ビビッド・バーベット)

このページで

  1. 前提条件
  2. ステップ1 - ファイアウォールを設定する
  3. ステップ 2 - Seafile の依存関係をインストールする
  4. ステップ3 - MySQLをインストールする
  5. ステップ4 - MySQLを設定する
  6. ステップ5 - Seafileディレクトリとユーザーを作成する
  7. ステップ6 - Seafileをダウンロードしてインストールする
  8. ステップ7 - Seafileサーバーを開始する
  9. ステップ8 - Seafileの設定
  10. ステップ9 - Systemdサービスを作成する
  11. ステップ10 - Nginxをインストールする
  12. ステップ11 - SSLをインストールする
  13. ステップ12 - Nginxを設定する
  14. ステップ13 - Seafileにアクセスする
  15. 結論

Seafileはオープンソースのセルフホスティング型ファイル同期および共有プラットフォームです。これは、ユーザーがサードパーティのクラウドプロバイダーに依存することなく、自分のサーバーにデータを保存し、暗号化することを可能にします。Seafileでは、プラットフォームを超えた同期や、期限付きのファイルへのパスワード保護されたリンクを使用してファイルやフォルダーを共有できます。また、Seafileはファイルのバージョン管理も行っており、これによりユーザーは削除されたり修正されたファイルやフォルダーを復元することができます。

このチュートリアルでは、Ubuntu 22.04サーバーにSeafileをインストールし、MySQLおよびNginxをリバースプロキシサーバーとして設定する方法を学びます。

前提条件

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

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

    seafile.example.comのような完全修飾ドメイン名 (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 - Seafile の依存関係をインストールする

SeafileはPython Djangoフレームワークで書かれているため、動作させるには依存関係とPythonパッケージをインストールする必要があります。

次のコマンドを実行して、Pythonツール、Pipパッケージマネージャー、SQLライブラリ、およびMemcachedをインストールします。

sudo apt install -y python3 python3-setuptools python3-pip libmysqlclient-dev memcached libmemcached-dev

次のコマンドを実行してPythonの依存関係をインストールしてください。

sudo pip3 install --timeout=3600 django==3.2.* future==0.18.* mysqlclient==2.1.* \
    pymysql pillow==9.3.* pylibmc captcha==0.4 markupsafe==2.0.1 jinja2 sqlalchemy==1.4.3 \
    psd-tools django-pylibmc django_simple_captcha==0.5.* djangosaml2==1.5.* pysaml2==7.2.* pycryptodome==3.16.* cffi==1.15.1 lxml

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

Ubuntu 22.04は最新バージョンのMySQLを搭載しています。単一のコマンドでインストールできます。

sudo apt install -y mysql-server

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

mysql --version
mysql  Ver 8.0.32-0ubuntu0.22.04.2 for Linux on x86_64 ((Ubuntu))

このステップは、MySQL バージョン 8.0.28 以上に必要です。MySQL シェルに入ります。

sudo mysql

以下のコマンドを実行して、ルートユーザーのパスワードを設定してください。数字、大文字、小文字、特殊文字を混ぜていることを確認してください。

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourPassword12!';

シェルを終了します。

mysql> exit

MySQLのセキュアインストールスクリプトを実行します。

sudo mysql_secure_installation

最初に、ルートパスワードの入力を求められます。それを入力してください。次に、パスワードの強度をチェックするValidate Passwordコンポーネントのインストールを求められます。インストールするにはYを押してください。次に、パスワードの検証ポリシーのレベルを設定するよう求められます。最も強力なものとして2を選択してください。

Securing the MySQL server deployment.

Enter password for user root:

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: Y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
Using existing password for root.

Estimated strength of the password: 100

次に、ルートパスワードの変更を拒否するにはNを入力します。また、匿名ユーザーを削除し、リモートルートログインを無効にし、テストデータベースを削除し、特権テーブルをリロードするにはYを入力してください。

Change the password for root ? ((Press y|Y for Yes, any other key for No) : N

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done!

ステップ4 - MySQLを設定する

MySQLシェルにログインします。プロンプトが表示されたら、ルートパスワードを入力してください。

sudo mysql -u root -p

次の3つのデータベースを作成してください。

mysql> CREATE DATABASE ccnet_db CHARACTER SET utf8;
mysql> CREATE DATABASE seafile_db CHARACTER SET utf8;
mysql> CREATE DATABASE seahub_db CHARACTER SET utf8;

これらのデータベースにアクセスするためのSQLユーザーアカウントを作成してください。Seafileはmysql_native_password認証プラグインでのみ動作し、MySQL 8はデフォルトでこれを使用しないため、作成時に指定する必要があります。

mysql> CREATE USER 'seafile'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Your_password2';

ユーザーに3つのデータベースへのすべての特権を付与します。

mysql> GRANT ALL PRIVILEGES ON `ccnet_db`.* to `seafile`@localhost;
mysql> GRANT ALL PRIVILEGES ON `seafile_db`.* to `seafile`@localhost;
mysql> GRANT ALL PRIVILEGES ON `seahub_db`.* to `seafile`@localhost;

ユーザー権限を消去します。

mysql> FLUSH PRIVILEGES;

シェルを終了します。

mysql> exit

ステップ5 - Seafileディレクトリとユーザーを作成する

Seafileのプログラムファイル用のディレクトリを作成します。

sudo mkdir /opt/seafile

Seafileのユーザーを作成します。

sudo adduser --home /opt/seafile --shell /bin/bash seafile

ディレクトリの所有権を新しいユーザーに変更してください。

sudo chown -R seafile: /opt/seafile

ステップ6 - Seafileをダウンロードしてインストールする

Seafileユーザーとしてログインします。求められたらユーザーパスワードを入力してください。

su seafile

Seafileのダウンロードページにアクセスして、Seafileの最新バージョンのダウンロードリンクを取得してください。この記事を書いている時点での最新バージョンは10.0.1です。

Seafileサーバーのアーカイブをダウンロードしてください。

wget https://s3.eu-central-1.amazonaws.com/download.seadrive.org/seafile-server_10.0.1_x86-64.tar.gz

アーカイブを抽出してください。

tar xf seafile-server_10.0.1_x86-64.tar.gz

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

cd seafile-server-10.0.1/

Seafileのインストールスクリプトを実行します。

./setup-seafile-mysql.sh

インストーラスクリプトが開始されます。続行するには ENTER キーを押してください。

Checking python on this machine ...

-----------------------------------------------------------------
This script will guide you to setup your seafile server using MySQL.
Make sure you have read seafile server manual at

        https://download.seafile.com/published/seafile-manual/home.md

Press ENTER to continue
-----------------------------------------------------------------

次に、サーバーの名前、ドメイン名(seafile.example.com)、およびポートを指定してSeafileサーバーを設定します。ポートのフィールドは空のままにしておくと、Seafileはデフォルトポートの8082を使用します。設定が完了したら、ENTERキーを押して続行してください。

What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] Howtoforge

What is the ip or domain of the server?
For example: www.mycompany.com, 192.168.1.101
[ This server's ip or domain ] seafile.example.com

Which port do you want to use for the seafile fileserver?
[ default "8082" ]

次に、Seafileデータベースを初期化する方法を選択するように求められます。すでにデータベースを作成しているので、2番目のオプションを選んでください。

-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------

[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

[ 1 or 2 ] 2

次に、Seafileのデータベース詳細を入力するように求められます。ホストおよびポートのフィールドは空のままにしておくと、Seafileがデフォルト値を選択します。他の値はステップ4で設定されたように入力してください。

What is the host of mysql server?
[ default "localhost" ]

What is the port of mysql server?
[ default "3306" ]

Which mysql user to use for seafile?
[ mysql user for seafile ] seafile

What is the password for mysql user "seafile"?
[ password for seafile ]

verifying password of user seafile ...  done

Enter the existing database name for ccnet:
[ ccnet database ] ccnet_db

verifying user "seafile" access to database ccnet_db ...  done

Enter the existing database name for seafile:
[ seafile database ] seafile_db

verifying user "seafile" access to database seafile_db ...  done

Enter the existing database name for seahub:
[ seahub database ] seahub_db

verifying user "seafile" access to database seahub_db ...  done

次に、あなたのSeafile設定が表示されます。インストールを続けるにはENTERキーを押してください。

---------------------------------
This is your configuration
---------------------------------

    server name:            Howtoforge
    server ip/domain:       seafile.example.com

    seafile data dir:       /opt/seafile/seafile-data
    fileserver port:        8082

    database:               use existing
    ccnet database:         ccnet_db
    seafile database:       seafile_db
    seahub database:        seahub_db
    database user:          seafile


---------------------------------
Press ENTER to continue, or Ctrl-C to abort
---------------------------------

インストールが成功した場合、次の画面が表示されます。

Generating ccnet configuration ...

Generating seafile configuration ...

done
Generating seahub configuration ...

----------------------------------------
Now creating ccnet database tables ...

----------------------------------------
----------------------------------------
Now creating seafile database tables ...

----------------------------------------
----------------------------------------
Now creating seahub database tables ...

----------------------------------------

creating seafile-server-latest symbolic link ...  done




-----------------------------------------------------------------
Your seafile server configuration has been finished successfully.
-----------------------------------------------------------------

run seafile server:     ./seafile.sh { start | stop | restart }
run seahub  server:     ./seahub.sh  { start <port> | stop | restart <port> }

-----------------------------------------------------------------
If you are behind a firewall, remember to allow input/output of these tcp ports:
-----------------------------------------------------------------

port of seafile fileserver:   8082
port of seahub:               8000

When problems occur, Refer to

        https://download.seafile.com/published/seafile-manual/home.md

for information.

ステップ7 - Seafileサーバーを開始する

/opt/seafile/seafile-server-latest ディレクトリに切り替えてください。

cd /opt/seafile/seafile-server-latest

次のコマンドを実行してSeaf-serverを起動します。

./seafile.sh start

次の出力が得られます。

Starting seafile server, please wait ...
** Message: 04:42:32.937: seafile-controller.c(621): No seafevents.

Seafile server started

Done.

次のコマンドを実行してSeahubを起動します。

./seahub.sh start

Seahubを初めて起動すると、管理者アカウントの詳細を求められます。

LC_ALL is not set in ENV, set to en_US.UTF-8
Starting seahub at port 8000 ...

----------------------------------------
It's the first time you start the seafile server. Now let's create the admin account
----------------------------------------

What is the email for the admin account?
[ admin email ] [email 

What is the password for the admin account?
[ admin password ]

Enter the password again:
[ admin password again ]


----------------------------------------
Successfully created seafile admin
----------------------------------------


Seahub is started

Done.

Seafile と Seahub サーバーを停止してください。

./seafile.sh stop
./seahub.sh stop

ステップ8 - Seafileの設定

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

nano /opt/seafile/conf/seafile.conf

[fileserver]セクションの下にパラメータhost=127.0.0.1を追加してください。

[fileserver]
host = 127.0.0.1
port = 8082

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

/opt/seafile/conf/seahub_settings.py ファイルを編集のために開いてください。

nano /opt/seafile/conf/seahub_settings.py

SERVICE_URLの値をHTTPSプロトコルを反映するように変更してください。

SERVICE_URL = "https://seafile.example.com/"

その下に次の行を追加してください。

FILE_SERVER_ROOT = "https://seafile.example.com/seafhttp"

ファイルの末尾に次のコードを追加してください。

CACHES = {
    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1:11211',
    },
}

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

Seafileユーザーシェルを終了します。

exit

ステップ9 - Systemdサービスを作成する

Seafileが自動的にブート時に起動し、再起動に耐えられるようにするには、それに対するSystemdサービスユニットファイルを作成する必要があります。

/etc/systemd/system/seafile.serviceファイルを編集のために作成して開きます。

sudo nano /etc/systemd/system/seafile.service

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

[Unit]
Description=Seafile
add mysql.service or postgresql.service depending on your database to the line below
After=network.target mysql.service

[Service]
Type=forking
ExecStart=/opt/seafile/seafile-server-latest/seafile.sh start
ExecStop=/opt/seafile/seafile-server-latest/seafile.sh stop
LimitNOFILE=infinity
User=seafile
Group=seafile

[Install]
WantedBy=multi-user.target

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

/etc/systemd/system/seahub.service ファイルを作成して編集のために開いてください。

sudo nano /etc/systemd/system/seahub.service

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

[Unit]
Description=Seafile hub
After=network.target seafile.service

[Service]
Type=forking
change start to start-fastcgi if you want to run fastcgi
ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start
ExecStop=/opt/seafile/seafile-server-latest/seahub.sh stop
User=seafile
Group=seafile

[Install]
WantedBy=multi-user.target

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

Systemctlデーモンを再読み込みしてください。

sudo systemctl daemon-reload

以下のコマンドを実行して、SeafileとSeahubサービスを有効にし、開始します。

sudo systemctl enable --now seafile
sudo systemctl enable --now seahub

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

sudo systemctl status seafile
? seafile.service - Seafile
     Loaded: loaded (/etc/systemd/system/seafile.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-04-19 07:20:38 UTC; 24s ago
      Tasks: 19 (limit: 1026)
     Memory: 11.6M
        CPU: 102ms
     CGroup: /system.slice/seafile.service
             ??3601 /opt/seafile/seafile-server-10.0.1/seafile/bin/seafile-controller -c /opt/seafile/ccnet -d /opt/seafile/seafile-data -F /opt/seafile/conf

次に、Seahubのステータスを確認してください。

sudo systemctl status seahub
? seahub.service - Seafile hub
     Loaded: loaded (/etc/systemd/system/seahub.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-04-19 07:20:54 UTC; 19s ago
    Process: 3655 ExecStart=/opt/seafile/seafile-server-latest/seahub.sh start (code=exited, status=0/SUCCESS)
   Main PID: 3668 (python3)
      Tasks: 6 (limit: 1026)
     Memory: 85.8M
        CPU: 1.177s
     CGroup: /system.slice/seahub.service
             ??3668 python3 /opt/seafile/seafile-server-10.0.1/seahub/thirdpart/bin/gunicorn seahub.wsgi:application -c /opt/seafile/conf/gunicorn.conf.py --preload

ステップ10 - 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.24.0

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

sudo systemctl start nginx

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

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

Ubuntu 22.04 には、デフォルトで 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 seafile.example.com

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

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

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

Certbotの更新スケジューラーサービスを確認してください。

sudo systemctl list-timers

あなたは、snap.certbot.renew.serviceが実行予定のサービスの1つとして見つけるでしょう。

NEXT                        LEFT          LAST                        PASSED        UNIT                       ACTIVATES
Wed 2023-04-19 10:31:47 UTC 2h 55min left Wed 2023-04-19 03:31:58 UTC 4h 3min ago   ua-timer.timer             ua-timer.service
Wed 2023-04-19 12:02:42 UTC 4h 26min left Wed 2023-04-19 03:19:20 UTC 4h 16min ago  motd-news.timer            motd-news.service
Wed 2023-04-19 18:19:56 UTC 10h left      Wed 2023-04-19 07:19:52 UTC 16min ago     apt-daily.timer            apt-daily.service
Wed 2023-04-19 22:51:00 UTC 15h left      n/a                         n/a           snap.certbot.renew.timer   snap.certbot.renew.service

プロセスのドライランを実行して、SSLの更新が正常に機能しているか確認してください。

sudo certbot renew --dry-run

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

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

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

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

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

log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $upstream_response_time';

server {
    listen       80;
    listen       [::]:80;
    server_name  seafile.example.com;
    rewrite ^ https://$http_host$request_uri? permanent;    # Forced redirect from HTTP to HTTPS

    server_tokens off;      # Prevents the Nginx version from being displayed in the HTTP response header
}

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

    ssl_certificate /etc/letsencrypt/live/seafile.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/seafile.example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/seafile.example.com/chain.pem;
    ssl_session_timeout  5m;
    ssl_session_cache shared:MozSSL:10m;
    ssl_session_tickets off;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    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_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    resolver 8.8.8.8;

    server_name seafile.example.com;
    server_tokens off;

    location / {
        proxy_pass         http://127.0.0.1:8000;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;
        proxy_read_timeout 1200s;

        proxy_set_header   X-Forwarded-Proto https;

        # used for view/edit office file via Office Online Server
        client_max_body_size 0;

        access_log      /var/log/nginx/seahub.access.log seafileformat;
        error_log       /var/log/nginx/seahub.error.log;
    }

    location /seafhttp {
        rewrite ^/seafhttp(.*)$ $1 break;
        proxy_pass http://127.0.0.1:8082;
        client_max_body_size 0;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_send_timeout  36000s;

        send_timeout  36000s;

        # Uncomment the following line if you want to support uploads > 4GB
        # proxy_request_buffering off;

        access_log      /var/log/nginx/seafhttp.access.log seafileformat;
        error_log       /var/log/nginx/seafhttp.error.log;
    }

    location /media {
        root /opt/seafile/seafile-server-latest/seahub;
    }
}

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

ファイル /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と入力します。

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

ステップ13 - Seafileにアクセスする

ブラウザでURL https://seafile.example.com を開くと、以下のログイン画面が表示されます。

ステップ7で作成した資格情報を入力し、ログインボタンをクリックして続行します。次のページが表示されます。

マイライブラリをクリックして、デフォルトのライブラリを開いてください。

アップロードボタンをクリックし、ファイルをアップロードオプションを選択してください。アップロードしたいファイルを選択し、開くボタンをクリックします。

進捗バーが読み込まれ、あなたのファイルはすぐにアップロードされます。

管理パネルにアクセスするには、右上のプロフィール写真アイコンをクリックしてください。

システム管理者オプションを選択して管理パネルを開いてください。

ここからは、サイトのブランディングを変更したり、より強力なパスワードや二要素認証を有効にしたり、登録を無効にしたり、複数のユーザーを管理するなど、他のオプションを利用できます。

結論

これでUbuntu 22.04サーバーにSeafileのセルフホステッドクラウドストレージをインストールするためのチュートリアルは終了です。質問がある場合は、以下のコメントに投稿してください。

関連記事: