如何在 CentOS 7 上安装 Seafile如何在 CentOS 7 上安装 Seafile如何在 CentOS 7 上安装 Seafile如何在 CentOS 7 上安装 Seafile
  • 业务
  • 目标
  • 支持
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容

如何在 CentOS 7 上安装 Seafile

发表 admin at 2025年2月28日
类别
  • 未分类
标签

介绍

Seafile 是一个私人文件托管平台,类似于 Dropbox、Google Drive、OneDrive 和 Mega。其部分是根据开源许可证发布的,特别是:

  • Seafile iOS 客户端:Apache 许可证 v2
  • Seafile Android 客户端:GPLv3
  • 桌面同步客户端:GPLv2
  • Seafile 服务器核心:AGPLv3
  • Seahub(Seafile 服务器 Web UI):Apache 许可证 v2

支持文件加密和群组共享。

本教程介绍如何在 CentOS 7 上安装 Seafile,并使用 NGINX 作为 Web 服务器和 MariaDB 作为数据库。

入门

首先,Seafile是用Python编写的,因此需要以下依赖:

yum install python-imaging MySQL-python python-memcached python-ldap python-urllib3
安装和配置 MariaDB

安装MariaDB; EPEL 上可用:

yum install epel-release

然后 :

yum install mariadb mariadb-server

在此过程结束时,启动程序并配置 MariaDB root 帐户,执行:

systemctl start mysqld

和

mysql_secure_installation
Set root password? [Y/n]
New password:
Re-enter new password:
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]

Seafile 需要三个不同的数据库(每个组件一个):

  • ccnet数据库
  • Seafile数据库
  • Seahub数据库

因此,创建这些数据库和用户,

seauser

:

mysql -u root -p

在 MariaDB shell 中:

mysql> CREATE DATABASE ccnet-db CHARACTER SET = 'utf8';
mysql> CREATE DATABASE seafile-db CHARACTER SET = 'utf8';
mysql> CREATE DATABASE seahub-db CHARACTER SET = 'utf8';
mysql> CREATE USER 'seauser'@'localhost' IDENTIFIED BY 'user_strong_password';
mysql> GRANT ALL PRIVILEGES ON ccnet-db TO seauser@localhost IDENTIFIED BY 'user_strong_password';
mysql> GRANT ALL PRIVILEGES ON seafile-db TO seauser@localhost IDENTIFIED BY 'user_strong_password';
mysql> GRANT ALL PRIVILEGES ON seahub-db TO seauser@localhost IDENTIFIED BY 'user_strong_password';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
安装 NGINX

由于 EPEL 存储库可用,因此可以使用 yum 安装 NGINX:

yum install nginx

使用 systemd 启动它:

systemctl start nginx.service

创建一个用户和一个组,都命名为

nginx

:

adduser --user-group --system --no-create-home nginx

安装和配置Seafile

创建一个新目录:

mkdir /var/www/seafile
cd /var/www/seafile

在那里,下载 Seafile

wget

:

wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_6.0.8_x86-64.tar.gz

提取存档:

tar xf seafile-server_6.0.8_x86-64.tar.gz

重命名提取的目录:

mv seafile-server-6.0.8 seafile-server
cd seafile-server

有一个脚本,名为

setup-seafile-mysql.sh

为了配置数据库,执行它:

./setup-seafile-mysql.sh

它会要求一些信息:

  • 服务器名称:我的服务器
  • 服务器 ip 或域:localhost
  • seafile data dir:按回车键,将使用当前目录
  • 文件服务器端口:输入,应该使用8082

接下来,它将显示以下内容:

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

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

选择选项2,然后:

  • 使用默认主机:localhost
  • 默认端口:3306
  • mysql 用户:‘seauser’
  • Seafile mysql 用户的密码:‘user_strong_password’
  • ccnet 数据库:‘ccnet-db’
  • Seafile 数据库:‘seafile-db’
  • seahub 数据库:‘seahub-db’

接下来,该脚本将为 Seafile 创建所需的表。

启动 Seafile 和 Seahub:

./seafile.sh start
./seahub.sh start

在执行过程中,seahub.sh 将询问管理员信息,特别是您的电子邮件和密码。

之后,Seafile 将运行,并且可以使用 Web 浏览器在 localhost:8000 访问它。
接下来,您需要将 NGINX 配置为反向代理。但首先,有必要创建一个 systemd 服务。

配置服务

将Seafile安装目录和缓存所有者更改为用户

nginx

:

chown -R nginx:nginx /var/www/*
chown -R nginx:nginx /tmp/seahub_cache

然后创建一个服务:

$EDITOR /etc/systemd/system/seafile.service

在此文件中,粘贴以下配置:

[Unit]
Description=Seafile - the open source, self-hosted file sync
Before=seahub.service
After=network.target mariadb.service
 
[Service]
Type=oneshot
ExecStart=/var/www/seafile/seafile-server/seafile.sh start
ExecStop=/var/www/seafile/seafile-server/seafile.sh stop
RemainAfterExit=yes
User=nginx
Group=nginx
 
[Install]
WantedBy=multi-user.target

保存,退出并对 SeaHub 执行相同操作:

$EDITOR /etc/systemd/system/seahub.service

并粘贴:

[Unit]
Description=SeaHub
After=network.target seafile.target mariadb.service
 
[Service]
Type=oneshot
ExecStart=/var/www/seafile/seafile-server/seahub.sh start-fastcgi
ExecStop=/var/www/seafile/seafile-server/seahub.sh stop
RemainAfterExit=yes
User=nginx
Group=nginx
 
[Install]
WantedBy=multi-user.target

保存,退出然后:

systemctl daemon-reload
systemctl start seafile
systemctl start seahub

配置 NGINX

Seafile 已正确运行,现在配置 NGINX 以在其后面运行 Seafile。创建一个新的虚拟主机文件:

$EDITOR /etc/nginx/conf.d/seafile.conf

那里:



<span class="hljs-section">server</span> {
    <span class="hljs-attribute">listen</span> <span class="hljs-number">80</span>;
    <span class="hljs-attribute">server_name</span> seafile.mydomain.com;

    <span class="hljs-attribute">proxy_set_header</span> X-Forwarded-For <span class="hljs-variable">$remote_addr</span>;

    <span class="hljs-attribute">location</span> / {
        <span class="hljs-attribute">fastcgi_pass</span>    <span class="hljs-number">127.0.0.1:8000</span>;
        <span class="hljs-attribute">fastcgi_param</span>   SCRIPT_FILENAME     <span class="hljs-variable">$document_root</span><span class="hljs-variable">$fastcgi_script_name</span>;
        <span class="hljs-attribute">fastcgi_param</span>   PATH_INFO           <span class="hljs-variable">$fastcgi_script_name</span>;

        <span class="hljs-attribute">fastcgi_param</span>    SERVER_PROTOCOL        <span class="hljs-variable">$server_protocol</span>;
        <span class="hljs-attribute">fastcgi_param</span>   QUERY_STRING        <span class="hljs-variable">$query_string</span>;
        <span class="hljs-attribute">fastcgi_param</span>   REQUEST_METHOD      <span class="hljs-variable">$request_method</span>;
        <span class="hljs-attribute">fastcgi_param</span>   CONTENT_TYPE        <span class="hljs-variable">$content_type</span>;
        <span class="hljs-attribute">fastcgi_param</span>   CONTENT_LENGTH      <span class="hljs-variable">$content_length</span>;
        <span class="hljs-attribute">fastcgi_param</span>    SERVER_ADDR         <span class="hljs-variable">$server_addr</span>;
        <span class="hljs-attribute">fastcgi_param</span>    SERVER_PORT         <span class="hljs-variable">$server_port</span>;
        <span class="hljs-attribute">fastcgi_param</span>    SERVER_NAME         <span class="hljs-variable">$server_name</span>;
        <span class="hljs-attribute">fastcgi_param</span>   REMOTE_ADDR         <span class="hljs-variable">$remote_addr</span>;

        <span class="hljs-attribute">access_log</span>      /var/log/nginx/seahub.access.log;
        <span class="hljs-attribute">error_log</span>       /var/log/nginx/seahub.<span class="hljs-literal">error</span>.log;
        <span class="hljs-attribute">fastcgi_read_timeout</span> <span class="hljs-number">36000</span>;
    }

    <span class="hljs-attribute">location</span> /seafhttp {
        <span class="hljs-attribute">rewrite</span><span class="hljs-regexp"> ^/seafhttp(.*)$</span> <span class="hljs-variable">$1</span> <span class="hljs-literal">break</span>;
        <span class="hljs-attribute">proxy_pass</span> http://127.0.0.1:8082;
        <span class="hljs-attribute">client_max_body_size</span> <span class="hljs-number">0</span>;
        <span class="hljs-attribute">proxy_connect_timeout</span>  <span class="hljs-number">36000s</span>;
        <span class="hljs-attribute">proxy_read_timeout</span>  <span class="hljs-number">36000s</span>;
        <span class="hljs-attribute">proxy_send_timeout</span>  <span class="hljs-number">36000s</span>;
        <span class="hljs-attribute">send_timeout</span>  <span class="hljs-number">36000s</span>;
    }

    <span class="hljs-attribute">location</span> /media {
        <span class="hljs-attribute">root</span> /path/to/your/directory;
    }
}

保存、退出并测试 NGINX,如下所示:

nginx -t

在 ccnet.conf 和 seahub_setting.py 中配置域

修改值

SERVICE_URL

在 ccnet.conf 中让 Seafile 了解所选的域、协议和端口:

$EDITOR /var/www/seafile/conf/ccnet.conf

并进行更改:

SERVICE_URL = http://seafile.mydomain.com

保存、退出并编辑SeaHub配置文件:

$EDITOR /var/www/seafile/conf/seahub_setting.py

那里 :

FILE_SERVER_ROOT = 'http://seafile.mydomain.com/seafhttp'

保存、退出并重启服务:

systemctl restart seafile
systemctl restart seahub

测试Seafile

使用网络浏览器访问 URL:http://seafile.mydomain.com;它将显示一个登录表单,您可以在其中输入之前创建的管理员帐户信息。就这样!现在您可以像任何其他云存储系统一样使用 Seafile!

©2015-2025 Norria support@alaica.com