Seafile 是一种多功能的自托管文件同步和共享解决方案,使个人和组织能够有效地管理其文件和数据。它以其隐私和安全功能而著称,使其成为重视数据保护的企业和个人的热门选择。
在 Debian 12 书虫上安装 Seafile
第 1 步。在我们安装任何软件之前,通过在终端中运行以下命令来确保您的系统是最新的非常重要:apt
<span class="pln">sudo apt update sudo apt upgrade</span>
此命令将刷新存储库,允许您安装最新版本的软件包。
第 2 步。安装必要的依赖项。
接下来,让我们安装 Seafile 所需的依赖项:
<span class="pln">sudo apt install python3 python3</span><span class="pun">-</span><span class="pln">setuptools python3</span><span class="pun">-</span><span class="pln">pip python3</span><span class="pun">-</span><span class="pln">mysqldb python3</span><span class="pun">-</span><span class="pln">ldap python3</span><span class="pun">-</span><span class="pln">urllib3 python3</span><span class="pun">-</span><span class="pln">requests python3</span><span class="pun">-</span><span class="pln">pil python3</span><span class="pun">-</span><span class="pln">pip python3</span><span class="pun">-</span><span class="pln">setuptools</span>
第 3 步。创建非根用户。
最好创建一个专用用户来运行 Seafile,而不是使用 root 帐户。将“”替换为您的首选用户名:seafile
<span class="pln">sudo adduser seafile</span>
第 4 步。安装 MariaDB。
现在使用以下命令安装 MariaDB:
<span class="pln">sudo apt install mariadb</span><span class="pun">-</span><span class="pln">server mariadb</span><span class="pun">-</span><span class="pln">client</span>
安装后,通过运行内置脚本来保护 MariaDB:
<span class="pln">sudo mysql_secure_installation</span>
按照提示设置 root 密码并相应地回答安全问题。
第5步。创建海文件数据库和用户。
以根用户身份登录 MariaDB 服务器:
<span class="pln">sudo mysql </span><span class="pun">-</span><span class="pln">u root </span><span class="pun">-</span><span class="pln">p</span>
输入您在安全安装期间设置的 root 密码。现在,为 Seafile 创建一个新的数据库和用户:
<span class="pln">CREATE DATABASE seafiledb CHARACTER SET </span><span class="pun">=</span> <span class="str">'utf8mb4'</span><span class="pun">;</span><span class="pln"> CREATE USER </span><span class="str">'seafile'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pln"> IDENTIFIED BY </span><span class="str">'your_strong_password'</span><span class="pun">;</span><span class="pln"> GRANT ALL PRIVILEGES ON seafiledb</span><span class="pun">.*</span><span class="pln"> TO </span><span class="str">'seafile'</span><span class="pun">@</span><span class="str">'localhost'</span><span class="pun">;</span><span class="pln"> FLUSH PRIVILEGES</span><span class="pun">;</span><span class="pln"> EXIT</span><span class="pun">;</span>
第 6 步。设置 Web 服务器 (nginx)。
Nginx是一个高性能的Web服务器,我们将用它来为Seafile提供服务。使用以下命令安装它:
<span class="pln">sudo apt install nginx</span>
接下来,为 Seafile 创建一个新的 Nginx 配置文件:
<span class="pln">sudo nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">available</span><span class="pun">/</span><span class="pln">seafile</span>
添加以下配置:
<span class="pln">server </span><span class="pun">{</span><span class="pln"> listen </span><span class="lit">80</span><span class="pun">;</span><span class="pln"> server_name your_domain</span><span class="pun">;</span><span class="pln"> location </span><span class="pun">/</span> <span class="pun">{</span><span class="pln"> proxy_pass http</span><span class="pun">:</span><span class="com">//127.0.0.1:8000;</span><span class="pln"> proxy_set_header </span><span class="typ">Host</span><span class="pln"> $host</span><span class="pun">;</span><span class="pln"> proxy_set_header X</span><span class="pun">-</span><span class="typ">Real</span><span class="pun">-</span><span class="pln">IP $remote_addr</span><span class="pun">;</span><span class="pln"> proxy_set_header X</span><span class="pun">-</span><span class="typ">Forwarded</span><span class="pun">-</span><span class="typ">For</span><span class="pln"> $proxy_add_x_forwarded_for</span><span class="pun">;</span><span class="pln"> proxy_set_header X</span><span class="pun">-</span><span class="typ">Forwarded</span><span class="pun">-</span><span class="typ">Host</span><span class="pln"> $server_name</span><span class="pun">;</span><span class="pln"> proxy_set_header X</span><span class="pun">-</span><span class="typ">Forwarded</span><span class="pun">-</span><span class="typ">Proto</span><span class="pln"> $scheme</span><span class="pun">;</span> <span class="pun">}</span><span class="pln"> location </span><span class="pun">/</span><span class="pln">seafhttp </span><span class="pun">{</span><span class="pln"> rewrite </span><span class="pun">^/</span><span class="pln">seafhttp</span><span class="pun">(.*)</span><span class="pln">$ $1 </span><span class="kwd">break</span><span class="pun">;</span><span class="pln"> proxy_pass http</span><span class="pun">:</span><span class="com">//127.0.0.1:8082;</span><span class="pln"> client_max_body_size </span><span class="lit">0</span><span class="pun">;</span> <span class="pun">}</span><span class="pln"> location </span><span class="pun">/</span><span class="pln">media </span><span class="pun">{</span><span class="pln"> root </span><span class="pun">/</span><span class="pln">opt</span><span class="pun">/</span><span class="pln">seafile</span><span class="pun">/</span><span class="pln">seafile</span><span class="pun">-</span><span class="pln">server</span><span class="pun">-</span><span class="pln">latest</span><span class="pun">/</span><span class="pln">seahub</span><span class="pun">;</span> <span class="pun">}</span> <span class="pun">}</span>
保存文件并创建符号链接以启用此配置:
<span class="pln">sudo ln </span><span class="pun">-</span><span class="pln">s </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">available</span><span class="pun">/</span><span class="pln">seafile </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">nginx</span><span class="pun">/</span><span class="pln">sites</span><span class="pun">-</span><span class="pln">enabled</span><span class="pun">/</span>
现在,测试 Nginx 配置是否存在错误:
<span class="pln">sudo nginx </span><span class="pun">-</span><span class="pln">t</span>
现在,测试 Nginx 配置是否存在错误:
<span class="pln">sudo systemctl reload nginx</span>
步骤 7.在 Debian 12 上安装 Seafile。
现在,让我们获取并提取 Seafile 服务器文件:
<span class="pln">mkdir </span><span class="pun">-</span><span class="pln">p </span><span class="pun">~</span><span class="str">/seafile-server && cd ~/</span><span class="pln">seafile</span><span class="pun">-</span><span class="pln">server wget https</span><span class="pun">:</span><span class="com">//download.seadrive.org/seafile-server_${VER}_x86-64.tar.gz</span><span class="pln"> tar </span><span class="pun">-</span><span class="pln">zxvf seafile</span><span class="pun">-</span><span class="pln">server_8</span><span class="pun">.</span><span class="lit">0.2</span><span class="pln">_x86</span><span class="pun">-</span><span class="lit">64.tar</span><span class="pun">.</span><span class="pln">gz</span>
将下载链接替换为 Seafile 下载页面上提供的最新版本。
第8步。配置海文件。
首先,为 Seafile 创建一个新的配置文件:
<span class="pln">cp </span><span class="pun">~</span><span class="str">/seafile-server/</span><span class="pln">seafile</span><span class="pun">-</span><span class="pln">server</span><span class="pun">-</span><span class="pln">latest</span><span class="pun">/</span><span class="pln">seafile</span><span class="pun">.</span><span class="pln">conf </span><span class="pun">~</span><span class="str">/seafile-server/</span><span class="pln">seafile</span><span class="pun">-</span><span class="pln">data nano </span><span class="pun">~</span><span class="str">/seafile-server/</span><span class="pln">seafile</span><span class="pun">-</span><span class="pln">data</span><span class="pun">/</span><span class="pln">seafile</span><span class="pun">.</span><span class="pln">conf</span>
添加以下配置:
<span class="pun">[</span><span class="pln">database</span><span class="pun">]</span><span class="pln"> type </span><span class="pun">=</span><span class="pln"> mysql host </span><span class="pun">=</span> <span class="lit">127.0</span><span class="pun">.</span><span class="lit">0.1</span><span class="pln"> port </span><span class="pun">=</span> <span class="lit">3306</span><span class="pln"> user </span><span class="pun">=</span><span class="pln"> seafile password </span><span class="pun">=</span><span class="pln"> your_strong_password db_name </span><span class="pun">=</span><span class="pln"> seafiledb connection_charset </span><span class="pun">=</span><span class="pln"> utf8 </span><span class="pun">[</span><span class="pln">seafile</span><span class="pun">]</span><span class="pln"> server</span><span class="pun">-</span><span class="pln">name </span><span class="pun">=</span><span class="pln"> your_server_name</span>
接下来,编辑数据库配置文件:
<span class="pln">nano </span><span class="pun">~</span><span class="str">/seafile-server/</span><span class="pln">seafile</span><span class="pun">-</span><span class="pln">data</span><span class="pun">/</span><span class="pln">seahub_settings</span><span class="pun">.</span><span class="pln">py</span>
修改数据库设置以匹配您的设置:
<span class="pln">DATABASES </span><span class="pun">=</span> <span class="pun">{</span> <span class="str">'default'</span><span class="pun">:</span> <span class="pun">{</span> <span class="str">'ENGINE'</span><span class="pun">:</span> <span class="str">'django.db.backends.mysql'</span><span class="pun">,</span> <span class="str">'NAME'</span><span class="pun">:</span> <span class="str">'seafiledb'</span><span class="pun">,</span> <span class="str">'USER'</span><span class="pun">:</span> <span class="str">'seafile'</span><span class="pun">,</span> <span class="str">'PASSWORD'</span><span class="pun">:</span> <span class="str">'your_strong_password'</span><span class="pun">,</span> <span class="str">'HOST'</span><span class="pun">:</span> <span class="str">'127.0.0.1'</span><span class="pun">,</span> <span class="str">'PORT'</span><span class="pun">:</span> <span class="str">'3306'</span><span class="pun">,</span> <span class="pun">}</span> <span class="pun">}</span>
之后,通过运行初始化脚本初始化 Seafile 数据库:
<span class="pln">cd </span><span class="pun">~</span><span class="str">/seafile-server/</span><span class="pln">seafile</span><span class="pun">-</span><span class="pln">server</span><span class="pun">-</span><span class="pln">latest </span><span class="pun">./</span><span class="pln">setup</span><span class="pun">-</span><span class="pln">seafile</span><span class="pun">-</span><span class="pln">mysql</span><span class="pun">.</span><span class="pln">sh </span><span class="kwd">auto</span>
最后,启动Seafile和Seahub服务:
<span class="pun">./</span><span class="pln">seafile</span><span class="pun">.</span><span class="pln">sh start </span><span class="pun">./</span><span class="pln">seahub</span><span class="pun">.</span><span class="pln">sh start</span>
第9步。配置防火墙规则 (UFW)。
如果启用了防火墙,请打开 Seafile 正常运行所需的端口:
<span class="pln">sudo ufw allow </span><span class="lit">80</span><span class="pun">,</span><span class="lit">443</span><span class="pun">/</span><span class="pln">tcp sudo ufw allow </span><span class="lit">8000</span><span class="pun">/</span><span class="pln">tcp sudo ufw allow </span><span class="lit">8082</span><span class="pun">/</span><span class="pln">tcp</span>
启用简单防火墙 (UFW) 并检查其状态:
<span class="pln">sudo ufw enable sudo ufw status</span>
第10步。访问海文件网页界面。
打开 Web 浏览器并导航到 或(替换为服务器的域或 IP 地址)。您应该会看到 Seafile 登录页面。http://your_domain
http://your_server_ip
感谢您使用本教程在 Debian 12 书虫上安装最新版本的 Seafile。如需其他帮助或有用信息,我们建议您查看官方 Seafile 网站。