How to install Seafile with MySQL and SSL

  • Hi all, I've broken this into four parts so it doesn't get to confusing :thumbup: .... Here we Go!


    Tip: Do the following using SSH so you can copy and paste line by line (google putty for more info).
    Tip: Depending on which browser you use copying code from forums can be troublesome. The code can be corrupted and cause errors.
    Make sure you use the little copy buttons to the right of the page or try a good web browser like Chrome or Firefox :)


    Video: I finally found time to make a video tutorial here, It's my first video so I hope you like it :) ...


    ## Part One ##

    As always:
    apt-get update
    apt-get upgrade


    1. Create a user to install Seafile.
    useradd -m -d /opt/seafile -c "Seafile Service Account" -s /bin/bash -r -g users seafile


    2. Create the Shared Folders
    - Create a Shared Folder for MySQL Databases.
    - Create a Share Folder for Seafile. (You will need the full directory path for this folder later. You can find it using SFTP/FTP.
    (eg. /media/7b1e06d4-f77a-47e4-a024-822c0d29a9fe/Seafile-Data)


    3. Install the MySQL plugin (if not already installed)
    - Go to MySQL Settings
    - Set the Data directory to the database folder you created in the previous step.
    - Enable the MySQL plugin
    - Save & Apply



    4. For new MySQL Plugin installations you will need to change the MySQL root password. The default password is blank.
    mysql -u root -p
    password: << BLANK
    UPDATE mysql.user SET Password = PASSWORD('NEW.PASSWORD.HERE') << INSERT YOUR NEW PASSWORD HERE
    WHERE User = 'root';
    FLUSH PRIVILEGES;
    exit


    5. Install the python packages: (copy & paste both lines together, use the copy button to the right >>)

    Code
    apt-get install python2.7 libpython2.7 python-setuptools python-imaging \
       python-ldap python-mysqldb python-memcache python-urllib3




    ## Part Two: Install Seafile ##

    su -s /bin/bash seafile
    cd


    1. Download Seafile: (choose your 64bit or 32bit version)
    64bit: wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_5.1.3_x86-64.tar.gz
    32bit: wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_5.1.3_i386.tar.gz

    2. Create the directories for the installation:
    tar -xzf seafile-server_*
    mkdir installed
    mv seafile-server_* installed


    3. Go to the Seafile server directory and run the setup:
    cd seafile-server-*
    ./setup-seafile-mysql.sh


    4. Install Seafile & connect the MySQL Databases, Follow the instructions:
    - Give your server a name
    - When asked for an IP enter OMV's local IP.
    - When asked for the Seafile Data directory use the full directory path to the Seafile-data folder you created in Part 1 Step 2 and append /data to the end of the path e.g.
    /media/fa8088ed-5de5-4c2c-b4dc-d84abe3dd7ec/Seafile-Data/data (/media/your-number-is different/Seafile-Data/data)
    - hit enter for the default port number
    ### Choose option 1 to initialize database. ###
    - Hit enter for the default MySQL server & port
    - Enter the MySQL root user password you changed in part 1.
    - Enter a name for the MySQL seafile user - seafile
    - Enter a password for the MySQL seafile user - new.password
    - Hit enter on all of the default database names
    - Hit enter to finish the Seafile installation


    5. Start the Seafile Server:
    su -s /bin/bash seafile  (only do this if you are staring a new terminal session)
    cd /opt/seafile/seafile-server-*  (only do this if you are starting a new terminal session)
    ./seafile.sh start
    ./seahub.sh start
    - enter your admin account info (this will be your admin login details).
    - log into your Seafile server using your admin email and password at:http://local-ip:8000 (NOT HTTPS)

    Tip: Though you can open port 8000 in your firewall and access Seafile remotely it will not be secure without SSL. It's recommended you continue with the rest of the steps and add SSL Security.


    6. Extra Settings: Add memcached to speed up Seafile server for 50+ users.
    nano /opt/seafile/conf/seahub_settings.py


    - Paste the following code into the bottom of the file then save and close. Ctrl+O to save, Ctrl+X to exit. (Use the copy button to the right >>)

    Code
    CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
            'LOCATION': '127.0.0.1:11211',
        }
    }



    ## Part Three: Start Seafile at System Boot ##

    1. Create a startup script file /etc/init.d/seafile-server (The script file is seafile-server.txt if you prefer manual installation)
    su (if not already root user)
    cd
    wget http://forums.openmediavault.org/index.php/Attachment/4495-seafile-server-txt/seafile-server.txt
    mv seafile-server.txt /etc/init.d/seafile-server
    chmod +x /etc/init.d/seafile-server
    update-rc.d seafile-server defaults


    2. Make sure your system reboots with Seafile running:
    reboot


    ## Part Four: SSL and the Nginx plugin ##

    1. Create an SSL Certificate to use with Seafile.


    2. Install the Nginx plugin (if not already installed)
    3. Add a server and copy the settings from attached images



    3. In the Extra options paste the following code. (Use the copy button to the right >>)



    4. Save & Apply
    5. Enable the Nginx plugin
    6.apt-get clean


    7. Change the fastcgi=false value to true in the startup script.
    replace "fastcgi=false" "fastcgi=true" -- /etc/init.d/seafile-server
    /etc/init.d/seafile-server restart (if you see "bad Gateway" after this then try it again or reboot)


    Tip: The following Warning can be fixed with the following commands:

    Code
    /opt/seafile/seafile-server-latest/seahub.sh: line 207: warning: setlocale: LC_A                
    LL: cannot change locale (en_US.UTF-8): No such file or directory


    locale-gen "en_US.UTF-8"
    dpkg-reconfigure locales
    add/select en_US.UTF-8 UTF-8 from the list and click ok.
    Select your correct locale as the default and click ok.
    Check the warning has gone with /etc/init.d/seafile-server restart


    8. You can now log into Seafile using https://yourdomain.com:[chosen ssl port]. You need to open your chosen HTTPS port in your firewall for remote access.


    9. Log into Seafile and go to system admin settings in the top right-hand corner. Change the settings below to your external IP address or domain name. File uploads won't work on your local IP after changing theses settings, therefore you need to access Seafile using your external IP address or Domain name and SSL port.


    SERVICE_URL https://yourdomain.com:[chosen ssl port]
    FILE_SERVER_ROOT https://yourdomain.com:[chosen ssl port]/seafhttp



    That's it!


    UPDATING SEAFILE...

    I've never updated Seafile before so I'm not going to tell you how to in this tutorial...Yet!. I Will post something when I've learned how to update mine :)


    For now here is a good place start: http://manual.seafile.com/deploy/upgrade.html :)

  • Hi Sieben ,


    I went through the installation wizard again using option 1 to automatically create the database. I wanted to see if I could choose another user instead of root but it’s not possible. For some reason the MySQL server plugin isn't allowing root user connections. I have set the root password in the plugin settings but this makes no difference if you can’t connect. Creating the databases manually seems to be the only option that works so far, unless someone knows of another way I haven’t found yet.


    When the wizard asks you for the IP address you can’t put 127.0.0.1 otherwise it causes problems with file transfer. The wizard asks for a domain name or an IP address and and gives an example of the local IP so I’d say that’s a safe bet. :)


    My Only problem now is I can’t upload via the browser using HTTPS (I can with HTTP), it says Error: Access is denied. The desktop appliction works fine though. There seems to be a permissions problem somewhere but I’m just not sure where. I’ve Googled around for a solution but no luck yet. Have you or anyone else here had this problem with Seafile and Nginx HTTPS?


    Thanks to anyone can help,


    Baldman :)

  • I went through the installation wizard again using option 1 to automatically create the database. I wanted to see if I could choose another user instead of root but it’s not possible. For some reason the MySQL server plugin isn't allowing root user connections. I have set the root password in the plugin settings but this makes no difference if you can’t connect. Creating the databases manually seems to be the only option that works so far, unless someone knows of another way I haven’t found yet.


    At first, yes it's not 127.0.0.1 it should be "localhost"


    You can, it defintely works :)
    -->use option 1. Here is how-to:


    Create a unprivileged user with home-directory, e.g. /srv/seafile
    useradd -m -d /srv/seafile -s /bin/false seafile


    Even before installing seafile you change to the "seafile" user, to install and configure everything with his permissions
    su - seafile -s /bin/bash


    Install python and seafile as you said, but with the seafile user.


    Then you setup seafile for mysql:
    ./setup-seafile-mysql.sh



    ------------------------------------


    For your HTTPS problem, please send your seafile config files (ccnet.conf, seahub_settings.py, seafile.conf)


    I actually I got most of my advice from this website (it's german though, I don't know if you can speak german :D )
    https://www.debinux.de/2014/05/seafile-nginx-mysql/

    OMV 5.x | Banana PI (M1) | Seafile Server
    OMV 4.x | ShuttlePC SH55J2

    2 Mal editiert, zuletzt von sieben ()

  • Thanks tekkb, I've written it twice now...lol. But its worth it :)


    Hi Sieben,


    I've discovered that localhost and probably 127.0.0.1 will work as long as the seahub_settings.py file contains FILE_SERVER_ROOT = https://domain-etc. This needs to be added as its not there by default. Thanks to your website reference and google translate I found what I needed..lol This also resolved my problem with uploading files over HTTPS 8)


    I've now updated the Guide and I think I can safely say it works :thumbup: .


    My next step will be to update the guide for automatic database creation and shorten the guide, which I will do soon.


    Thanks again for your help.

  • Hi there,
    I followed the steps through the installation routine. Thank you for your work! First of all, is it allowed to asked for help directly in this how-to? If not please tell me so that i can delete it and reopen it somewhere elese...


    I have three questions, i will start with the first one:


    1) I noticed that my BananaPi with openmediavault 2.2.3 can´t start seafile 5.1.2 automatically. I always have to start it manually.



    Where is my failure?


    Here is the input auf seafile-server:




    Can you help me please?


    Greetings Elluminatus

    ______________________________________________________________________________________________________________
    OMV 1: Asrock Q1900M - 8 GB Ram - 320 GB Boot Disk - 3 * 3 TB WD RED Data
    OMV 4.1.6 - Kernel 4.16.0.0 | Plugins: n.n.

    5 Mal editiert, zuletzt von Elluminatus ()

  • The warning states you do not have LC_ALL set. (It'a a warning only)


    What is the result of

    Code
    service seafile-server restart

    ?
    Did you follow the steps to enable seafile at boot (Part 3)?
    What is the result of

    Code
    ls -l /etc/init.d/s*

    If you got help in the forum and want to give something back to the project click here (omv) or here (scroll down) (plugins) and write up your solution for others.

  • Yeah thank you very much everything is working like a charm now. I repeated step 3 and now it works fine. Thank you very much.


    Elluminatus

    ______________________________________________________________________________________________________________
    OMV 1: Asrock Q1900M - 8 GB Ram - 320 GB Boot Disk - 3 * 3 TB WD RED Data
    OMV 4.1.6 - Kernel 4.16.0.0 | Plugins: n.n.

  • I'm try to understand this setup.
    If you look at OwnCloud setup, the server directory is enabled with its folder directory.
    On this Seafile, where would Seafile save its config/data to?

    OMV v5.0
    Asus Z97-A/3.1; i3-4370
    32GB RAM Corsair Vengeance Pro

  • So, /media/UUID/Seafile-Data is for user's data & config?
    I'm looking at OwnCloud, Seafile, and Pydio installation, their setup is similar.
    I might try Pydio installation this week.

    OMV v5.0
    Asus Z97-A/3.1; i3-4370
    32GB RAM Corsair Vengeance Pro

    Einmal editiert, zuletzt von tinh_x7 ()

  • @tinh_x7The config is stored in the database and in /root/seafile/conf, at least, if you followed the description in the tutorial.


    Seafile comes with it's own web server listening on port 8000. One can choose to access it directly or via nginx as proxy.
    If you use nginx as proxy, you should use fsctcgi, not http between the two.

    If you got help in the forum and want to give something back to the project click here (omv) or here (scroll down) (plugins) and write up your solution for others.

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!