1 相关链接

1.1 官方文档

Linux 下部署 Seafile 服务器

1.2 树莓派服务端下载地址

seafile-rpi/releases

选择的版本:

seafile-server-8.0.3-buster-arm64v8.tar.gz

2 安装

2.1 安装依赖

cloud@server:~ $ sudo apt-get update
cloud@server:~ $ sudo apt-get install python3 python3-setuptools python3-pip python3-ldap -y
cloud@server:~ $ sudo pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy psd-tools pymysql django-pylibmc django-simple-captcha -i https://mirrors.aliyun.com/pypi/simple

2.1 安装seafile

解压

cloud@server:~ $ mkdir -p /opt/module/seafile/installed
cloud@server:~ $ cd /opt/module/seafile/installed/
# 将压缩包上传到该目录
cloud@server:/opt/module/seafile/installed $ tar -zxvf seafile-server-8.0.3-buster-arm64v8.tar.gz -C /opt/module/seafile
cloud@server:/opt/module/seafile/installed $ cd /opt/module/seafile
cloud@server:/opt/module/seafile $ ll
total 8
drwxr-xr-x 2 cloud cloud 4096 Mar 14 17:53 installed
drwxr-xr-x 7 cloud cloud 4096 Feb 22 04:59 seafile-server-8.0.3

安装

cloud@server:/opt/module/seafile $ cd seafile-server-8.0.3/
# 运行安装脚本并回答预设问题
cloud@server:/opt/module/seafile/seafile-server-8.0.3 $ ./setup-seafile-mysql.sh

-------------------------------------------------------
Please choose a way to initialize seafile databases:
-------------------------------------------------------
# 选择1, 提供root密码. 脚本程序会创建数据库和用户。
[1] Create new ccnet/seafile/seahub databases
[2] Use existing ccnet/seafile/seahub databases

启动

cloud@server:/opt/module/seafile/seafile-server-8.0.3 $ cd ../seafile-server-latest/
cloud@server:/opt/module/seafile/seafile-server-latest $ ./seafile.sh start
cloud@server:/opt/module/seafile/seafile-server-latest $ ./seahub.sh start

开机自启

cloud@server:/opt/module/seafile/seafile-server-latest $ su -
root@server:~# vim /etc/rc.local 

# 在exit 0上面添加
nohup /opt/module/frp/frpc -c /opt/module/frp/frpc.ini >> /opt/module/frp/frpc.log 2>&1 &
nohup /opt/module/seafile/seafile-server-8.0.3/seafile.sh start 1>/dev/null 2>&1 &
nohup /opt/module/seafile/seafile-server-8.0.3/seahub.sh start 1>/dev/null 2>&1 &

2.2 配置Nginx反向代理

cloud@server:/opt/module/seafile/seafile-server-latest $ cd /etc/nginx/sites-available/
cloud@server:/etc/nginx/sites-available $ sudo vim seafile

创建文件

server {
    listen 55106;
    server_name cloud.tangke8.com;

    proxy_set_header X-Forwarded-For $remote_addr;

    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;

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

         access_log      /var/log/nginx/seahub.access.log;
         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;

        proxy_request_buffering off;
    }

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

创建符号链接

cloud@server:/etc/nginx/sites-available $ sudo ln -s /etc/nginx/sites-available/seafile /etc/nginx/sites-enabled/seafile

重启Nginx服务

cloud@server:/etc/nginx/sites-available $ sudo service nginx restart

此时可以在 http://${树莓派ip}:55106 访问seafile服务

3 映射到公网ip

3.1 添加主机名映射

在阿里云主机上

cloud@aliyun:~$ sudo vim /etc/hosts

增加一行

127.0.0.1       cloud.tangke8.com

3.2 增加域名解析

在阿里云控制台上增加对子域名cloud的解析

https://swas.console.aliyun.com/

3.3 增加frp映射

cloud@server:/etc/nginx/sites-available $ cd /opt/module/frp/
cloud@server:/opt/module/frp $ vim frpc.ini

增加一行

[web-cloud]
type = http
local_ip = 127.0.0.1
local_port = 55106
custom_domains = cloud.tangke8.com

重启frpc服务

cloud@server:/opt/module/frp $ ps -ef|grep frpc
cloud@server:/opt/module/frp $ sudo kill -9 xxxxx
cloud@server:/opt/module/frp $ sudo nohup /opt/module/frp/frpc -c /opt/module/frp/frpc.ini >> /opt/module/frp/frpc.log 2>&1 &

此时可以在 http://cloud.tangke8.com 访问seafile服务

4 配置Seafile

登陆web页面后,在右上角点击系统管理 → 设置

更改

SERVICE_URL为 http://cloud.tangke8.com/

FILE_SERVER_ROOT为 http://cloud.tangke8.com/seafhttp

即可正常上传下载文件