Install Seafile on Raspian, Raspberry Pi

Prerequisites: Install LAMP (optional: Installing No-IP client on Raspian)

More info at: Deploying Seafile under Linux

Login as root:

sudo su

Create directory for Seafile: (example*)

mkdir /media/usbhdd/seafile

Move to created directory:

cd /media/usbhdd/seafile

Download latest Seafile server for Raspberry Pi:


Extract archive:

tar xvf seafile-server_4.0.6_pi.tar.gz

Create directory:

mkdir installed

Move your archive to newly created directory:

mv seafile-server_4.0.6_pi.tar.gz installed

Check prerequisites:

dpkg-query -l python2.7 python-setuptools python-imaging python-mysqldb

and install missing packages:

apt-get install python-setuptools python-mysqldb

Move to directory:

cd seafile-server-4.0.6/

Run the script:

What is the name of the server? It will be displayed on the client.
3 - 15 letters or digits
[ server name ] <hostname/servername>

What is the ip or domain of the server?
For example:,
[ This server's ip or domain ] <your-dynamic-dns-address> OR <hostname>.local OR <local-IP-address>

Which port do you want to use for the ccnet server?
[ default "10001" ]

Where do you want to put your seafile data?
Please use a volume with enough free space
[ default "/media/usbhdd/seafile/seafile-data" ]

Which port do you want to use for the seafile server?
[ default "12001" ]

Which port do you want to use for the seafile fileserver?
[ default "8082" ]

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 *recomended by seafile

What is the host of mysql server?
[ default "localhost" ]

What is the port of mysql server?
[ default "3306" ]

What is the password of the mysql root user?
[ root password ] <your-mysql-root-password>

verifying password of user root ... done

Enter the name for mysql user of seafile. It would be created if not exists.
[ default "root" ] seafile OR <any-other-username-for-seafile-mysql-user>

Enter the password for mysql user "seafile":
[ password for seafile ] <password>

Enter the database name for ccnet-server:
[ default "ccnet-db" ]

Enter the database name for seafile-server:
[ default "seafile-db" ]

Enter the database name for seahub:
[ default "seahub-db" ]

This is your configuration

server name: <hostname/servername-you-used>
 server ip/domain: <ip-adress/domain-you-used>
 ccnet port: 10001
seafile data dir: /media/usbhdd/seafile/seafile-data
 seafile port: 12001
 fileserver port: 8082

database: create new
 ccnet database: ccnet-db
 seafile database: seafile-db
 seahub database: seahub-db
 database user: seafile

Press ENTER to continue, or Ctrl-C to abort

While in /media/usbhdd/seafile/seafile-server-4.0.6:

Start seafile:

./ start # Start seafile service

Start seahub

./ start # Start seahub website, port defaults to 8000
Starting seahub at port 8000 ...

It's the first time you start the seafile server. Now let's create the admin account

What is the email for the admin account?
[ admin email ] <your-mail>

What is the password for the admin account?
[ admin password ] <password>

Enter the password again:
[ admin password again ] <repeat-password>

Successfully created seafile admin

Type in your browser, and check if setup is successful:




Generate and apply your ssl keys (logged in as user):

sudo openssl genrsa -out seafile-key.pem 2048
sudo openssl req -new -x509 -key seafile-key.pem -out seafile-cacert.pem -days 1095
sudo mkdir /etc/apache2/ssl
sudo mv *.pem /etc/apache2/ssl
sudo mkdir /var/www/seafile
sudo a2enmod ssl

Edit file:

sudo nano /media/usbhdd/seafile/ccnet/ccnet.conf

Add this line:

SERVICE_URL = https://<your-dynamic-dns-address>:8001


SERVICE_URL = https://<hostname>.local:8001


SERVICE_URL = https://<local-IP-address>:8001

Edit file:

sudo nano /media/usbhdd/seafile/

Add this line:

FILE_SERVER_ROOT = 'https://<your-dynamic-dns-address>:8001/seafhttp'


FILE_SERVER_ROOT = 'https://<hostname>.local:8001/seafhttp'


FILE_SERVER_ROOT = 'https://<local-IP-address>:8001/seafhttp'

Enable modes on Apache:

sudo a2enmod rewrite
sudo a2enmod fastcgi
sudo a2enmod proxy_http

Edit file:

sudo nano /etc/apache2/ports.conf

Add these lines:

<IfModule ssl_module>
Listen 8001

<IfModule mod_gnutls.c>
Listen 8001

Edit file:

sudo nano /etc/apache2/sites-available/seafile-ssl.conf:
FastCGIExternalServer /var/www/seafile/seahub.fcgi -host -idle-timeout 600

<Directory /data/opt/seafile/seafile-server-latest/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted

<VirtualHost *:8001>
ServerAdmin <your-mail>

Servername <hostname/servername-you-used>
ServerAlias <hostname/servername-you-used>

DocumentRoot /var/www/seafile
Alias /media /media/usbhdd/seafile/seafile-server-latest/seahub/media

SSLEngine On
SSLCertificateFile /etc/apache2/ssl/<cert-name-you-used>.pem (*seafile-cacert.pem previously as an example)
SSLCertificateKeyFile /etc/apache2/ssl/<key-name-you-used>.pem (seafile-key.pem previously as an example)

RewriteEngine On

# seafile httpserver
ProxyPass /seafhttp
ProxyPassReverse /seafhttp
RewriteRule ^/seafhttp - [QSA,L]

# seahub
RewriteRule ^/(media.*)$ /$1 [QSA,L,PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /seahub.fcgi/$1 [QSA,L,E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Enable site:

sudo a2ensite seafile-ssl.conf

Restart Apache:

/etc/init.d/apache2 restart

Log in as root:

sudo su

Move to folder:

cd /media/usbhdd/seafile/seafile-server-latest


./ stop
./ stop


./ start
./ start-fastcgi

Forward ports on your router if you are using dynamic dns:

  • 8001
  • 10001
  • 12001

to local IP address.

Test your setup in browser:


Install client on your computer or smartphone and test. (Download client here.)


Create a script /etc/init.d/seafile-server (*logged in as user)

sudo nano /etc/init.d/seafile-server

The content of this script is: (You need to modify the value of user and script_path accordingly)


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

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

# Change the value of "script_path" to your path of seafile installation

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

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

Note: If you want to start seahub in fastcgi, just change the fastcgi variable to true.

Note: If you deployed Seafile with MySQL, append “mysql” to the Required-Start line: # Required-Start: $local_fs $remote_fs $network mysql

Add Directory for Logfiles:

sudo mkdir /media/usbhdd/seafile/logs

Make the seafile-sever script executable:

sudo chmod +x /etc/init.d/seafile-server

Add seafile-server to rc.d

sudo update-rc.d seafile-server defaults



One thought on “Install Seafile on Raspian, Raspberry Pi”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s