Host your own SeaFile cloud (with ssl support)

  • Hallo,


    if you want to host your own seafile cloud server on your i-mscp machine, follow this steps:
    (At your own risk - so make a backup before trying this!)


    Tested and configured on server:

    • Ubuntu 14.04 LTS
    • I-MSCP 1.2.10
    • seafile server 5.0.3


    Required:

    • Shell account (not "root"!)
    • Enabled SSL for domains (if you want to use SSL - recommend)


    Currently I am no longer hosting an own cloud storage space. That is why I am no longer updating this howto. In general this tutorial should work for newer Ubuntu, I-MSCP and Seafile releases too (maybe not the start scripts due to changes in Ubuntu 16.04). Feel free to write comments with updates/suggestions/bugfixes/... and I will include them into this howto.


    HowTo Versions:




    This HowTo is only for setting up the seafile server inside a I-MSCP environment. It's not the correct page to ask general seafile questions!
    For seafile questions use the seafile forum, seafile help section, the wiki or use the server manual!


    1. Create a shell user
    First of all, you have to create a shell user for the seafile services/deamons. Do not run seafile as root!


    2. Download and install seafile server
    Attention: use the architecture of your server (32/64bit). Otherwise you get an error running ./setup-seafile.sh
    Attention: all downloads can be found at http://seafile.com/en/download/ (client and server files - android and ios -> see last lines)
    Please visit Deplaying Seafile with SQLite and follow the installation instruction. (there is also a mysql howto: Deploying Seafile with MySQL - I do not use this, so no support)
    Start the seafile server once and stop it after successfully starting the server (generates config files).


    3. Generate the cloud domain/subdomain
    You can choose if you want to use your domain or subdomain. In this HowTo we use seafile.domain.tld as installation path. So next step is to create the subdomain "seafile".


    4. Configure Apache2
    First we have to install python-flup, libapache2-mod-fastcgi and enable mod rewrite, proxy_http and fastcgi.
    (Detailed information: http://manual.seafile.com/deploy/deploy_with_apache.html)


    Code
    1. sudo aptitude install libapache2-mod-fastcgi python-flupsudo a2enmod rewritesudo a2enmod fastcgisudo a2enmod proxy_http



    Open the apache2 config file "/etc/apache2/apache2.conf" and add this line at the bottom (where 127.0.0.1:8000 is the default seafile port)

    Code
    1. FastCGIExternalServer /var/www/virtual/domain.tld/seafile/htdocs/seahub.fcgi -host 127.0.0.1:8000


    (use your own domain url)


    Go to "/etc/apache2/imscp/" and open the configuration file for your domain/subdomain (e.g. "seafile.domain.tld.conf") and add following lines:

    Code
    1. # change "/home/seafile/" to the path of your seafile server files, do not delete the part after "/home/seafile/"!# IF YOU USE APACHE >= 2.4 UNCOMMENT THE NEXT 4 LINES!!! IF NOT THE IMAGES ARE NOT SHOWN AND THE PAGE SEEMS TO BE BROKEN!!!#<Directory /home/seafile>#Require all granted#Options FollowSymLinks#</Directory>Alias /media /home/seafile/seafile-apache/seahub/mediaRewriteEngine On## seafile httpserver#ProxyPass /seafhttp http://127.0.0.1:8082ProxyPassReverse /seafhttp http://127.0.0.1:8082RewriteRule ^/seafhttp - [QSA,L]## seahub#RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]RewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ /seahub.fcgi$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]


    (use your own path to seafile directory! Detail information: http://manual.seafile.com/deploy/deploy_http_sync.html)


    Now restart the apache2 server

    Code
    1. service apache2 restart


    5. Enable SSL support - seafile server
    (detailed information: http://manual.seafile.com/deploy/https_with_apache.html)


    First go to your seafile user directory (shell) and edit the ccnet/ccnet.conf file:

    Code
    1. SERVICE_URL = https://seafile.domain.tld


    (use your own domain url)


    Now edit the file seahub_settings.py:

    Code
    1. ...HTTP_SERVER_ROOT = 'https://seafile.domain.tld/seafhttp'...


    (use your own domain url, do not delete "/seafhttp"!)


    6. Start the seafile services
    Go to your seafile directory and start both services. Attention: seahub has to be started now with another parameter:

    Code
    1. ./seafile.sh start./seahub.sh start-fastcgi


    7. Test seafile
    Go to your url, e.g. http://seafile.domain.tld, and check if there is the seafile login. If you have enabled ssl and added the certificates using I-MSCP you should also be able to open https://seafile.domain.tld - recommend.


    8. Automatically start/stop seafile on boot/shutdown/restart
    The seafile project often releases new server and client versions. Because I want to keep the last versions of the server I use symbolic folders for my start/stop scripts.


    First go to the folder where your seafile folder is located (in this HowTo the folder is called like the archive):
    (If you are going to update your seafile server, remove this symbolic link and change it to the new location)


    The next steps may be not the best practise, so if you have a better idea - please tell me :P
    (One better idea is to use https://github.com/fhd/init-script-template )


    Save three new files inside your seafile directory:


    startSeafile.sh

    Code
    1. cd /home/seafilecd seafile-apacheecho "Starting seafile"./seafile.sh startecho "(Waiting 3 seconds to start seahub)"sleep 3echo "Starting seahub"./seahub.sh start-fastcgiecho "Finished"


    (change the first line to the location where you created the symbolic link "seafile-apache")


    stopSeafile.sh

    Code
    1. cd /home/seafilecd seafile-apache./seafile.sh stop./seahub.sh stop


    (change the first line to the location where you created the symbolic link "seafile-apache")


    restartSeafile.sh

    Code
    1. cd /home/seafile./stopSeafile.shsleep 3./startSeafile.sh


    (change the first line to the location where you created the symbolic link "seafile-apache")


    Make bot files executable by owner:

    Code
    1. chmod startSeafile.sh u+xchmod stopSeafile.sh u+xchmod restartSeafile.sh u+x


    Create a init.d script /etc/init.d/seafile:

    Code
    1. #! /bin/sh### BEGIN INIT INFO# Provides: seafile start stop restart# Required-Start:# Required-Stop:# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: seafile cloud service# Description: Starts/stops seafile cloud service### END INIT INFO# Author: Stefan Ruepp# Aktionencase "$1" in start) sudo -u seafile /home/seafile/startSeafile.sh ;; stop) sudo -u seafile /home/seafile/stopSeafile.sh ;; restart) sudo -u seafile /home/seafile/restartSeafile.sh ;;esacexit 0


    (change the paths to the location where you created the symbolic link "seafile-apache", and the username after "-u" to the seafile service user you created in step 1)


    Make it executable:

    Code
    1. chmod u+x /etc/init.d/seafile


    Insert it as default to the runlevels (automatically start on boot and stop on shutdown/restart):

    Code
    1. update-rc.d seafile defaults


    At last try all start/stop/restart scripts. If everything is working your seafile server should be shut-down and started automatically.


    9. Upgrade your seafile server
    Attention: only use this upgrade HowTo if you followed step 8!


    • Upgrading the seafile server is very easy. Stop both seafile services and make a backup :s.
    • Download the new server file (using wget) and extract the archive.
    • Remove the symbolic link and add a new one to the new server directory ("ln -s seafile-server..... seafile-apache" see step 8)
    • Go inside the folder "upgrade"
    • Check if there is a upgrade script from your old version to your new version. "yes": execute this script
    • execute ./minor-upgrade.sh (importent, it updates your symbolic links, avatars, ...)
    • Start the seafile server - done

    Detail information: http://manual.seafile.com/deploy/upgrade.html


    10. Finally connect the client
    Install the client from http://seafile.com/en/download/ and use your new http(s)://seafile.domain.tld address.


    11. Logrotation (optional)
    First you need to modify the startup script: http://manual.seafile.com/depl…ile_at_system_bootup.html
    After that you can enable log rotation: http://manual.seafile.com/deploy/using_logrotate.html


    12. Firewall settings
    First of all: All ports has to be accessable from inside. So if you disable any of the following ports be sure you let it open for localhost/127.0.0.1 - if you are not opening to be used internal apache is no longer able to access you seafile server and everything is offline!


    If you are using seafile with ssl support, everything is redirected over port 443 (https port) - so you do not need to open any special ports. If you skipped the ssl part you need to open the port 8000 and 8082.
    Attention: you need to close both ports (8000 and 8082) for security reasons if you are using ssl support!
    Detail information: http://manual.seafile.com/deploy/using_firewall.html


    If you are using the WebDAV extension you have to disable this port too.


    13. WebDAV extension (optional)
    First you need to choose the port which should be used for internal using webdav. I used port 8888 (because the default port from the wiki, 8080, was already used by another service at my server - if you want to use another port you have to change 8888 with your port).


    Open the /etc/apache2/apache2.conf file and add another line at the bottom:

    Code
    1. FastCGIExternalServer /var/www/virtual/domain.tld/seafile/htdocs/seafdav.fcgi -host 127.0.0.1:8888

    (as told above, replace the path with the path to your webspace location)



    Inside your seafile path open or create the file conf/seafdav.conf and replace everything with this lines:

    Code
    1. [WEBDAV]enabled = trueport = 8888fastcgi = trueshare_name = /seafdav


    Go to "/etc/apache2/imscp/" and open the configuration file for your domain/subdomain (e.g. "seafile.domain.tld.conf") and add following lines between the seahub and seafile server:

    Code
    1. ...
    2. #
    3. # seafdav
    4. #
    5. RewriteCond %{HTTP:Authorization} (.+)
    6. RewriteRule ^(/seafdav.*)$ /seafdav.fcgi$1 [QSA,L,e=HTTP_AUTHORIZATION:%1]
    7. RewriteRule ^(/seafdav.*)$ /seafdav.fcgi$1 [QSA,L]
    8. ...



    Now restart your seafile server.


    After the restart you can access your libraries and files using the link http://seafile.domain.tld/seafdav/ (Windows Explorer compatible)

    • Attention 1: Without the ending "/" it is not working correct ... no idea what, just write the ending "/"
    • Attention 2: Password encrypted libraries are not working!

    14. Backup and restore
    Detail information: http://manual.seafile.com/maintain/backup_recovery.html[/size]


    15. Mobile phone
    Android: https://play.google.com/store/…m.seafile.seadroid2&hl=de
    iPhone: https://itunes.apple.com/de/app/seafile-pro/id639202512?mt=8


    16. Migrate from SQLite to MySQL
    http://manual.seafile.com/depl…from_sqlite_to_mysql.html

    If there are any errors using this HowTo, please tell me!


    Feel free to use the "thumbs up" Button :D

    Edited 13 times, last by UncleSam ().

  • hi


    i keep getting this error


    ./setup-seafile.sh: regel 409: /cloud/seafile-server/seafile/bin/ccnet-init: kan een binair bestand niet uitvoeren


    it can not execute a binairy


    i try'ed to change the rights and owner but with no succes

    wt nx mr lr snl


  • even if you can find a how to here, this problem belongs not into i-MSCP forum.
    look here http://bit.ly/1i6qt7o


    i followed your link a thousend times m8
    otherwise i would not ask it here


    and yes this is not in anyway related to i-mscp but it could be that someone who folowed these instructions came up on the same problem and has a solution for this

    wt nx mr lr snl

    Edited once, last by check ().

  • seafile does not belong to imscp. but the thread should not be deleted, since the thread is a contributed howto. but errors that depend on seafile you can ask at seafile support forum. this error does not belong to imscp or the howto it self, because it happens while running the install script of seafile and not on some step that is "special" for this howto :)


  • seafile does not belong to imscp. but the thread should not be deleted, since the thread is a contributed howto. but errors that depend on seafile you can ask at seafile support forum. this error does not belong to imscp or the howto it self, because it happens while running the install script of seafile and not on some step that is "special" for this howto :)


    thnx m8
    for those who run into this error
    change the type you use be shure you need 64bit or 32bit
    because this error occures when you take the wrong structure
    i have a hp dl380 g6 and strange but i need the 32 bit so i think i installed the wrong debian version




    ps:
    i could not find any forum yet only google groups

    wt nx mr lr snl

  • I can recommend the following.
    Create a user seafile and install it in that home directory.

    Code
    1. /home/seafile


    Set the rights to 'chown -R seafile: seafile * "
    Then the installation should work.


  • added information to use the correct architecture files - thx for the information

    Edited once, last by UncleSam ().

  • when done follow this link Funny
    or go to your playstore on your phone and search for seafile


    have fun and thnx for this usefull info i like it

    wt nx mr lr snl