私有雲盤Seafile


私有雲盤Seafile

環境:CentOS 7

Seafile版本: Seafile 7.0.5社區版

官網手冊:https://cloud.seafile.com/published/seafile-manual-cn/deploy/using_mysql.md

其他版本下載:https://download.seafile.com/d/6e5297246c/?p=/pro&mode=list

Seafile 包含以下系統組件:

  • Seahub:網站界面,供用戶管理自己在服務器上的數據和賬戶信息。Seafile服務器通過"gunicorn"(一個輕量級的Python HTTP服務器)來提供網站支持。Seahub作為gunicorn的一個應用程序來運行。
  • Seafile server (seaf-server): 數據服務進程, 處理原始文件的上傳/下載/同步。
  • Ccnet server (ccnet-server): 內部 RPC 服務進程,連接多個組件。
  • Controller: 監控 ccnet 和 seafile 進程,必要時會重啟進程。

SQLite版安裝

此版本不需要裝數據庫,但是需要裝Nginx。

創建結構

mkdir seafile   #新建一個公司名文件夾,用來作為seafile的存儲目錄
mv seafile-server_* seafile
cd seafile

#將 seafile-server_* 移動到 seafile 目錄下后
tar -xzf seafile-server_*   #解壓壓縮包
mkdir installed  #解壓后將安裝包移動到installed文件夾備份
mv seafile-server_* installed

項目結構如下

seafile   #公司名稱,雲盤根目錄
├── installed    #存儲安裝包備份的文件夾
│   └── seafile-server-*.tar.gz
└── seafile-server-*
├── reset-admin.sh
├── runtime
├── seafile
├── seafile.sh
├── seahub
├── seahub.sh
├── setup-seafile.sh
└── upgrade

安裝環境

  • python 2.7
  • python-setuptools
  • python-imaging
  • python-ldap
  • python-urllib3
  • sqlite3
# on CentOS 7
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
pip3 install pillow moviepy  #使用pip3或者pip安裝pillow

# CentOS 7 & Seafile 7.0.5
yum install python python-setuptools MySQL-python python-urllib3 python-ldap -y

安裝seafile

cd seafile-server-*
./setup-seafile.sh

安裝完成后目錄如下

seafile
├── conf                # configuration files
│   ├── ccnet.conf
│   └── seafile.conf
│   └── seahub_settings.py
│   └── seafdav.conf
├── ccnet
│   ├── mykey.peer
│   ├── PeerMgr
│   └── seafile.ini
├── installed
│   └── seafile-server_*x86-64.tar.gz
├── seafile-data
├── seafile-server-*  # active version
│   ├── reset-admin.sh
│   ├── runtime
│   ├── seafile
│   ├── seafile.sh
│   ├── seahub
│   ├── seahub.sh
│   ├── setup-seafile.sh
│   └── upgrade
├── seafile-server-latest  # symbolic link to seafile-server-*
├── seahub-data
│   └── avatars
├── seahub.db

安裝成功預覽圖

啟動服務

./seafile.sh start # 啟動 Seafile 服務
./seahub.sh start # 啟動 Seahub 網站 (默認運行在8000端口上)

Nginx代理

然后安裝並配置nginx,代理seafile的兩個端口(如果使用Mysql版本可以自動安裝Nginx,不需要此步驟)。

#進入到/etc/nginx/conf.d,這個配置在/etc/nginx/nginx.conf ->http ->include
cd /etc/nginx/conf.d
#添加新的文件
vi seafile.conf

添加如下配置

server {
    listen 89;
    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 /opt/seafile/seafile-server-latest/seahub;
    }
}

異常

查看日志

tail -f /var/log/nginx/seahub.error.log

端口綁定失敗

nginx啟動提示high performance web server,查看日志端口,顯示端口綁定失敗 bind() to 0.0.0.0:8380 failed (13: Permission denied)

#添加http允許訪問的端口
semanage port -a -t http_port_t  -p tcp 89
#查看http允許訪問的端口
semanage port -l | grep http_port_t

nginx代理8000端口失敗

查看日志,顯示connect() to 127.0.0.1:8000 failed (13: Permission denied) while connecting to upstream

需要把SELinux永久關閉.

Mysql版安裝

mysql版需要提前安裝好Mysql數據庫並創建一個seafile用戶。安裝完畢后會自動安裝Nginx。sqlite版不需要提前安裝數據庫,但是安裝完畢后也不會安裝nginx。

創建結構

mkdir /opt/seafile   #新建seafile的文件夾,注意所處的掛載剩余空間
mv seafile-server_* /opt/seafile   #將下載的tar移動到/opt/seafile下面
cd /opt/seafile

#將 seafile-server_* 移動到 seafile 目錄下后
tar -xzf seafile-server_*
#解壓后將不用的tar安裝包放在/opt/seafile/installed下面.
mkdir installed
mv seafile-server_* installed

安裝環境

# CentOS 7 & Seafile 7.0.5
yum install python python-setuptools MySQL-python python-urllib3 python-ldap -y

安裝seafile

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

新建一個或者使用之前的數據庫,輸入服務器的IP或者域名,給數據庫創建一個seafile用戶

啟動

./seafile.sh start # 啟動 Seafile 服務
./seahub.sh start  # 啟動 Seahub 網站 (默認運行在127.0.0.1:8000端口上)

第一次啟動 seahub 時,seahub.sh腳本會提示你創建一個seafile管理員帳號。

部署完成后,web通過Nginx或者Apache的80端口訪問。

7.0.x 版本之后,8000端口默認監聽在127.0.0.1地址上,這意味着無法直接通過8000端口訪問Seafile服務。建議配置nginx反向代理

修改Seahub端口

關閉 Seafile 服務器

#關閉 Seafile 服務器
./seahub.sh stop # 停止 Seafile 進程
./seafile.sh stop # 停止 Seahub

修改conf/gunicorn.conf

# default localhost:8000
bind = "0.0.0.0:8001"

重啟Seafile服務器

./seafile.sh start # 啟動 Seafile 服務
./seahub.sh start # 啟動 Seahub 網站

通過進程殺死

# 使用pgrep命令檢查 seafile/seahub 進程是否還在運行中
pgrep -f seafile-controller # 查看 Seafile 進程
pgrep -f "seahub" # 查看 Seahub 進程

#使用pkill命令殺掉相關進程
pkill -f seafile-controller # 結束 Seafile 進程
pkill -f "seahub" # 結束 Seafile 進程

報錯

密碼不符合要求

Error: Failed to create mysql user seafile@localhost: Your password does not satisfy the current policy requirements。這個錯是Mysql創建用戶時密碼不符合規范,可以解除規范,也可以使用符合規范的密碼。

-- 可以在工具中用如下語句先創建好這個用戶
set global validate_password_policy=0;
set global validate_password_length=1;
create USER 'seafile'@'localhost' IDENTIFIED BY 'seafile';

刪除后Seafile遺留

卸載Seafile客戶端后,文件資源管理器中會殘留之前安裝的圖標。
image

  1. Win+R 執行 regedit 啟動注冊表編輯器
  2. 地址欄輸 計算機\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace
  3. 點開 NameSpace ,刪除需要刪掉的文件夾
  4. 重啟


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM