Seafile

Using PostgreSQL

Note: Postgres support is still in Beta status and may have some minor bugs. Please use MySQL in production environment.

Deploy Seafile with PostgreSQL

Preparation

  1. [[Download and setup seafile server]], then start seafile and seahub and make sure everything is OK.

  2. Setup PostgreSQL.

    1. sudo apt-get install postgresql
  3. Create seafile postgres user and required databases. (Obviously you should use a more secure password than seafile)

    1. sudo -u postgres psql -U postgres -d postgres -c "CREATE USER seafile WITH PASSWORD 'seafile' CREATEDB;"
    2. createdb ccnet_db -U seafile -W -h localhost
    3. createdb seafile_db -U seafile -W -h localhost
    4. createdb seahub_db -U seafile -W -h localhost
  4. Create 3 databases named ccnet_db, seafile_db, seahub_db. e.g., create database ccnet_db encoding 'utf8';

Steps

  1. Shutdown services by ./seahub.sh stop and ./seafile.sh stop. Then, append the following PostgreSQL configurations to 3 config files (you may need to change to fit your configuration).

    Append following lines to ccnet.conf:

    1. [Database]
    2. ENGINE=pgsql
    3. HOST=localhost
    4. USER=seafile
    5. PASSWD=seafile
    6. DB=ccnet_db

    Replace the database section in seafile.conf with following lines:

    1. [database]
    2. type=pgsql
    3. host=localhost
    4. user=seafile
    5. password=seafile
    6. db_name=seafile_db

    Append following lines to seahub_settings.py:

    1. DATABASES = {
    2. 'default': {
    3. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
    4. 'NAME' : 'seahub_db',
    5. 'USER' : 'seafile',
    6. 'PASSWORD' : 'seafile',
    7. 'HOST' : 'localhost',
    8. }
    9. }
  2. Start seafile by ./seafile.sh start. There will be several tables created in ccnet_db and seafile_db if your configuration is correct.

  3. Install python-psycopg2 (package name on ubuntu):

    1. [sudo] apt-get build-dep python-psycopg2
    2. [sudo] pip install psycopg2
  4. Start seahub as follows (assume current path is /data/haiwen/seafile-server-1.7.0:

    1. export CCNET_CONF_DIR=/data/haiwen/ccnet
    2. export SEAFILE_CENTRAL_CONF_DIR=/data/haiwen/conf
    3. export SEAFILE_CONF_DIR=/data/haiwen/seafile-data
    4. INSTALLPATH=/data/haiwen/seafile-server-1.7.0
    5. export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.6/site-packages:${INSTALLPATH}/seafile/lib64/python2.6/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
    6. cd seahub
    7. python manage.py syncdb

    There will be several tables created in seahub_db. Then start seahub by ./seahub.sh start.

Create Seahub Admin

Assume current path is /data/haiwen/seafile-server-1.7.0, and you have exported all the variables above,

  1. cd seahub
  2. python manage.py createsuperuser

This command tool will guide you to create a seahub admin.