【server瞎折騰】CentOS部署同步盤Seafile

折騰一段時間後的總結 -於2018.1

開源網盤,尤爲是想要同步盤功能的話,seafile和nextcloud算是比較好的兩個選擇。我的感受seafile功能更強,有相似gitignore的能力,別的同步盤還沒發現有這個能力的。可是對通常用戶來說,seafile的易用性是不如nextcloud的。nextcloud的交互體驗確實作得很好,有商業軟件的水準。seafile嘛...感受是沒有交互設計師參與的。python

可是!搭建網盤服務必定不能忽視帶寬的問題!國內的帶寬是天價!咱們我的隨便用用的騰訊雲、阿里雲,帶寬都是1Mbps的,實際上就是128KB/s,這個速度,對須要同步大文件的網盤來說,是徹底不夠用的!不論是加帶寬仍是換成按流量購買,我的用戶都不太扛得住。mysql

若是用國外服務器,流量是着實便宜,個人搬瓦工vps每月1T流量簡直不要錢同樣。可是國外便宜的vps硬盤每每比較小,另外服務器在國外的話,網絡畢竟沒有國內穩定,也是要考慮的!linux

折騰到底,跟朋友合買了Office 365,投奔了onedrive的懷抱。nginx


Seafile是什麼

Seafile 是一款開源的企業雲盤,注重可靠性和性能。支持 Windows, Mac, Linux, iOS,
Android 平臺。支持文件同步或者直接掛載到本地訪問。

就是個開源的同步網盤。隨着各類網盤的倒閉和百度雲的墮落,靠譜的網盤是愈來愈少了。國外的要麼被牆了要麼速度慢,這時候在本身的服務器上搭建私人同步盤就是個不錯的選擇了。git

目前比較流行的開源網盤也沒幾個,適合自建服務器上有SeafileownCloud,比較接近傳統網盤。另外有個用於多客戶端同步的Syncthing web

Seafile這個網盤,功能仍是很強大的,自動同步,還附帶版本控制。就是界面醜了點,可是瑕不掩瑜。sql

本文介紹在CentOS 7上Seafile的部署流程。
完整資料建議查看官方手冊vim

安裝

安裝

這裏我選擇的是最新的6.3.2版本,建議去下載頁面查看linux服務端的最新版本,並替換下面的連接。bash

wget http://seafile-downloads.oss-cn-shanghai.aliyuncs.com/seafile-server_6.3.2_x86-64.tar.gz
mkdir seafile
mv seafile-server_6.3.2_x86-64.tar.gz  seafile/
cd seafile/
tar xzf seafile-server_6.3.2_x86-64.tar.gz


yum -y install epel-release
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
yum -y install python-imaging MySQL-python python-memcached python-ldap python-urllib3 ffmpeg ffmpeg-devel
pip install --upgrade setuptools #爲了保證moviepy安裝成功
pip install pillow moviepy

cd seafile-server-*
./setup-seafile.sh  #運行安裝腳本並回答預設問題

安裝完成後,默認文件服務(seafile)運行在8082端口,web管理頁面(seahub)運行在8000端口。服務器

修改seahub的端口

個人服務器上還有別的工具在運行,所以修改了seahub的端口號,並經過nginx的反向代理訪問。
更改conf/ccnet.conf文件中SERVICE_URL和conf/gunicorn.conf中的bind便可修改端口號。

nginx反向代理

編輯/etc/nginx/nginx.conf,在中間找個地方插入下面的代碼。一些關鍵詞要改爲本身的。

server {
    listen 80;
    server_name seafile.example.com;

    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 for view/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_pass http://127.0.0.1:8082;
        client_max_body_size 0;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_connect_timeout  36000s;
        proxy_read_timeout  36000s;
        proxy_send_timeout  36000s;

        send_timeout  36000s;
    }
    location /media {
        root /home/user/haiwen/seafile-server-latest/seahub;
    }
}

而後重啓nginx

service nginx restart

這個時候在你配置的域名下就能夠訪問seafile了,須要登陸後在管理後臺修改兩個字段,形如:

SERVICE_URL: http://www.myseafile.com
FILE_SERVER_ROOT: http://www.myseafile.com/seafhttp

開機啓動

配置開機啓動。CentOS 7支持systemctl,用這個就行了。

vim /etc/systemd/system/seafile.service

文件內容以下,注意把${seafile_dir}替換成本身的安裝目錄。User和Group替換成本身的,估計我的的話大部分都是root吧。

[Unit]
Description=Seafile
# add mysql.service or postgresql.service depending on your database to the line below
After=network.target


[Service]
Type=oneshot
ExecStart=${seafile_dir}/seafile-server-latest/seafile.sh start
# 若是seahub使用了nginx反代,請修改成 ExecStart=${seafile_dir}/seafile-server-latest/seahub.sh start-fastcgi
ExecStart=${seafile_dir}/seafile-server-latest/seahub.sh start
ExecStop=${seafile_dir}/seafile-server-latest/seafile.sh stop
ExecStop=${seafile_dir}/seafile-server-latest/seahub.sh stop
RemainAfterExit=yes
User=root
Group=root

[Install]
WantedBy=multi-user.target

刷新配置並開機啓動

systemctl daemon-reload
systemctl enable seafile

結語

其實主要仍是給本身個備忘。提及來,seafile的官方安裝指引,很規範,可是對我的來講有些操做都比較累贅了。好比安裝包專門放一個地方好維護,自啓動腳本seafile和seahub分開。我的搭建的話隨意一點也是能夠的。

相關文章
相關標籤/搜索