私有雲盤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 (
): 内部 RPC 服務程序,連接配接多個元件。ccnet-server
- 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
安裝成功預覽圖
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnLxYDO4QzN0kDMy0CMzIDOwkDMwEDMxMDMxIDMy0yN3QDOwITMvw1MwEjMwIzLcdzN0gDMyEzLcd2bsJ2Lc12bj5ycn9Gbi52YuAjMwIzZtl2Lc9CX6MHc0RHaiojIsJye.png)
啟動服務
./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
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用戶端後,檔案資料總管中會殘留之前安裝的圖示。
- Win+R 執行 regedit 啟動系統資料庫編輯器
- 位址欄輸 計算機\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace
- 點開 NameSpace ,删除需要删掉的檔案夾
- 重新開機
如果這篇文章對你有用,麻煩關注一下本人微信公衆号~