See Common Linux Commands for [start | stop | status] systemctl commands for seafile and seahub
## download
${shell}:~$ wget https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_6.0.9_x86-64.tar.gz
${shell}:~$ tar -xzf seafile-server_6.0.9_x86-64.tar.gz
${shell}:~$ mkdir /opt/seafile
${shell}:~$ mv seafile-server-6.0.9/ /opt/seafile/seafile-server/
${shell}:~$ tree
├── installed
│ └── seafile-server_1.4.0_x86-64.tar.gz
└── seafile-server-1.4.0
├── check_init_admin.py
├── reset-admin.sh
├── runtime
├── seaf-fsck.sh
├── seaf-fuse.sh
├── seaf-gc.sh
├── seafile
├── seafile.sh
├── seahub
├── seahub.sh
├── setup-seafile-mysql.py
├── setup-seafile-mysql.sh
├── setup-seafile.sh
├── upgrade
## to upgrade, untar the latest package into /opt/seafile
## install dependencies
${shell}:~$ apt-get update
${shell}:~$ apt-get install openjdk-8-jre poppler-utils libreoffice python libreoffice-script-provider-python libpython2.7 python-pip python-setuptools python-imaging python-mysqldb python-memcache ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy python-pip wget python-ldap python-urllib3 sqlite3
${shell}:~$ PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin
${shell}:~$ pip install --upgrade pip
${shell}:~$ pip install boto
## run seafile script
${shell}:~$ ./opt/seafile/seafile-server/setup-seafile.sh
# This is your config information:
# server name: ${server}
# server ip/domain: ${domain}
# seafile data dir: /opt/seafile/seafile-data
# fileserver port: 8082
# port of seafile fileserver: 8082
# port of seahub: 8000
See MYSQL to:
# run seafile mysql script
${shell}:~$ ./opt/seafile/seafile-server/setup-seafile-mysql.sh
# [ server name ] ${server}
# [ This server's ip or domain ] 127.0.0.1
# [ default "/opt/seafile/seafile-data" ]
# [ default "8082" ]
# [2] Use existing ccnet/seafile/seahub databases
# [ default "localhost" ]
# [ default "3306" ]
# [ mysql user for seafile ] ${mysql:user}
# [ password for ${mysql:user} ]
# verifying password of user ${mysql:user} ... done
# [ ccnet database ] ccnet_db
# verifying user "${mysql:user}" access to database ccnet_db ... done
# [ seafile database ] seafile_db
# verifying user "${mysql:user}" access to database seafile_db ... done
# [ seahub database ] seahub_db
# verifying user "${mysql:user}" access to database seahub_db ... done
# ---------------------------------
# This is your configuration
# ---------------------------------
# server name: ${server}
# server ip/domain: 127.0.0.1
# seafile data dir: /opt/seafile/seafile-data
# fileserver port: 8082
# database: use existing
# ccnet database: ccnet_db
# seafile database: seafile_db
# seahub database: seahub_db
# database user: ${mysql:user}
# ---------------------------------
# port of seafile fileserver: 8082
# port of seahub: 8000
${shell}:~$ vi /opt/seafile/conf/ccnet.conf
< /opt/seafile/conf/ccnet.conf >
[General]
USER_NAME = ${server}
ID = xxxxxxxxxxxxxxxxxxxxxx
NAME = ${server}
SERVICE_URL = https://${domain}
[Client]
PORT = 13419
[Database]
ENGINE = mysql
HOST = 127.0.0.1
PORT = 3306
USER = ${mysql:user}
PASSWD = ${mysql:password}
DB = ccnet_db
CONNECTION_CHARSET = utf8
${shell}:~$ vi /opt/seafile/conf/seafile.conf
< /opt/seafile/conf/seafile.conf >
[fileserver]
port = 8082
[database]
type = mysql
host = 127.0.0.1
port = 3306
user = ${mysql:user}
password = ${mysql:password}
db_name = seafile_db
connection_charset = utf8
${shell}:~$ vi /opt/seafile/conf/seahub_settings.py
< /opt/seafile/conf/seahub_settings.py >
# -*- coding: utf-8 -*-
SECRET_KEY = "xxxxxxxxxxxxxxxxxxx"
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'seahub_db',
'USER': '${mysql:user}',
'PASSWORD': '${mysql:password}',
'HOST': '127.0.0.1',
'PORT': '3306'
}
}
${shell}:~$ vi /opt/seafile/conf/seafdav.conf
< /opt/seafile/conf/seafdav.conf >
[WEBDAV]
# enabled = false
enabled = true
port = 8080
fastcgi = false
# host = 0.0.0.0
share_name = /
${shell}~$ vi /opt/seafile/conf/seahub_settings.py
< /opt/seafile/conf/seahub_settings.py >
EMAIL_USE_TLS = True
EMAIL_HOST = '${server}'
EMAIL_HOST_USER = '${email}'
EMAIL_HOST_PASSWORD = '${password}'
EMAIL_PORT = ${port}
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
See Common Linux Commands for [start | restart | stop | enable | status] systemctl commands
set up service for seafile:
servicename: seafile
description: "Seafile Server"
after: network.target mariadb.service
type: oneshot
execstart: /opt/seafile/seafile-server/seafile.sh start
execstop: /opt/seafile/seafile-server/seafile.sh stop
remain: yes
user: root
group: root
set up service for seahub:
servicename: seahub
description: "Seafile Hub"
after: network.target seafile.target
type: oneshot
execstart: /opt/seafile/seafile-server/seahub.sh start
execstop: /opt/seafile/seafile-server/seahub.sh stop
remain: yes
user: root
group: root
# Active Internet connections (only servers) # Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name # tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 177/mysqld # tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 9300/python2.7 # tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN 9301/seaf-server # tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 9386/python2.7 # udp 0 0 0.0.0.0:68 0.0.0.0:* 144/dhclient
root@nginx:~$ vi /etc/nginx/sites-available/seafile
< /etc/nginx/sites-available/seafile >
upstream seahub {
server 10.0.4.199:8082;
}
upstream seafile {
server 10.0.4.199:8000;
}
proxy_cache_path /var/cache/nginx/seafile levels=1:2 keys_zone=seafile_cache:10m max_size=3g inactive=120m use_temp_path=off;
server {
listen 80;
server_name sea.somedomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name sea.somedomain.com;
#proxy_set_header X-Forwarded-For $remote_addr;
ssl on;
ssl_certificate /etc/letsencrypt/live/sea.somedomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sea.somedomain.com/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
location /api/v3/users/websocket {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
client_max_body_size 50M;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
proxy_read_timeout 600s;
proxy_pass http://seafile;
}
location / {
access_log /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.error.log;
client_max_body_size 50M;
proxy_set_header Connection "";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
proxy_read_timeout 600s;
proxy_cache mattermost_cache;
proxy_cache_revalidate on;
proxy_cache_min_uses 2;
proxy_cache_use_stale timeout;
proxy_cache_lock on;
proxy_pass http://seafile;
}
# Reverse proxy for seafile
#location / {
#fastcgi_pass seafile;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param PATH_INFO $fastcgi_script_name;
#fastcgi_param SERVER_PROTOCOL $server_protocol;
#fastcgi_param QUERY_STRING $query_string;
#fastcgi_param REQUEST_METHOD $request_method;
#fastcgi_param CONTENT_TYPE $content_type;
#fastcgi_param CONTENT_LENGTH $content_length;
#fastcgi_param SERVER_ADDR $server_addr;
#fastcgi_param SERVER_PORT $server_port;
#fastcgi_param SERVER_NAME $server_name;
#fastcgi_param REMOTE_ADDR $remote_addr;
#access_log /var/log/nginx/seahub.access.log;
#error_log /var/log/nginx/seahub.error.log;
#fastcgi_read_timeout 36000;
#}
# Reverse Proxy for seahub
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
proxy_pass http://seahub;
client_max_body_size 0;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_send_timeout 36000s;
send_timeout 36000s;
}
}
# garbage collection when storage is getting full ./seaf-gc.sh
# fastcgi
${shell}:~$ vi /opt/seafile/conf/seafdav.conf
</opt/seafile/conf/seafdav.conf>
[WEBDAV]
fastcgi = true
host=0.0.0.0
${shell}:~$ vi /opt/seafile/seafile-server-latest/seahub.sh
< /opt/seafile/seafile-server-latest/seahub.sh >
function start_seahub_fastcgi() {
before_start;
export SEAFILE_FASTCGI_HOST=0.0.0.0
}
root@nginx:~$ vi /etc/nginx/sites-available/seafile
< /etc/nginx/sites-available/seafile >
upstream seahub {
server 10.0.4.199:8082;
}
upstream seafile {
server 10.0.4.199:8000;
}
proxy_cache_path /var/cache/nginx/seafile levels=1:2 keys_zone=seafile_cache:10m max_size=3g inactive=120m use_temp_path=off;
server {
listen 80;
server_name sea.somedomain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name sea.somedomain.com;
#proxy_set_header X-Forwarded-For $remote_addr;
ssl on;
ssl_certificate /etc/letsencrypt/live/sea.somedomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sea.somedomain.com/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
access_log /var/log/nginx/seahub.access.log;
error_log /var/log/nginx/seahub.error.log;
# Reverse proxy for seafile
location / {
fastcgi_pass SEAFILE_REMOTE_IP:8000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
fastcgi_read_timeout 36000;
proxy_set_header X-Forwarded-For $remote_addr;
}
# Reverse Proxy for seahub
location /seafhttp {
rewrite ^/seafhttp(.*)$ $1 break;
#proxy_pass http://seahub;
proxy_pass http://SEAFILE_REMOTE_IP:8082;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_send_timeout 36000s;
send_timeout 36000s;
}
location /webdav {
fastcgi_pass SEAFILE_REMOTE_IP:8080;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS on;
fastcgi_param HTTP_SCHEME https;
client_max_body_size 0;
proxy_connect_timeout 36000s;
proxy_read_timeout 36000s;
proxy_send_timeout 36000s;
send_timeout 36000s;
proxy_request_buffering off;
}
}
root@nginx:~$ ln -s /etc/nginx/sites-available/seafile /etc/nginx/sites-enabled/
root@nginx:~$ nginx -t
root@nginx:~$ systemctl restart nginx
# start-fastcgi uses localhost by default and is not configurable
root@nginx:~$ curl 10.0.4.199:8000
curl: (7) Failed to connect to 10.0.4.199 port 8000: Connection refused
${shell}:~$ tcpdump -ani eth0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
14:03:42.793455 IP 10.0.4.79.58826 > 10.0.4.199.8000: Flags [S], seq 2157979588, win 29200, options [mss 1460,sackOK,TS val 3237124001 ecr 0,nop,wscale 6], length 0
14:03:42.793568 IP 10.0.4.199.8000 > 10.0.4.79.58826: Flags [R.], seq 0, ack 2157979589, win 0, length 0
14:03:48.010556 ARP, Request who-has 10.0.4.79 tell 10.0.4.199, length 28
14:03:48.010797 ARP, Request who-has 10.0.4.199 tell 10.0.4.79, length 28
14:03:48.010841 ARP, Reply 10.0.4.199 is-at 00:16:3e:f9:c8:1e, length 28
14:03:48.010877 ARP, Reply 10.0.4.79 is-at 00:16:3e:94:8d:b6, length 28
${shell}:~$ vi /lib/systemd/system/seahub.service
< /lib/systemd/system/seahub.service >
...
[Service]
ExecStart=/opt/seafile/seafile-server/seahub.sh start-fastcgi
...
${shell}:~$ systemctl daemon-reload
${shell}:~$ systemctl stop seahub
${shell}:~$ systemctl start seahub