其他分享
首页 > 其他分享> > seafile企业私有云盘

seafile企业私有云盘

作者:互联网

介绍

优点

  1. 安装配置完成后,指定同步的文件与电脑中的其他文件有完全一致的操作方式。可以让用户完全感觉不到它的存在,但它实实在在的工作着。
  2. 实现同步服务的“去中心化”,保证数据安全,对于企业而言,可控制数据不外漏。
  3. 支持历史版本
  4. 同步速度快,接近拷贝文件速度

基于Docker方式安装

创建seafile数据、数据库存放目录

mkdir -p /data/code/seafile-data
mkdir -p /data/code/seafile-mysql/data
mkdir  /opt/docker/seafile
vim /opt/docker/seafile/docker-compose.yml	#上传并修改
version: '2.0'
services:
  db:
    image: mariadb:10.1
    container_name: seafile-mysql
    environment:
      #设置MySQL服务的根用户密码
      - MYSQL_ROOT_PASSWORD=db_dev
      - MYSQL_LOG_CONSOLE=true
    volumes:
      #指定MySQL数据持久存储的路径
      - /data/code/seafile-mysql/data:/var/lib/mysql
    networks:
      - seafile-net

  memcached:
    image: memcached:1.5.6
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net
          
  seafile:
    image: seafileltd/seafile-mc:latest
    container_name: seafile
    ports:
      - "18889:80"
    volumes:
      - /data/code/seafile-data:/shared
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=db_dev
      - TIME_ZONE=Asia/Shanghai
      #控制台管理用户名
      - SEAFILE_ADMIN_EMAIL=me@example.com
      #控制台管理用户密码
      - SEAFILE_ADMIN_PASSWORD=asecret
      #是否使用letsencrypt生成证书
      - SEAFILE_SERVER_LETSENCRYPT=false
      #指定主机ip
      - SEAFILE_SERVER_HOSTNAME=192.168.66.230
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net

networks:
  seafile-net:

