Seafile+阿里云ECS云盘同步盘服务器搭建


前言

开源网盘、云盘搭建,自动同步(亲测成功案例分享)

环境准备

系统                       centOS 7.4

yum                   阿里云、本地镜像

seafile下载地址    seafile官网

seafile版本            Linux服务器端6.2.3 X86 64bit

seafile存放路径    /opt/

安装用户                root

操作步骤

1.设置selinux

setenforce 0

sed -i 's/^SELINUX=.*/SELINUX=permissive/'/etc/selinux/config

2.设置防火墙

yum install firewalld fail2ban -y

for i in ssh http https ; do firewall-cmd --zone=public--add-service=${i} --permanent ; done

firewall-cmd --reload

3.安装依赖包

yum install epel-release -y

yum upgrade -y

yum install python-setuptools python-imaging MySQL-pythonpython-memcached memcached python-urllib3 pwgen curl openssl python-ldapjava-1.7.0-openjdk poppler-utils libreoffice python-requests libreoffice-headless libreoffice-pyunowqy-microhei-fonts wqy-zenhei-fonts wqy-unibit-fonts -y

4.将memcached设置为开机自启

systemctl enable memcached

5.安装nginx

yum install nginx -y

systemctl enable nginx

rm -rf /etc/nginx/conf.d/*

vi /etc/nginx/conf.d/seafile.conf


server {

    listen 80;

    server_nameseafile.example.com; #此处填写阿里云给的公网IP地址

   proxy_set_header X-Forwarded-For $remote_addr;

    location / {

        proxy_pass         http://127.0.0.1:8000;

        proxy_set_header   Host $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-Host $server_name;

        proxy_read_timeout  1200s;


         # used forview/edit office file via Office Online Server

        client_max_body_size 0;


        access_log      /var/log/nginx/seahub.access.log;

         error_log       /var/log/nginx/seahub.error.log;

    }


    location /seafhttp{

        rewrite ^/seafhttp(.*)$$1 break;

        proxy_passhttp://127.0.0.1:8082;

       client_max_body_size 0;

       proxy_connect_timeout  36000s;

        proxy_read_timeout  36000s;

    }


    location /media{

        root /opt/seafile/seafile-server-latest/seahub;

    }


        location /seafdav{

       fastcgi_pass    127.0.0.1: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   REMOTE_ADDR         $remote_addr;


       client_max_body_size 0;


               access_log      /var/log/nginx/seafdav.access.log;

       error_log       /var/log/nginx/seafdav.error.log;

    }

}

6.创建nginx配置文件

mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup

vi /etc/nginx/nginx.conf  


user nginx nginx;

worker_processes 4;


events {

 worker_connections 8096;

  multi_accept on;

  use epoll;

}


pid /var/run/nginx.pid;

worker_rlimit_nofile 40000;


http {

  server_tokens off;

 server_names_hash_bucket_size 128;

 client_max_body_size 50M;

  include /etc/nginx/mime.types;

  default_typeapplication/octet-stream;

  log_format main '$remote_addr- $remote_user [$time_local] "$request" '

  '$status$body_bytes_sent "$http_referer" '

  '"$http_user_agent""$http_x_forwarded_for"';

  access_log /var/log/nginx/access.logmain;

  error_log /var/log/nginx/error.logwarn;

  sendfile on;

  tcp_nopush on;

  tcp_nodelay on;

 client_body_timeout 12;

 client_header_timeout 12;

  keepalive_timeout15;

  send_timeout 10;

  # Fully disabledgzip compression to mitigate Django BREACH attack

  gzip off;

  #gzip_vary on;

  #gzip_proxiedexpired no-cache no-store private auth any;

  #gzip_comp_level 9;

  #gzip_min_length 10240;

  #gzip_buffers 16 8k;

 #gzip_http_version 1.1;

  #gzip_types text/plaintext/css text/xml text/javascript application/javascript application/x-javascriptapplication/xml font/woff2;

  #gzip_disable "MSIE[1-6].";

  include /etc/nginx/conf.d/*.conf;

}


7.重启nginx

systemctl restart nginx

8.安装MySQL

yum install mariadb-server -y

systemctl start mariadb

systemctl enable mariadb

mysqladmin -u root password  pwgen


vi /root/.my.cnf

[client]

user=root

password=pwgen

chmod 600 /root/.my.cnf

9.创建seafile的systemctl服务脚本

vi /etc/systemd/system/seafile.service

[Unit]

Description=Seafile Server

After=network.target mariadb.service


[Service]

Type=oneshot

ExecStart=/opt/seafile/seafile-server-latest/seafile.shstart

ExecStop=/opt/seafile/seafile-server-latest/seafile.shstop

RemainAfterExit=yes

User=root

Group=root


[Install]

WantedBy=multi-user.target

命令行

systemctl enable seafile

vi /etc/systemd/system/seahub.service

[Unit]

Description=Seafile Seahub

After=network.target seafile.service


[Service]

ExecStart=/opt/seafile/seafile-server-latest/seahub.shstart 8000

ExecStop=/opt/seafile/seafile-server-latest/seahub.shstop

User=root

Group=root

Type=oneshot

RemainAfterExit=yes


[Install]

WantedBy=multi-user.target

命令行

systemctl enable seahub

10.创建seafile重启脚本

vi /usr/local/sbin/seafile-server-restart

#!/bin/bash

for ACTION in stop start ; do

    for SERVICE inseafile seahub ; do

      systemctl${ACTION} ${SERVICE}

    done

done

命令行

chmod 700 /usr/local/sbin/seafile-server-restart

11.创建seafile目录

mkdir -p /opt/seafile/installed

cd /opt/

wgethttp://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.2.3_x86-64.tar.gz

cd /opt/seafile/

cp /opt/seafile-server_6.2.3_x86-64.tar.gz .

tar -zxvf seafile-server_6.2.3_x86-64.tar.gz

mv seafile-server_6.2.3_x86-64.tar.gz installed

##./setup-seafile-mysql.sh

##下面按照seafile官网要求进行设置,记住你的公网IP

12.配置seafile 数据库

vi /opt/seafile.my.cnf

[client]

user=root

password=pwgen

命令行

chmod 600 /opt/seafile.my.cnf

cd /opt/seafile/seafile-server-6.2.3/

mkdir -p /opt/seafile/conf

./setup-seafile-mysql.sh auto -u seafile -w pwgen -r pwgen

13.配置seafile WebDAV服务

vi /opt/seafile/conf/seafdav.conf

[WEBDAV]

enabled = true

port = 8080

fastcgi = true

share_name = /seafdav/

14.配置seahub_settings.py

vi /opt/seafile/conf/seahub_settings.py ##在末尾插入

ACHES = {

    'default': {

        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',

    'LOCATION': '127.0.0.1:11211',

    }

}


# EMAIL_USE_TLS                       = False

# EMAIL_HOST                          = 'localhost'

# EMAIL_HOST_USER                     = ''

# EMAIL_HOST_PASSWORD                 = ''

# EMAIL_PORT                          = '25'

# DEFAULT_FROM_EMAIL                  = EMAIL_HOST_USER

# SERVER_EMAIL                        = EMAIL_HOST_USER


TIME_ZONE                           = Asia/Shanghai

SITE_BASE                           = 'http://127.0.0.1'

SITE_NAME                           = 'Seafile Server'

SITE_TITLE                          = 'Seafile Server'

SITE_ROOT                           = '/'

ENABLE_SIGNUP                       = False

ACTIVATE_AFTER_REGISTRATION         = False

SEND_EMAIL_ON_ADDING_SYSTEM_MEMBER  = True

SEND_EMAIL_ON_RESETTING_USER_PASSWD = True

CLOUD_MODE                          = False

FILE_PREVIEW_MAX_SIZE               = 30 * 1024 * 1024

SESSION_COOKIE_AGE                  = 60 * 60 * 24 * 7 * 2

SESSION_SAVE_EVERY_REQUEST          = False

SESSION_EXPIRE_AT_BROWSER_CLOSE     = False


FILE_SERVER_ROOT                    = 'http://127.0.0.1/seafhttp'

15.备份check_init_admin.py

cp /opt/seafile/seafile-server-6.2.3/check_init_admin.py/opt/seafile/seafile-server-6.2.3/check_init_admin.py.backup

16.设置管理证书

vi /opt/seafile/seafile-server-6.2.3/check_init_admin.py ##修改第366、367行

修改前

email = ask_admin_email()

passwd = ask_admin_password()

修改后

email = "admin@seafile.local"

passwd = "pwgen"


17.启动和关闭服务,以便生成管理员用户

[root@seafile seafile-server-6.2.3]# pwd

/opt/seafile/seafile-server-6.2.3

[root@seafile seafile-server-6.2.3]# ./seafile.shstart

[12/01/17 13:38:40] ../common/session.c(132): usingconfig file /opt/seafile/conf/ccnet.conf

Starting seafile server, please wait ...

Seafile server started


Done.

[root@seafile seafile-server-6.2.3]# ./seahub.shstart

LC_ALL is not set in ENV, set to en_US.UTF-8

Starting seahub at port 8000 ...




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

Successfully created seafile admin

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





Seahub is started


Done.


[root@seafile seafile-server-6.2.3]# ./seahub.shstop

Stopping seahub ...

Done.

[root@seafile seafile-server-6.2.3]# ./seafile.shstop

Stopping seafile server ...

Done.

18.恢复原来的check_init_admin.py

mv check_init_admin.py.backup check_init_admin.py

重启seafile服务

/usr/local/sbin/seafile-server-restart

19.设置你的SEAFILE 服务器

网页以管理员登录你的服务器,设置2个主要参数

SERVICE_URL 为http://你的公网IP(或者127.0.0.1):8000

FILE_SERVER)ROOT 为http://你的公网IP/seahttp

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,948评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,371评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,490评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,521评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,627评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,842评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,997评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,741评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,203评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,534评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,673评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,339评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,955评论 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,770评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,000评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,394评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,562评论 2 349