服务器配置记录(六) 网盘搭建(基于 seafile和Docker)

本文介绍如何通过Docker及Docker Compose部署Seafile云盘系统,包括环境搭建、配置文件修改等步骤,并实现OnlyOffice在线编辑功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 安装docker

使用脚本一键安装

sudo curl -sSL https://get.daocloud.io/docker | sh
# 开机启动
sudo systemctl enable docker.service

2. 安装Docker-compose

sudo apt install docker-compose

3. 创建并修改 docker-compose.yml

Seafile Cloud

mkdir seafile && cd seafile/
vim docker-compose.yml

主要应该修改mysql root用户账号密码,重要文件保存位置,并添加了onlyoffice用于支持在线编辑office

version: '2.0'
services:
  db:
    image: mariadb:10.5
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=db_dev  # Requested, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
    volumes:
      - /media/xxxx/HDD2/seafile/db_files:/var/lib/mysql  # MySQL 文件路径 Requested, specifies the path to MySQL data persistent store.
    networks:
      - seafile-net

  memcached:
    image: memcached:1.6
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net

  onlyoffice:
    image: onlyoffice/documentserver
    container_name: onlyoffice
    ports:
      - "8889:80"
    networks:
      - seafile-net

  seafile:
    image: seafileltd/seafile-mc:latest
    container_name: seafile
    ports:
      - "8888:80"
#      - "443:443"  # If https is enabled, cancel the comment.
    volumes:
      - /media/xxxx/HDD2/seafile/files:/shared   # Seafile文件路径,包括配置文件和网盘文件 Requested, specifies the path to Seafile data persistent store.
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=db_dev  # Requested, the value shuold be root's password of MySQL service.
      - TIME_ZONE=Asia/Shanghai # Optional, default is UTC. Should be uncomment and set to your local time zone.
      - SEAFILE_ADMIN_EMAIL=XXXX@XXXX.com # Specifies Seafile admin user, default is 'me@example.com'.
      - SEAFILE_ADMIN_PASSWORD=xxxxxx     # Specifies Seafile admin password, default is 'asecret'.
      - SEAFILE_SERVER_LETSENCRYPT=false   # Whether use letsencrypt to generate cert.
      - SEAFILE_SERVER_HOSTNAME=seafile.xxxx.com # Specifies your host name.
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net

4. docker换源

更换到科大源,提高镜像下载速度

sudo vim /etc/docker/daemon.json
{
  "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}

重启docker

systemctl restart docker

5. 启动容器

 sudo docker-compose up -d

6. 一些配置文件修改

cat /media/xxxx/HDD2/seafile/files/seafile/conf/seahub_settings.py
# -*- coding: utf-8 -*-
SECRET_KEY = "b'xxxxxxxxx'"
SERVICE_URL = "http://seafile.xxxxx.com/"

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'seahub_db',
        'USER': 'seafile',
        'PASSWORD': '1f900e5c-349b-420f-85dc-50c9eb6124ef',
        'HOST': 'db',
        'PORT': '3306',
        'OPTIONS': {'charset': 'utf8mb4'},
    }
}


CACHES = {
    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': 'memcached:11211',
    },
    'locmem': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    },
}
COMPRESS_CACHE_BACKEND = 'locmem'
TIME_ZONE = 'Asia/Shanghai'
# 主要是修改如下内容 包括文件存储url和ONLYOFFICE支持
FILE_SERVER_ROOT = "http://192.168.150.69:8888/seafhttp"
# OFFICE_CONVERTOR_ROOT = 'http://192.168.150.69:8889'

ENABLE_ONLYOFFICE = True
VERIFY_ONLYOFFICE_CERTIFICATE = False
ONLYOFFICE_APIJS_URL = 'http://192.168.150.69:8889/web-apps/apps/api/documents/api.js'
ONLYOFFICE_FILE_EXTENSION = ('pdf','doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'odt', 'fodt', 'odp', 'fodp', 'ods', 'fods')
ONLYOFFICE_EDIT_FILE_EXTENSION = ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx')

cat  /media/xxxx/HDD2/seafile/files/seafile/conf/seafile.conf
[fileserver]
port = 8082

[database]
type = mysql
host = db
port = 3306
user = seafile
password = xxxxxxxxxxx
db_name = seafile_db
connection_charset = utf8

[quota]
default = 100 # 主要修改了这里每用户的默认可用空间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值