基于安装包方式安装

  1. 创建数据库

    新建一个普通用户(seafile不允许使用管理员用户)

    CREATE USER 'seafile_user'@'%' IDENTIFIED BY 'seafile_yunxia';
    

    创建ccnet数据库

    CREATE DATABASE `ccnet`CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    

    创建seafile数据库

    CREATE DATABASE `seafile`CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    

    创建seahub数据库

    CREATE DATABASE `seahub`CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    

    授权

    GRANT ALL PRIVILEGES ON ccnet.* TO 'seafile_user'@'%';
    GRANT ALL PRIVILEGES ON seafile.* TO 'seafile_user'@'%';
    GRANT ALL PRIVILEGES ON seahub.* TO 'seafile_user'@'%';
    
  2. 安装jdk

    tar并mv到/usr/local/下
    
    vim  /etc/profile
    export JAVA_HOME=/opt/jdk1.8.0_152
    export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/ 
    export PATH=$PATH:$JAVA_HOME/bin
    
    source /etc/profile
    检测:java -version
    
  3. 安装python3

    安装依赖包

    yum install -y epel-release                                                            
    
    yum -y install python3 python3-setuptools python3-pip python3-ldap  libmemcached libreoffice-headless libreoffice-pyuno libffi-devel pwgen  curl python3-devel gcc gcc-c++
    

    安装

    pip3 install --timeout=3600 Pillow pylibmc captcha jinja2 sqlalchemy==1.3.8  psd-tools django-pylibmc django-simple-captcha
    

    或者

    解压Python-3.7.0.tgz

    tar -zxvf Python-3.7.0.tgz
    

    建立一个空文件夹,用于存放python3程序

    mkdir /usr/local/python3

    执行配置文件,编译,编译安装

    cd Python-3.7.0
    ./configure --prefix=/usr/local/python3
    make && make install
    

    #安装完成没有提示错误便安装成功了
    建立软连接

    ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
    ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
    

    测试一下python3是否可以用

    pip3 --version
    

    建立 Python 虚拟环境

    cd /usr/local/
    python3 -m venv py3
    source /usr/local/py3/bin/activate
    (py3) [root@xuegod63 ~]#
    #切换成功的,前面有一个py3 标识
    
  4. 安装seafile

    依赖环境安装

    yum install python python-setuptools MySQL-python python-urllib3 python-ldap -y
    

    上传并解压安装包

    mkdir -p /data/seafile/
    tar -xvf seafile-server_7.1.5_x86-64.tar.gz -C /data/seafile/
    mv /data/seafile/ seafile-server_7.1.5 /data/seafile/ seafile-server_7.1.5-install
    

    进入解压出来的安装包目录执行安装

    cd /data/seafile/installed/seafile-server-7.1.5/
    ./setup-seafile-mysql.sh 
    		Press ENTER to continue(回车继续)
    		[ server name ](定义服务名称:catke)
    		[ This server's ip or domain ](本机ip地址或域名:192.168.66.40)
    		[ default "8082" ](设置端口:18890)
    		[ 1 or 2 ](2:使用自己安装的数据库)
    		[ default "localhost" ](数据库地址:192.168.66.243)
    		[ default "%" ](回车继续)
    		[ default "3306" ](数据库端口:回车继续)
    		[ mysql user for seafile ](库的用户名:seafile_user)
    		[ password for seafile_user ](库的用户密码:seafile_yunxia)
    		[ ccnet database ](库名:ccnet)
    		[ seafile database ] (库名:seafile)
    		[ seahub database ](库名:seahub)
    		Press ENTER to continue, or Ctrl-C to abort(回车继续)
    

    修改配置文件

    7.0.x 版本之后,8000端口默认监听在127.0.0.1地址上,这意味着您无法直接通过 8000端口访问Seafile服务,按官方文档建nginx或者修改下面配置

    vim conf/ccnet.conf
    CONNECTION_CHARSET = utf8mb4
    
    vim conf/seafdav.conf
    # 默认值是false。改为true来使用SeafDAV server。
    enabled = true
    port = 8080
    # 如果fastcgi将被使用则更改fastcgi的值为true。
    fastcgi = true
    share_name = /seafdav
    
    vim conf/seahub_settings.py
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'seahub_db',
            'USER': 'seafile',
            'PASSWORD': '32ef28d8-fb09-4074-9ed2-a565c35ca3e7',
            'HOST': 'db',
            'PORT': '3306'
        }
    }
    #使用缓存开启
    CACHES = {
        'default': {
            'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
            'LOCATION': '缓存ip:11211',
        },
        'locmem': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        },
    }
    COMPRESS_CACHE_BACKEND = 'locmem'
    #开启在线阅览
    # 是否使用 pdf.js 来在线查看文件. 默认为 `True`
    USE_PDFJS = True
    # 在线预览的文件大小上限,默认为 30M.
    FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
    # 可预览文件的文件类型扩展名
    TEXT_PREVIEW_EXT = """ac, am, bat, c, cc, cmake, cpp, cs, css, diff, el, h, html, htm, java, js, json, less, make, org, php, pl, properties, py, rb, scala, script, sh, sql, txt, text, tex, vi, vim, xhtml, xml, log, csv, groovy, rst, patch, go, doc, docx, ppt, pptx, xls, xlsx, odt, fodt, odp, fodp, ods, fods"""
    # 开启 thumbnails 功能
    ENABLE_THUMBNAIL = True
    # Seafile只针对小于以下尺寸的图片生成缩略图
    THUMBNAIL_IMAGE_SIZE_LIMIT = 30 # MB
    # 文件缩略图的存储位置
    THUMBNAIL_ROOT = '/haiwen/seahub-data/thumbnail/thumb/'
    # 开启或禁用视频缩略图,ffmpeg 和 moviepy 应该事先被安装
    # 详情,请参阅https://manual.seafile.com/deploy/video_thumbnails.html
    ENABLE_VIDEO_THUMBNAIL = False
    # 使用第5秒的图片作为缩略图
    THUMBNAIL_VIDEO_FRAME_TIME = 5 
    # 图片预览的默认大小。放大这个尺寸可以提高预览的质量。
    THUMBNAIL_SIZE_FOR_ORIGINAL = 1024
    
    #Gmail 邮箱示例:
    EMAIL_USE_TLS/EMAIL_USE_SSL = True
    EMAIL_HOST = 'smtp.gmail.com'
    EMAIL_HOST_USER = 'username@gmail.com'
    EMAIL_HOST_PASSWORD = 'password'
    EMAIL_PORT = '587/465'
    DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
    SERVER_EMAIL = EMAIL_HOST_USER
    #126 邮箱
    EMAIL_USE_TLS/EMAIL_USE_SSL = True
    EMAIL_HOST = 'smtp.vip.126.com'
    EMAIL_HOST_USER = 'test@vip.126.com'
    EMAIL_HOST_PASSWORD = 'password'
    EMAIL_PORT = '587/465'
    DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
    SERVER_EMAIL = EMAIL_HOST_USER
    
    # 是否开启用户注册功能. 默认为 `False`.
    ENABLE_SIGNUP = True
    # 用户注册后是否立刻激活,默认为 `True`.如设置为 `False`, 需管理员手动激活.
    ACTIVATE_AFTER_REGISTRATION = False
    # 管理员新增用户后是否给用户发送邮件. 默认为 `True`.
    SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = False
    # 管理员重置用户密码后是否给用户发送邮件. 默认为 `True`.
    SEND_EMAIL_ON_RESETTING_USER_PASSWD = False
    # 新用户注册后,给管理员发送通知邮件。默认为 `False`。
    NOTIFY_ADMIN_AFTER_REGISTRATION = False
    # 记住登录状态的天数. 默认 7 天
    LOGIN_REMEMBER_DAYS = 7
    # 用户输入密码错误次数超过该设置后,显示验证码
    LOGIN_ATTEMPT_LIMIT = 3
    # 如果登录密码输错次数超过 ``LOGIN_ATTEMPT_LIMIT``,冻结账号
    FREEZE_USER_ON_LOGIN_FAILED = False
    # 用户密码最少长度
    USER_PASSWORD_MIN_LENGTH = 6
    # 检查用户密码的复杂性
    USER_STRONG_PASSWORD_REQUIRED = False
    # 密码复杂性:数字, 大写字母, 小写字母, 其他符号,'3' 表示至少包含以上四种类型中的3个
    USER_PASSWORD_STRENGTH_LEVEL = 3
    # 管理员添加/重置用户后,强制用户修改登录密码
    FORCE_PASSWORD_CHANGE = True
    # cookie 的保存时限,(默认为 2 周).
    SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
    # 浏览器关闭后,是否清空用户会话 cookie
    SESSION_EXPIRE_AT_BROWSER_CLOSE = False
    # 是否存储每次请求的会话数据. 默认为 `False`
    SESSION_SAVE_EVERY_REQUEST = False
    # 是否开启个人wiki和群组wiki。默认是 `False`
    ENABLE_WIKI = True
    
    vim conf/gunicorn.conf.py
    #bind = "127.0.0.1:8000"
    bind = "192.168.66.230:8000"
    
    vim conf/seafile.conf
    [fileserver]
    port = 18890
    # 上传文件最大为200M.
    max_upload_size=2000
    # 最大下载目录限制为200M.
    max_download_dir_size=200
    [database]
    type = mysql
    host = 192.168.66.243
    port = 3306
    user = seafile_user
    password = seafile_yunxia
    db_name = seafile
    connection_charset = utf8mb4
    [quota]
    # 向所有用户分配存储空间(e.g. 2GB)
    default = 2
    
  5. 启动seafile、seahub

    vim /etc/systemd/system/seafile.service
    [Unit]
    Description=Seafile Server
    After=network.target remote-fs.target mariadb.service
    
    [Service]
    ExecStart=/data/seafile/installed/seafile-server-latest/seafile.sh start
    ExecStop=/data/seafile/installed/seafile-server-latest/seafile.sh stop
    LimitNOFILE=infinity
    Type=oneshot
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    
    vim /etc/systemd/system/seahub.service
    [Unit]
    Description=Seafile Seahub
    After=network.target seafile.service
    
    [Service]
    ExecStart=/data/seafile/installed/seafile-server-latest/seahub.sh start
    ExecStop=/data/seafile/installed/seafile-server-latest/seahub.sh stop
    Type=oneshot
    RemainAfterExit=yes
    
    [Install]
    WantedBy=multi-user.target
    
    systemctl start seafile.service
    systemctl status seafile.service
    systemctl enable seafile.service
    systemctl start seahub.service
    systemctl status seahub.service
    systemctl enable seahub.service
    
  6. 制作重启脚本

    vim /sh/seafile-server-restart.sh
    #!/bin/bash
    for ACTION in stop start ; do
        for SERVICE in seafile seahub ; do
          systemctl ${ACTION} ${SERVICE}
        done
    done
    
    chmod 700 /sh/seafile-server-restart.sh
    
  7. 开放需要开放的端口

  8. 重置管理员密码

    cd /data/seafile/installed/seafile-server-latest/
    ./reset-admin.sh
    	cxk@example.com
    	caoxuekun
    
  9. 安装nginx

    安装依赖

    yum -y install gcc pcre-devel openssl-devel
    

    解压

    tar -xvf nginx-1.18.0.tar.gz -C /data/
    

    指定软件归属

    useradd -s /sbin/nologin nginx
    

    编译安装

    cd /data/nginx-1.18.0/
    ./configure --prefix=/data/nginx --user=nginx --group=nginx  --with-http_ssl_module --with-stream
    make && make install
    

    配置启动文件

    vim /usr/lib/systemd/system/nginx.service
    [Unit]
    Description=nginx
    After=network.target
      
    [Service]
    Type=forking
    ExecStart=/usr/local/nginx/sbin/nginx
    ExecReload=/usr/local/nginx/sbin/nginx -s reload
    ExecStop=/usr/local/nginx/sbin/nginx -s quit
    PrivateTmp=true
      
    [Install]
    WantedBy=multi-user.target
    
    systemctl daemon-reload
    

    修改配置文件

    vim /data/nginx/conf/nginx.conf
    worker_processes  2;
    events {
        worker_connections  2048;
        multi_accept on;
        use epoll;
    }
    http {
        server_tokens off;
        server_names_hash_bucket_size 128;
        client_max_body_size 50M;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
        sendfile on;
        tcp_nopush on;
        keepalive_timeout 65;
        gzip off;
        server {
            listen       80;
            server_name  localhost 192.168.66.40;
            proxy_set_header X-Forwarded-For \$remote_addr;
            location / {
                proxy_pass         http://192.168.66.40: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_set_header   X-Forwarded-Proto $scheme;
                proxy_read_timeout  1200s;
                client_max_body_size 0;
                access_log      logs/seahub.access.log;
                error_log       logs/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;
                access_log      logs/seafhttp.access.log;
                error_log       logs/seafhttp.error.log;
            }
            location /media {
                root /data/seafile/installed/seafile-server-latest/seahub;
            }
            location /seafdav {
                proxy_pass         http://127.0.0.1:8080/seafdav;
                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_set_header   X-Forwarded-Proto $scheme;
                proxy_read_timeout  1200s;
                client_max_body_size 0;
                access_log      logs/seafdav.access.log;
                error_log       logs/seafdav.error.log;
            }
    

    启动

    systemctl start nginx
    systemctl enable nginx.service
    

在这里插入图片描述

喜欢的亲可以关注点赞评论哦!以后每天都会更新的哦!本文为小编原创文章;
文章中用到的文件、安装包等可以加小编联系方式获得;
欢迎来交流小编联系方式VX:CXKLittleBrother

标签:私有,云盘,data,nginx,proxy,server,seafile,EMAIL
来源: https://blog.csdn.net/qq_39122260/article/details/117525643