Seafile+阿里云ECS云盤同步盤服務(wù)器搭建


前言

開源網(wǎng)盤述暂、云盤搭建,自動同步(親測成功案例分享)

環(huán)境準(zhǔn)備

系統(tǒng)? ? ? ? ? ? ? ? ? ? ? ?centOS 7.4

yum? ? ? ? ? ? ? ? ? ?阿里云逃延、本地鏡像

seafile下載地址? ??seafile官網(wǎng)

seafile版本? ? ????????Linux服務(wù)器端6.2.3 X86 64bit

seafile存放路徑? ? /opt/

安裝用戶? ? ????????????root

操作步驟

1.設(shè)置selinux

setenforce 0

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

2.設(shè)置防火墻

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設(shè)置為開機自啟

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; #此處填寫阿里云給的公網(wǎng)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.創(chuàng)建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.創(chuàng)建seafile的systemctl服務(wù)腳本

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.創(chuàng)建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.創(chuàng)建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官網(wǎng)要求進(jìn)行設(shè)置,記住你的公網(wǎng)IP

12.配置seafile 數(shù)據(jù)庫

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服務(wù)

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.設(shè)置管理證書

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.啟動和關(guān)閉服務(wù),以便生成管理員用戶

[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.恢復(fù)原來的check_init_admin.py

mv check_init_admin.py.backup check_init_admin.py

重啟seafile服務(wù)

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

19.設(shè)置你的SEAFILE 服務(wù)器

網(wǎng)頁以管理員登錄你的服務(wù)器,設(shè)置2個主要參數(shù)

SERVICE_URL 為http://你的公網(wǎng)IP(或者127.0.0.1):8000

FILE_SERVER)ROOT 為http://你的公網(wǎng)IP/seahttp

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末袁辈,一起剝皮案震驚了整個濱河市区赵,隨后出現(xiàn)的幾起案子惭缰,更是在濱河造成了極大的恐慌浪南,老刑警劉巖笼才,帶你破解...
    沈念sama閱讀 217,084評論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異络凿,居然都是意外死亡骡送,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,623評論 3 392
  • 文/潘曉璐 我一進(jìn)店門絮记,熙熙樓的掌柜王于貴愁眉苦臉地迎上來摔踱,“玉大人,你說我怎么就攤上這事怨愤∨煞螅” “怎么了?”我有些...
    開封第一講書人閱讀 163,450評論 0 353
  • 文/不壞的土叔 我叫張陵撰洗,是天一觀的道長篮愉。 經(jīng)常有香客問我,道長差导,這世上最難降的妖魔是什么试躏? 我笑而不...
    開封第一講書人閱讀 58,322評論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮设褐,結(jié)果婚禮上颠蕴,老公的妹妹穿的比我還像新娘。我一直安慰自己助析,他們只是感情好犀被,可當(dāng)我...
    茶點故事閱讀 67,370評論 6 390
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著外冀,像睡著了一般寡键。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上锥惋,一...
    開封第一講書人閱讀 51,274評論 1 300
  • 那天昌腰,我揣著相機與錄音,去河邊找鬼膀跌。 笑死遭商,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的捅伤。 我是一名探鬼主播劫流,決...
    沈念sama閱讀 40,126評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了祠汇?” 一聲冷哼從身側(cè)響起仍秤,我...
    開封第一講書人閱讀 38,980評論 0 275
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎可很,沒想到半個月后诗力,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,414評論 1 313
  • 正文 獨居荒郊野嶺守林人離奇死亡我抠,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,599評論 3 334
  • 正文 我和宋清朗相戀三年苇本,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片菜拓。...
    茶點故事閱讀 39,773評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡瓣窄,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出纳鼎,到底是詐尸還是另有隱情俺夕,我是刑警寧澤,帶...
    沈念sama閱讀 35,470評論 5 344
  • 正文 年R本政府宣布贱鄙,位于F島的核電站劝贸,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏贰逾。R本人自食惡果不足惜悬荣,卻給世界環(huán)境...
    茶點故事閱讀 41,080評論 3 327
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望疙剑。 院中可真熱鬧氯迂,春花似錦、人聲如沸言缤。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,713評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽管挟。三九已至轿曙,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間僻孝,已是汗流浹背导帝。 一陣腳步聲響...
    開封第一講書人閱讀 32,852評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留穿铆,地道東北人您单。 一個月前我還...
    沈念sama閱讀 47,865評論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像荞雏,于是被迫代替她去往敵國和親虐秦。 傳聞我的和親對象是個殘疾皇子平酿,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,689評論 2 354