本教程适用于以下操作系统版本

  • Ubuntu 22.04 (Jammy Jellyfish)
  • Ubuntu 20.04 (Focal Fossa)
  • Ubuntu 18.04 (Bionic Beaver)
  • Ubuntu 16.04 (Xenial Xerus)
  • Ubuntu 15.04 (Vivid Vervet)

本页内容

  • 前置条件
  • 第 1 步 - 配置防火墙
  • 第 2 步 - 安装 Seafile 依赖
  • 第 3 步 - 安装 MySQL
  • 第 4 步 - 配置 MySQL
  • 第 5 步 - 创建 Seafile 目录和用户
  • 第 6 步 - 下载并安装 Seafile
  • 第 7 步 - 启动 Seafile 服务器
  • 第 8 步 - 配置 Seafile
  • 第 9 步 - 创建 Systemd 服务
  • 第 10 步 - 安装 Nginx
  • 第 11 步 - 安装 SSL
  • 第 12 步 - 配置 Nginx
  • 第 13 步 - 访问 Seafile
  • 结语

Seafile 是一个开源的、自托管的文件同步与共享平台。它允许用户在自己的服务器上存储和加密数据,而无需依赖第三方云服务提供商。Seafile 支持通过跨平台同步以及带有到期时间的密码保护链接来共享文件和文件夹。Seafile 还会对文件进行版本管理,使用户能够恢复已删除或修改过的文件或文件夹。

在本教程中,你将学习如何在 Ubuntu 22.04 服务器上安装 Seafile,并使用 MySQL 和 Nginx 作为反向代理服务器。

前置条件

  • 一台运行 Ubuntu 22.04 的服务器,至少 2 个 CPU 核心和 2GB 内存。
  • 一个具有 sudo 权限的非 root 用户。
  • 一个完整的域名(FQDN),例如 seafile.example.com。
  • 确保系统已更新。$ 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 其中部分软件包可能已在系统中安装。

一台运行 Ubuntu 22.04 的服务器,至少 2 个 CPU 核心和 2GB 内存。

一个具有 sudo 权限的非 root 用户。

一个完整的域名(FQDN),例如 seafile.example.com。

确保系统已更新。

$ 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(Uncomplicated Firewall,简易防火墙)。

检查防火墙是否正在运行。

$ 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 Shell。

$ sudo mysql

运行以下命令为 root 用户设置密码。请确保密码包含数字、大写字母、小写字母和特殊字符的组合。

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

退出 Shell。

mysql> exit

运行 MySQL 安全安装脚本。

$ sudo mysql_secure_installation

首先,系统会要求你输入 root 密码,请输入。接着会询问是否安装 Validate Password Component(密码强度校验组件)。它会检查 MySQL 中所用密码的强度。按 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 以拒绝修改 root 密码。同时,输入 Y 以删除匿名用户、禁止 root 远程登录、删除测试数据库并重新加载权限表。

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 Shell。在提示时输入你的 root 密码。

$ sudo mysql -u root -p

创建以下三个数据库。

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';

授予该用户在这三个数据库上的所有权限。

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;

退出 Shell。

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 下载页面并获取最新版本的下载链接。撰写本教程时,最新版本为 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 服务器提供服务器名称、域名(seafile.example.com)以及端口来进行配置。端口字段可留空,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 protected]


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 用户 Shell。

$ 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

我们需要安装 Certbot 来生成 SSL 证书。你可以使用 Ubuntu 的软件仓库安装 Certbot,也可以通过 Snapd 工具获取最新版本。我们将使用 Snapd 版本。

Ubuntu 22.04 默认已安装 Snapd。运行以下命令确保你的 Snapd 版本是最新的。

$ sudo snap install core && sudo snap refresh core

安装 Certbot。

$ sudo snap install --classic certbot

使用以下命令,通过创建指向 /usr/bin 目录的符号链接,确保 Certbot 命令可以运行。

$ 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 protected]
 -d seafile.example.com

上述命令会将证书下载到服务器上的 /etc/letsencrypt/live/seafile.example.com 目录。

生成 Diffie-Hellman 组证书。

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

检查 Certbot 续期调度服务。

$ sudo systemctl list-timers

你会发现 snap.certbot.renew.service 是已安排运行的服务之一。

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

对该流程执行一次空运行(dry run),以检查 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,你将看到如下登录界面。

在 Ubuntu 系统使用 Nginx 搭建 Seafile 自托管私有云存储教程

输入你在第 7 步创建的凭据,然后点击 Log in(登录)按钮继续。你将看到如下页面。

在 Ubuntu 系统使用 Nginx 搭建 Seafile 自托管私有云存储教程

点击 My Library(我的资料库)以打开默认资料库。

在 Ubuntu 系统使用 Nginx 搭建 Seafile 自托管私有云存储教程

点击 Upload(上传)按钮并选择 Upload files(上传文件)选项。选择你要上传的文件,然后点击 Open(打开)按钮。

进度条会进行加载,你的文件很快就会被上传。

在 Ubuntu 系统使用 Nginx 搭建 Seafile 自托管私有云存储教程

要访问管理面板,请点击右上角的头像图标。

在 Ubuntu 系统使用 Nginx 搭建 Seafile 自托管私有云存储教程

选择 System Admin(系统管理)选项以打开管理面板。

在 Ubuntu 系统使用 Nginx 搭建 Seafile 自托管私有云存储教程

从这里开始,你可以修改站点品牌标识、启用更强的密码和双因素认证、禁用注册,以及管理多个用户等。

结语

本教程到此结束,我们介绍了如何在 Ubuntu 22.04 服务器上安装 Seafile 自托管云存储。如果你有任何问题,请在下方评论中留言。