How to install Seafile with MySQL and SSL

    • OMV 2.x

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • 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 >>)

      Source Code

      1. apt-get install python2.7 libpython2.7 python-setuptools python-imaging \
      2. 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 >>)

      Source Code

      1. CACHES = {
      2. 'default': {
      3. 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
      4. 'LOCATION': '127.0.0.1:11211',
      5. }
      6. }



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

      1. Create a startup script file /etc/init.d/seafile-server (The script file is attached 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 >>)

      Source Code

      1. location / {
      2. fastcgi_pass 127.0.0.1:8000;
      3. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      4. fastcgi_param PATH_INFO $fastcgi_script_name;
      5. fastcgi_param SERVER_PROTOCOL $server_protocol;
      6. fastcgi_param QUERY_STRING $query_string;
      7. fastcgi_param REQUEST_METHOD $request_method;
      8. fastcgi_param CONTENT_TYPE $content_type;
      9. fastcgi_param CONTENT_LENGTH $content_length;
      10. fastcgi_param SERVER_ADDR $server_addr;
      11. fastcgi_param SERVER_PORT $server_port;
      12. fastcgi_param SERVER_NAME $server_name;
      13. fastcgi_param REMOTE_ADDR $remote_addr;
      14. fastcgi_param HTTPS on;
      15. fastcgi_param HTTP_SCHEME https;
      16. access_log /var/log/nginx/seahub.access.log;
      17. error_log /var/log/nginx/seahub.error.log;
      18. fastcgi_read_timeout 36000;
      19. }
      20. location /seafhttp {
      21. rewrite ^/seafhttp(.*)$ $1 break;
      22. proxy_pass http://127.0.0.1:8082;
      23. client_max_body_size 0;
      24. proxy_connect_timeout 36000s;
      25. proxy_read_timeout 36000s;
      26. proxy_send_timeout 36000s;
      27. send_timeout 36000s;
      28. }
      29. location /media {
      30. root /opt/seafile/seafile-server-latest/seahub;
      31. }
      Display All



      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:

      Source Code

      1. /opt/seafile/seafile-server-latest/seahub.sh: line 207: warning: setlocale: LC_A
      2. 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: manual.seafile.com/deploy/upgrade.html :)

      The post was edited 150 times, last by baldman ().

    • How to install Seafile with MySQL and SSL (Updated)

      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 :)
    • baldman wrote:

      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
      Display Spoiler

      What is the name of the server? It will be displayed on the client.
      3 – 15 letters or digits
      [ server name ] servername

      What is the ip or domain of the server?
      For example: mycompany.com, 192.168.1.101
      [ This server’s ip or domain ] cloud.domain.tld

      ——————————————————-Please choose a way to initialize seafile databases:——————————————————-

      [1] Create new ccnet/seafile/seahub databases
      [2] Use existing ccnet/seafile/seahub databases

      [ 1 or 2 ] 1

      What is the host of mysql server?
      [ default „localhost“ ] <depending on your config>

      What is the port of mysql server?
      [ default „3306“ ] <depending on your config>

      What is the password of the mysql root user?
      [ root password ] <depending on your config>

      verifying password of user root … done

      Enter the name for mysql user of seafile. It would be created if not exists.
      [ default „root“ ] seafileusr (for example)

      Enter the password for mysql user „seafileusr“:
      [ password for seafileusr ] Password for new user „seafileusr“

      ———————————This is your configuration———————————
      […]



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

      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 )
      debinux.de/2014/05/seafile-nginx-mysql/
      OMV 3.x | Banana PI (M1) | | | Seafile Server
      OMV 4.x | ShuttlePC SH55J2

      The post was edited 2 times, last by 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 = 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 :thumbsup: .

      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.

      root@Hermes:~# cd /home/seafile/seafile-server-*
      root@Hermes:~/seafile/seafile-server-5.1.2# ./seafile.sh start

      [05/16/16 02:12:35] ../common/session.c(132): using config file /root/seafile/conf/ccnet.conf
      Starting seafile server, please wait ...
      Seafile server started

      Done.
      root@Hermes:~/seafile/seafile-server-5.1.2# ./seahub.sh start

      LC_ALL is not set in ENV, set to en_US.UTF-8
      ./seahub.sh: Zeile 207: Warnung: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): Datei oder Verzeichnis nicht gefunden
      Starting seahub at port 8000 ...

      Seahub is started

      Done.


      Where is my failure?

      Here is the input auf seafile-server:

      #!/bin/sh

      ### BEGIN INIT INFO
      # Provides: seafile-server
      # Required-Start: $local_fs $remote_fs $network
      # Required-Stop: $local_fs
      # Default-Start: 2 3 4 5
      # Default-Stop: 0 1 6
      # Short-Description: Starts Seafile Server
      # Description: starts Seafile Server
      ### END INIT INFO

      # Change the value of "user" to your linux user name
      user=seafile

      # Change the value of "script_path" to your path of seafile installation
      # usually the home directory of $user
      seafile_dir=/home/seafile
      script_path=${seafile_dir}/seafile-server-latest
      seafile_init_log=${seafile_dir}/logs/seafile.init.log
      seahub_init_log=${seafile_dir}/logs/seahub.init.log

      # Change the value of fastcgi to true if fastcgi is to be used
      fastcgi=true
      # Set the port of fastcgi, default is 8000. Change it if you need different.
      fastcgi_port=8000

      #
      # Write a polite log message with date and time
      #
      echo -e "\n \n About to perform $1 for seafile at `date -Iseconds` \n " >> ${seafile_init_log}
      echo -e "\n \n About to perform $1 for seahub at `date -Iseconds` \n " >> ${seahub_init_log}

      case "$1" in
      start)
      sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
      if [ $fastcgi = true ];
      then
      sudo -u ${user} ${script_path}/seahub.sh ${1}-fastcgi ${fastcgi_port} >> ${seahub_init_log}
      else
      sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
      fi
      ;;
      restart)
      sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
      if [ $fastcgi = true ];
      then
      sudo -u ${user} ${script_path}/seahub.sh ${1}-fastcgi ${fastcgi_port} >> ${seahub_init_log}
      else
      sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
      fi
      ;;
      stop)
      sudo -u ${user} ${script_path}/seahub.sh ${1} >> ${seahub_init_log}
      sudo -u ${user} ${script_path}/seafile.sh ${1} >> ${seafile_init_log}
      ;;
      *)
      echo "Usage: /etc/init.d/seafile-server {start|stop|restart}"
      exit 1
      ;;
      esac



      Can you help me please?

      Greetings Elluminatus
      ______________________________________________________________________________________________________________
      OMV 1: BananaPi M1 - 8 GB SD Card - 1 TB WD RED Data
      BanaNas 2.2 - OMV 2.2.5 - Kernel 3.4.108 | Plugins: Flash - Sensors - Antivirus - MySql | Software: Baikal 0.3.5 - Seafile 5.1.2

      OMV 2: Asus P5Q-Pro - Intel Q9300 - 6 GB Ram - 16 GB Disk on Module - 3*2 TB WD RED Raid 5 - Digital Device 4 DVB-C
      Debian Wheezy - OMV 2.2.5 - Kernel still trying | Plugins: still testing | Software: Tvheadend 3.4 (testing)

      The post was edited 5 times, last by Elluminatus ().

    • 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: BananaPi M1 - 8 GB SD Card - 1 TB WD RED Data
      BanaNas 2.2 - OMV 2.2.5 - Kernel 3.4.108 | Plugins: Flash - Sensors - Antivirus - MySql | Software: Baikal 0.3.5 - Seafile 5.1.2

      OMV 2: Asus P5Q-Pro - Intel Q9300 - 6 GB Ram - 16 GB Disk on Module - 3*2 TB WD RED Raid 5 - Digital Device 4 DVB-C
      Debian Wheezy - OMV 2.2.5 - Kernel still trying | Plugins: still testing | Software: Tvheadend 3.4 (testing)