Fading Coder

One Final Commit for the Last Sprint

Home > Notes > Content

Installing Seafile on Ubuntu 24.04 Virtual Machine and Configuring OnlyOffice on Windows

Notes 1

Environment Setup

The setup involves Windows Server 2019 hosting OnlyOffice with MySQL 5.7 configured for Seafile's database. A virtual machine running Ubuntu 24.04 Server Edition hosts Seafile, as Ubuntu 22.04 installation methods are incompatible.

Seafile operates without Nginx initially (though Nginx was later added). Files are stored via shared folders from Windows rather than within the VM.

Installing Seafile

  1. System Preparation

    • Ubuntu 24.04 virtual machine installed with SSH server only for remote access.
    • MySQL 5.7 already installed on the Windows host.
    • Downloaded Seafile Pro Server version 11.0.6 for Linux (64-bit) from the official site.
  2. Extract Installation Package

    mkdir -p /opt/seafile/installed
    mv seafile-pro-server_* /opt/seafile/installed
    cd /opt/seafile/installed
    tar -xzf seafile-pro-server_* -C /opt/seafile
    
  3. Install Dependencies

    sudo apt-get update
    sudo apt-get install -y python3 python3-dev python3-setuptools python3-pip libmysqlclient-dev ldap-utils libldap2-dev python3.12-venv
    sudo apt-get install -y memcached libmemcached-dev
    
    # Create virtual environment
    python3 -m venv python-venv
    source python-venv/bin/activate
    
    # Install Python packages
    pip3 install --timeout=3600 django==4.2.* future==0.18.* mysqlclient==2.1.* \
        pymysql pillow==10.2.* pylibmc captcha==0.5.* markupsafe==2.0.1 jinja2 sqlalchemy==2.0.18 \
        psd-tools django-pylibmc django_simple_captcha==0.6.* djangosaml2==1.5.* pysaml2==7.2.* pycryptodome==3.16.* cffi==1.16.0 lxml python-ldap==3.4.3
    
  4. Database Configurasion

    • Create a dedicated MySQL user:
      CREATE USER 'seafile'@'%' IDENTIFIED BY 'seafile';
      GRANT ALL PRIVILEGES ON *.* TO 'seafile'@'%';
      FLUSH PRIVILEGES;
      
    • If using MySQL 8.4+, enable mysql_native_password plugin:
      [mysqld]
      mysql_native_password=ON
      
    • Update password encryption:
      ALTER USER 'seafile'@'%' IDENTIFIED WITH mysql_native_password BY 'seafile';
      FLUSH PRIVILEGES;
      
    • Create required databases:
      CREATE DATABASE `ccnet` CHARACTER SET utf8;
      CREATE DATABASE `seafile` CHARACTER SET utf8;
      CREATE DATABASE `seahub` CHARACTER SET utf8;
      
  5. Run Setup Script

    cd /opt/seafile/seafile-pro-server_11.0.6
    ./setup-seafile-mysql.sh
    

    Choose option 2 if MySQL is pre-installed and non-local.

  6. Post-Installation Steps

    • Start services:
      cd /opt/seafile/seafile-server-latest
      ./seafile.sh start
      ./seahub.sh start
      
    • Configure service URLs in the admin panel under "Settings".
  7. Configure Shared Storage

    • Create directories on Windows: seafile-data and seahub-data
    • Mount these shares in Ubuntu:
      sudo apt-get install cifs-utils
      mount.cifs //192.168.xxx.xxx/seafile-data seafile-data -o user=administrator
      mount.cifs //192.168.xxx.xxx/seahub-data seahub-data -o user=administrator
      
    • Add to /etc/fstab for automatic mounting:
      //192.168.xxx.xxx/seafile-data /opt/seafile/seafile-data cifs username=administrator,password=yourpass,iocharset=utf8 0 0
      //192.168.xxx.xxx/seahub-data /opt/seafile/seahub-data cifs username=administrator,password=yourpass,iocharset=utf8 0 0
      

Installing OnlyOffice

Install OnlyOffice on Windows Server 2019 with Erlang, RabbitMQ, and PostgreSQL using default settings. Pay special attention to PostgreSQL password configuration during setup.

