如何在 Ubuntu 22.04 LTS 上安装 Seafile

如果您正在寻找一种简单安全的方式来同步和共享 Ubuntu 系统上的文件,Seafile Ubuntu 是一个值得探索的解决方案。Seafile是一个自托管文件同步和协作平台,其操作类似于Dropbox或Google Drive,只是用户可以完全控制他们的数据,并有可能通过消除第三方订阅费来节省资金。

Seafile-logo-2

在 Ubuntu 22.04 LTS Jammy Jellyfish 上安装 Seafile

第 1 步。首先,通过在终端中运行以下命令,确保所有系统软件包都是最新的。apt

sudo apt update
sudo apt upgrade

第 2 步。安装所需的依赖项。

Seafile 需要在您的系统上安装一些依赖项。要安装它们,请在终端中运行以下命令:

sudo apt install python3 python3-setuptools python3-pip python3-mysqldb python3-dev python3-ldaplib python3-urllib3 python3-requests

第 3 步。安装 MariaDB。

默认情况下,MariaDB 在 Ubuntu 22.04 基本存储库上可用。现在运行以下命令将最新版本的MariaDB安装到您的Ubuntu系统中:

sudo apt install mariadb-server mariadb-client

成功安装后,启用MariaDB(在系统启动时自动启动),启动并使用以下命令验证状态:

sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo systemctl status mariadb

确认安装并检查已安装的 MariaDB 构建版本:

mariadb --version

默认情况下,MariaDB 未强化。您可以使用脚本保护 MariaDB。您应该仔细阅读并在每个步骤下方仔细阅读,这将设置root密码,删除匿名用户,禁止远程root登录,并删除测试数据库和对安全MariaDB的访问权限:mysql_secure_installation

mysql_secure_installation

像这样配置它:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

现在登录到 MariaDB 控制台并为 Seafile 创建一个数据库。运行以下命令:

mysql -u root -p

这将提示您输入密码,因此请输入您的MariaDB root密码并按Enter键。我们将为每个服务器组件创建一个数据库。

MariaDB [(none)]> CREATE DATABASE seafile_server;
MariaDB [(none)]> CREATE DATABASE ccnet_server;
MariaDB [(none)]> CREATE DATABASE seahub_server;

然后,创建数据库用户并为创建的数据库授予权限:

MariaDB [(none)]> CREATE USER 'seafile'@'localhost' IDENTIFIED BY 'Your-Strong-Password';
MariaDB [(none)]> GRANT ALL ON seafile_server.* TO 'seafile'@'localhost';
MariaDB [(none)]> GRANT ALL ON ccnet_server.* TO 'seafile'@'localhost';
MariaDB [(none)]> GRANT ALL ON seahub_server.* TO 'seafile'@'localhost';
MariaDB [(none)]> QUIT;

有关安装 MariaDB 的其他资源,请阅读以下帖子:

  • 如何在 Ubuntu Linux √ 上安装 MariaDB

第 4 步。在 Ubuntu 22.04 上安装 Seafile。

默认情况下,Seafile 在 Ubuntu 22.04 基本存储库上不可用。现在运行以下命令,将最新的稳定版本的 Seafile 下载到您的 Ubuntu 系统:

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

接下来,通过执行以下命令提取包:

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

移动到解压缩的目录中:

cd seafile-server-10.0.1/

运行安装脚本:

./setup-seafile-mysql.sh

按照提示使用您的首选设置配置 Seafile。

完成后,现在切换到目录:/opt/seafile/seafile-server-latest

cd /opt/seafile/seafile-server-latest

运行以下命令以启动 Seaf 服务器:

./seafile.sh start

此外,运行以下命令以启动 Seahub:

./seahub.sh start

第5步。创建海文件系统服务。

现在我们创建并打开文件进行编辑:/etc/systemd/system/seafile.service

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

保存并关闭文件,然后创建并打开文件进行编辑:/etc/systemd/system/seahub.service

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

保存并关闭文件,然后重新加载管理器,以便进行更改:systemd

sudo systemctl daemon-reload
sudo systemctl enable --now seafile
sudo systemctl enable --now seahub

第 6 步。安装Nginx。

默认情况下,Nginx 在 Ubuntu 22.04 基本存储库上可用。现在运行以下命令,将最新版本的 Nginx 安装到您的 Ubuntu 系统中:

sudo apt install nginx

成功安装后,启用 Nginx(在系统启动时自动启动)、启动并使用以下命令验证状态:

sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl status nginx

确认安装并检查已安装的 Nginx 构建版本:

nginx -v

现在我们使用以下命令创建一个新的配置文件:/etc/nginx/conf.d/seafile.conf

server {
    listen 80;
    listen [::]:80;
    server_name  seafile.your-domain.com;
    autoindex off;
    client_max_body_size 100M;
    access_log /var/log/nginx/seafile.com.access.log;
    error_log /var/log/nginx/seafile.com.error.log;

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

     location /seafhttp {
            rewrite ^/seafhttp(.*)$ $1 break;
            proxy_pass http://127.0.0.1:8082;
            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;
        }

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

保存并关闭文件,然后重新启动 Nginx Web 服务器,以便进行更改:

nginx -t
sudo systemctl restart nginx

步骤 7.配置防火墙。

Ubuntu 22.04 默认运行防火墙。启用通过端口 HTTP 和 HTTPS 的连接:ufw80443

sudo ufw allow 'Nginx FULL'
sudo ufw enable
sudo ufw status

第8步。访问海文件网页界面。

成功安装后,您可以使用首选的Web浏览器访问Seafile网络界面。打开浏览器并输入以下地址:

http://seafile.your-domain.com

您应该看到以下页面:

seafile-web-interface-login-1

感谢您使用本教程在 Ubuntu 系统上安装 Seafile。如需其他帮助或有用信息,我们建议您查看官方 Seafile 网站。

未经允许不得转载:统信UOS之家 » 如何在 Ubuntu 22.04 LTS 上安装 Seafile

相关文章