seafile enterprise private cloud disk

introduce

  • Seafile is an open source file cloud storage platform, which solves the problems of centralized file storage, synchronization and multi platform access, and pays attention to security and performance.
  • Seafile
    The "database" is used to classify and manage files. Each database can be synchronized separately. Users can encrypt the database, and the password will not be saved on the server. Therefore, even the server administrator has no right to access your files.
  • Seafile allows users to create "groups" and share and synchronize files within groups, which facilitates team collaboration.

advantage

  1. After the installation configuration is completed, the specified synchronized files have exactly the same operation mode as other files in the computer. It can make users completely unaware of its existence, but it really works.
  2. Realize the "decentralization" of synchronization services to ensure data security. For enterprises, data leakage can be controlled.
  3. Support historical version
  4. Fast synchronization speed, close to the speed of copying files

Docker based installation

Create seafile data and database storage directory

mkdir -p /data/code/seafile-data
mkdir -p /data/code/seafile-mysql/data
mkdir  /opt/docker/seafile
vim /opt/docker/seafile/docker-compose.yml	#Upload and modify
version: '2.0'
services:
  db:
    image: mariadb:10.1
    container_name: seafile-mysql
    environment:
      #Set the root password of MySQL service
      - MYSQL_ROOT_PASSWORD=db_dev
      - MYSQL_LOG_CONSOLE=true
    volumes:
      #Specify the path of MySQL data persistent storage
      - /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
      #Console admin user name
      - SEAFILE_ADMIN_EMAIL=me@example.com
      #Console management user password
      - SEAFILE_ADMIN_PASSWORD=asecret
      #Whether to use letsencrypt to generate certificate
      - SEAFILE_SERVER_LETSENCRYPT=false
      #Specify host ip
      - SEAFILE_SERVER_HOSTNAME=192.168.66.230
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net

networks:
  seafile-net:

Installation based on installation package

  1. Create database

    Create a new ordinary user (seafile does not allow administrator users)

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

    Create ccnet database

    CREATE DATABASE `ccnet`CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    

    Create seafile database

    CREATE DATABASE `seafile`CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    

    Create seahub database

    CREATE DATABASE `seahub`CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
    

    to grant authorization

    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. Install jdk

    tar and mv reach/usr/local/lower
    
    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
     testing: java -version
    
  3. Install python3

    Install dependent packages

    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++
    

    install

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

    perhaps

    Unzip python-3.7.0 tgz

    tar -zxvf Python-3.7.0.tgz
    

    Create an empty folder for storing Python 3 programs

    mkdir /usr/local/python3

    Execute configuration file, compile, compile and install

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

    #After the installation is completed, the installation succeeds without prompting an error
    Establish soft connection

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

    Test whether Python 3 can be used

    pip3 --version
    

    Build Python virtual environment

    cd /usr/local/
    python3 -m venv py3
    source /usr/local/py3/bin/activate
    (py3) [root@xuegod63 ~]#
    #If the switch is successful, there is a py3 ID in front of it
    
  4. Install seafile

    Environment dependent installation

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

    Upload and unzip the installation package

    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
    

    Enter the extracted installation package directory to perform the installation

    cd /data/seafile/installed/seafile-server-7.1.5/
    ./setup-seafile-mysql.sh 
    		Press ENTER to continue(Enter (continue)
    		[ server name ](Define service name: catke)
    		[ This server's ip or domain ](Local machine ip Address or domain name: 192.168.66.40)
    		[ default "8082" ](Setting port: 18890)
    		[ 1 or 2 ](2: (use your own installed database)
    		[ default "localhost" ](Database address: 192.168.66.243)
    		[ default "%" ](Enter (continue)
    		[ default "3306" ](Database port: enter (continue)
    		[ mysql user for seafile ](User name of the Library: seafile_user)
    		[ password for seafile_user ](User password for Library: seafile_yunxia)
    		[ ccnet database ](Library name: ccnet)
    		[ seafile database ] (Library name: seafile)
    		[ seahub database ](Library name: seahub)
    		Press ENTER to continue, or Ctrl-C to abort(Enter (continue)
    

    Modify profile

    7.0. After version x, port 8000 listens to the address 127.0.0.1 by default, which means that you cannot directly access the Seafile service through port 8000. Create nginx according to the official document or modify the following configuration

    vim conf/ccnet.conf
    CONNECTION_CHARSET = utf8mb4
    
    vim conf/seafdav.conf
    # The default value is false. Change to true to use SeafDAV server.
    enabled = true
    port = 8080
    # If fastcgi will be used, change the value of fastcgi to 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'
        }
    }
    #Use cache on
    CACHES = {
        'default': {
            'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
            'LOCATION': 'cache ip:11211',
        },
        'locmem': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        },
    }
    COMPRESS_CACHE_BACKEND = 'locmem'
    #Open online reading
    # Whether to use PDF JS to view files online Default to ` True`
    USE_PDFJS = True
    # The maximum file size of online preview is 30M by default
    FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024
    # The file type extension of the Previewable file
    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"""
    # Turn on the thumbnails function
    ENABLE_THUMBNAIL = True
    # Seafile generates thumbnails only for images smaller than
    THUMBNAIL_IMAGE_SIZE_LIMIT = 30 # MB
    # Storage location of file thumbnails
    THUMBNAIL_ROOT = '/haiwen/seahub-data/thumbnail/thumb/'
    # To enable or disable video thumbnails, ffmpeg and moviepy should be installed in advance
    # For details, see https://manual.seafile.com/deploy/video_thumbnails.html
    ENABLE_VIDEO_THUMBNAIL = False
    # Use the picture in the 5th second as the thumbnail
    THUMBNAIL_VIDEO_FRAME_TIME = 5 
    # The default size of the picture preview. Enlarge this size to improve the quality of the preview.
    THUMBNAIL_SIZE_FOR_ORIGINAL = 1024
    
    #Gmail email example:
    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
    #Mailbox 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
    
    # Whether to enable the user registration function The default is' False '
    ENABLE_SIGNUP = True
    # Activate immediately after user registration. The default value is' True ' If it is set to 'False', it needs to be activated manually by the administrator
    ACTIVATE_AFTER_REGISTRATION = False
    # Whether the administrator sends mail to users after adding users The default is' True '
    SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER = False
    # Whether the administrator sends mail to the user after resetting the user password The default is' True '
    SEND_EMAIL_ON_RESETTING_USER_PASSWD = False
    # After a new user registers, send a notification email to the administrator. The default is' False '.
    NOTIFY_ADMIN_AFTER_REGISTRATION = False
    # Remember the number of days of login status Default 7 days
    LOGIN_REMEMBER_DAYS = 7
    # After the number of user input password errors exceeds this setting, the verification code is displayed
    LOGIN_ATTEMPT_LIMIT = 3
    # If the login password is entered incorrectly more than ` ` LOGIN_ATTEMPT_LIMIT ` `, freeze account
    FREEZE_USER_ON_LOGIN_FAILED = False
    # Minimum length of user password
    USER_PASSWORD_MIN_LENGTH = 6
    # Check the complexity of the user password
    USER_STRONG_PASSWORD_REQUIRED = False
    # Password complexity: numbers, uppercase letters, lowercase letters, other symbols, '3' means at least three of the above four types
    USER_PASSWORD_STRENGTH_LEVEL = 3
    # After the administrator adds / resets the user, force the user to change the login password
    FORCE_PASSWORD_CHANGE = True
    # The time limit for saving cookie s (2 weeks by default)
    SESSION_COOKIE_AGE = 60 * 60 * 24 * 7 * 2
    # Do you want to clear the user session cookie after the browser is closed
    SESSION_EXPIRE_AT_BROWSER_CLOSE = False
    # Whether to store session data for each request Default to ` False`
    SESSION_SAVE_EVERY_REQUEST = False
    # Whether to open personal Wiki and group wiki. Default is ` 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
    # The maximum upload file is 200M
    max_upload_size=2000
    # The maximum download directory is limited to 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]
    # Allocate storage space to all users (e.g. 2GB)
    default = 2
    
  5. Start seafile and 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. Make restart script

    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. Opening requires open ports

  8. Reset administrator password

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

    Installation dependency

    yum -y install gcc pcre-devel openssl-devel
    

    decompression

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

    Specify software ownership

    useradd -s /sbin/nologin nginx
    

    Compile and install

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

    Configure startup file

    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
    

    Modify profile

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

    start-up

    systemctl start nginx
    systemctl enable nginx.service
    

Like the pro can focus on praise comments Oh! It will be updated every day in the future! This article is a small original article;
The files and installation packages used in the article can be obtained by adding the contact information of Xiaobian;
Welcome to exchange Xiaobian's contact information VX: cxklittlebroth

Keywords: Operation & Maintenance

Added by tomdchi on Thu, 03 Feb 2022 08:09:28 +0200