Integratnig Both Systems

  1. Update Seafile Settings In /opt/seafile/conf/seahub_settings.py:

    ENABLE_ONLYOFFICE = True
    VERIFY_ONLYOFFICE_CERTIFICATE = False
    ONLYOFFICE_APIJS_URL = 'http://192.168.3.110/web-apps/apps/api/documents/api.js'
    ONLYOFFICE_FILE_EXTENSION = ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'odt', 'fodt', 'odp', 'fodp', 'ods', 'fods')
    ONLYOFFICE_EDIT_FILE_EXTENSION = ('docx', 'pptx', 'xlsx', 'doc', 'xls', 'ppt')
    ONLYOFFICE_JWT_SECRET = 'your-secret-key'
    SERVICE_URL = "http://192.168.xxx.xxx:8000/"
    
  2. Modify Gunicorn Configuration Change bind = "127.0.0.1:8000" to bind = "0.0.0.0:8000" in /opt/seafile/conf/gunicorn.conf.py

  3. Obtain JWT Secret Extract the secret key from local.json in OnlyOffice config folder.

  4. Adjust OnlyOffice Settings In default.json, modify:

    "request-filtering-agent": {
        "allowPrivateIPAddress": true,
        "allowMetaIPAddress": true
    }
    

Additional Considerations

  1. MySQL authentication method issues when creating new users
  2. Incorrect database creation with root user enstead of dedicated user
  3. Missing port specification in SERVICE_URL causing save errors
  4. PostgreSQL password setting oversight during installation
  5. Network restrictions preventing file downloads in OnlyOffice
  6. Chrome + IDM conflict where editor.bin is mistaken for downloadable file

Memcached and Nginx Configuration

  1. Install Memcached

    sudo apt install memcached libmemcached-dev -y
    pip3 install --timeout=3600 pylibmc django-pylibmc
    sudo systemctl enable --now memcached
    
  2. Configure Caching in seahub_settings.py

    CACHES = {
        'default': {
            'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
            'LOCATION': '127.0.0.1:11211',
        },
    }
    
  3. Configure Nginx

    sudo apt install nginx -y
    rm /etc/nginx/sites-enabled/default
    rm /etc/nginx/sites-available/default
    touch /etc/nginx/sites-available/seafile.conf
    

    Add the following content to the config file:

    log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $upstream_response_time';
    
    server {
        listen 80;
        server_name seafile.example.com;
    
        proxy_set_header X-Forwarded-For $remote_addr;
    
        location / {
             proxy_pass         http://127.0.0.1:8000;
             proxy_set_header   Host $http_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;
    
             client_max_body_size 0;
    
             access_log      /var/log/nginx/seahub.access.log seafileformat;
             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;
    
            access_log      /var/log/nginx/seafhttp.access.log seafileformat;
            error_log       /var/log/nginx/seafhttp.error.log;
        }
        location /media {
            root /opt/seafile/seafile-server-latest/seahub;
        }
    }
    

    Enable the site:

    ln -s /etc/nginx/sites-available/seafile.conf /etc/nginx/sites-enabled/seafile.conf
    

    For large file uploads (>4GB), ensure:

    location /seafhttp {
        ... ...
        proxy_request_buffering off;
    }
    
Tags: seafile

Related Articles

Designing Alertmanager Templates for Prometheus Notifications

How to craft Alertmanager templates to format alert messages, improving clarity and presentation. Alertmanager uses Go’s text/template engine with additional helper functions. Alerting rules referenc...

Deploying a Maven Web Application to Tomcat 9 Using the Tomcat Manager

Tomcat 9 does not provide a dedicated Maven plugin. The Tomcat Manager interface, however, is backward-compatible, so the Tomcat 7 Maven Plugin can be used to deploy to Tomcat 9. This guide shows two...

Skipping Errors in MySQL Asynchronous Replication

When a replica halts because the SQL thread encounters an error, you can resume replication by skipping the problematic event(s). Two common approaches are available. Methods to Skip Errors 1) Skip a...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.