Linux 上部署 Seafile 9.0.x 专业版(Seafile Server端)——踩一路坑,溅一身水
1. Seafile 簡(jiǎn)介
Seafile 是一款開源的企業(yè)云盤,注重可靠性和性能。支持 Windows, Mac, Linux, iOS, Android 平臺(tái)。支持文件同步或者直接掛載到本地訪問。Seafile 主要注重的是文件安全工作,寫一個(gè)基本的文件同步工具是件簡(jiǎn)單的事情,但是要保證在各種極端的場(chǎng)合下都能正確的工作、不丟數(shù)據(jù)是件不容易的事情。Seafile 專注文件同步的可靠性。同步算法經(jīng)過 3 年的不斷改進(jìn)和數(shù)十萬用戶的使用,已經(jīng)非常可靠。Seafile 的文件歷史和資料庫(kù)鏡像機(jī)制保證了文件可隨時(shí)方便的恢復(fù)到任意歷史狀態(tài)。
其擁有如下特點(diǎn):
-
可靠的文件同步
文件組織成資料庫(kù)。每個(gè)資料庫(kù)可選擇性的同步到任意設(shè)備。可靠高效的文件同步將提高您的工作效率。 -
掛載盤客戶端
直接通過本地 S 盤來訪問云端文件,不占用本地存儲(chǔ)。為電腦提供服務(wù)器的海量存儲(chǔ)空間。同操作系統(tǒng)無縫集成,還可以離線修改文件。 -
團(tuán)隊(duì)協(xié)作
可以共享文件到群組。權(quán)限管理、版本控制、事件通知讓協(xié)作更為流暢。 -
高性能
Seafile 服務(wù)器內(nèi)核由 C 語(yǔ)言編寫。運(yùn)行起來小巧快速。 -
Wiki 與知識(shí)管理
融合 Wiki 與網(wǎng)盤的功能,使用 Markdown 格式以所見即所得方式編輯 Wiki 文檔,提供搜索、標(biāo)簽、評(píng)審等知識(shí)管理功能,支持對(duì)外發(fā)布 Wiki 內(nèi)容。 -
適用于企業(yè)環(huán)境
可與 AD/LDAP 集成。可同步 AD 群組和用戶信息。
來看看官網(wǎng)給的一張示例圖片,和我們正常使用的網(wǎng)盤基本沒什么區(qū)別。
官方的介紹文檔:Seafile 簡(jiǎn)介
2. Seafile pro Server 下載鏈接
官方下載連接:
Linux 服務(wù)器端開源版: Seafile 9.0.5 64bit
Linux 服務(wù)器端專業(yè)版: Seafile 專業(yè)版
其它的支持平臺(tái):Seafile
筆者的當(dāng)前環(huán)境:
OS: Ubuntu server 22.04
選擇的 Seafile Server 專業(yè)版本: Seafile pro 9.0.5 64bit
3. 一些安裝前的準(zhǔn)備工作
3.1. 安裝依賴
適合 Seafile 9.0.x 版本
imaginemiracle:~$ sudo apt-get updateimaginemiracle:~$ sudo apt-get install -y python3 python3-setuptools python3-pip python3-ldap libmysqlclient-dev imaginemiracle:~$ sudo apt-get install -y memcached libmemcached-dev安裝過程中可能會(huì)彈出一個(gè)選項(xiàng)框,問你 “哪個(gè)服務(wù)需要被重新安裝呢?”,你回答 “不!”,就可以了,我們不需要重新安裝之前裝過的服務(wù)。
注意,由于依賴項(xiàng)較多,因此下面這行命令非常的長(zhǎng),務(wù)必復(fù)制完整!!!
接下來根據(jù)每個(gè)人的網(wǎng)絡(luò)情況,如果網(wǎng)絡(luò)像筆者一樣不好的朋友就要等稍微久一點(diǎn)的時(shí)間了(╮(╯▽╰)╭😔)。(老實(shí)說我等了很久,大概有個(gè)兩千年吧~)
[注]: Seafile Pro 9.0.x 版本不支持在 Centos 系統(tǒng) tar 包部署,支持 Docker 方式部署 。
3.1.1. 可能出現(xiàn)的錯(cuò)誤
安裝過程中有可能會(huì)出現(xiàn)各種各樣的錯(cuò)誤,這里筆者將自己遇到的問題也整理下來供大家參考。
在每次遇到問題的時(shí)候我都會(huì)這樣想,也會(huì)這樣做:
并不會(huì)所有人都會(huì)遇到問題,
而所有人也不會(huì)都出現(xiàn)同樣的問題。
但只要每個(gè)人將自己的解決過程分享出來,
那么我相信,
所有人的問題都會(huì)迎刃而解。🥰
互相幫助,將會(huì)使我們進(jìn)步的更快!
問題(1). fatal error: libmemcached/memcached.h: No such file or directory
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE_ZLIB -I/usr/include/python3.10 -c src/_pylibmcmodule.c -o build/temp.linux-x86_64-3.10/src/_pylibmcmodule.o -fno-strict-aliasing -std=c99In file included from src/_pylibmcmodule.c:34:src/_pylibmcmodule.h:42:10: fatal error: libmemcached/memcached.h: No such file or directory42 | #include <libmemcached/memcached.h>| ^~~~~~~~~~~~~~~~~~~~~~~~~~compilation terminated.error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1[end of output]note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure× Encountered error while trying to install package. ╰─> pylibmcnote: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.解決(1)
imaginemiracle:~$ sudo apt-get install libmemcached-dev zlib1g-dev問題(2). fatal error: ffi.h: No such file or directory
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/usr/include/python3.10 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.10/c/_cffi_backend.oc/_cffi_backend.c:15:10: fatal error: ffi.h: No such file or directory15 | #include <ffi.h>| ^~~~~~~compilation terminated.error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1[end of output]note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure× Encountered error while trying to install package. ╰─> cffinote: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.解決(2)
imaginemiracle:~$ sudo apt-get install libffi-dev問題(3). 出現(xiàn)有關(guān) c/_cffi_backend.c 源文件報(bào)錯(cuò)
c/_cffi_backend.c: In function ‘ctypedescr_dealloc’:c/_cffi_backend.c:407:23: error: lvalue required as left operand of assignment407 | Py_REFCNT(ct) = 43;| ^c/_cffi_backend.c:410:23: error: lvalue required as left operand of assignment410 | Py_REFCNT(ct) = 0;| ^c/_cffi_backend.c: In function ‘prepare_callback_info_tuple’:c/_cffi_backend.c:6185:5: warning: ‘PyEval_InitThreads’ is deprecated [-Wdeprecated-declarations]6185 | PyEval_InitThreads();| ^~~~~~~~~~~~~~~~~~In file included from /usr/include/python3.10/Python.h:130,from c/_cffi_backend.c:2:/usr/include/python3.10/ceval.h:122:37: note: declared here122 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);| ^~~~~~~~~~~~~~~~~~c/_cffi_backend.c: In function ‘b_callback’:c/_cffi_backend.c:6245:5: warning: ‘ffi_prep_closure’ is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations]6245 | if (ffi_prep_closure(closure, &cif_descr->cif,| ^~In file included from c/_cffi_backend.c:15:/usr/include/x86_64-linux-gnu/ffi.h:347:1: note: declared here347 | ffi_prep_closure (ffi_closure*,| ^~~~~~~~~~~~~~~~error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1[end of output]假的解決(3) 這里耍了小聰明
以下被劃掉的部分為筆者初次解決該錯(cuò)誤的方法,但這種方法導(dǎo)致了后面出現(xiàn)了嚴(yán)重而尷尬的問題,此處展示僅供讀者欣(cháo)賞(fěng)🤣😂😇🥳
對(duì)于該問題找了好久,但并沒有解決,因此筆者試著搜了一下 cffi 這個(gè)東西。
從當(dāng)前的官網(wǎng)來看,cffi 目前最新版本號(hào)為 1.15.0,而我們使用 pip 下載時(shí)候?qū)懙氖?cffi==1.14.0,看到這里嘗試將上文那串下載命令后面的版本號(hào)更改為 1.15.0再重新下載,問題解決,因此筆者這里猜測(cè)應(yīng)該是新版本與舊版本不兼容導(dǎo)致報(bào)錯(cuò)的。
來吧看看筆者這自以為是的解決方法會(huì)導(dǎo)致什么問題。
在一切安裝配置結(jié)束后,發(fā)現(xiàn) seafile 的網(wǎng)站運(yùn)行不起來。
使用 ./seahub.sh start-fastcgi 可以看到更細(xì)節(jié)的錯(cuò)誤原因。
seafile:seafile-server-latest$ ./seahub.sh start-fastcgiLC_ALL is not set in ENV, set to en_US.UTF-8 Starting seahub (fastcgi) at 127.0.0.1:8000 ... Traceback (most recent call last): ----------------------------snip-------------------------------- ----------------------------snip--------------------------------File "/usr/local/seafile-pro-server/seafile-pro-server-9.0.5/seahub/thirdpart/cffi/api.py", line 54, in __init__raise Exception("Version mismatch: this is the 'cffi' package version %s, located in %r. When we import the top-level '_cffi_backend' extension module, we get version %s, located in %r. The two versions should be equal; check your installation." % ( Exception: Version mismatch: this is the 'cffi' package version 1.14.0, located in '/usr/local/seafile-pro-server/seafile-pro-server-9.0.5/seahub/thirdpart/cffi/api.py'. When we import the top-level '_cffi_backend' extension module, we get version 1.15.0, located in '/usr/local/lib/python3.10/dist-packages/_cffi_backend.cpython-310-x86_64-linux-gnu.so'. The two versions should be equal; check your installation. Error:Seahub failed to start.這里省略掉無關(guān)緊要的輸出,直接看錯(cuò)誤原因,程序說,他應(yīng)該要的是 cffi 1.14.0 版本,而卻拿到的是 cffi 1.15.0,純屬找茬是不。這誰(shuí)能想到這玩意竟然指定版本的,唉😔。
真的解決(3)
這里我們把 cffi 1.14.0 和 cffi 1.15.0 源碼包下載下來,用源碼方式安裝。稍后會(huì)解釋為什么要下載兩個(gè)。
堅(jiān)持做免積分的CSDN下載鏈接:cffi 1.14.0 & cffi 1.15.0
git下載: cffi 1.14.0、cffi 1.15.0
cffi 官方下載鏈接: cffi 1.14.0、cffi 1.15.0
這里我們?cè)诮K端直接下載并解壓
imaginemiracle:Downloads$ git clone https://gitcode.net/imagine-miracle/cffi.git imaginemiracle:Downloads$ cd cffi imaginemiracle:cffi$ ls cffi-1.14.0.tar.gz cffi-1.15.0.tar.gz README.md imaginemiracle:cffi$ tar -xf cffi-1.14.0.tar.gz imaginemiracle:cffi$ tar -xf cffi-1.15.0.tar.gz imaginemiracle:cffi$ ls cffi-1.14.0 cffi-1.14.0.tar.gz cffi-1.15.0 cffi-1.15.0.tar.gz README.md進(jìn)入 cffi-1.14.0 目錄
imaginemiracle:cffi$ cd cffi-1.14.0/ imaginemiracle:cffi-1.14.0$ ls AUTHORS cffi demo LICENSE PKG-INFO setup_base.py setup.py c cffi.egg-info doc MANIFEST.in README.md setup.cfg testing安裝 python 插件 cffi
imaginemiracle:cffi-1.14.0$ sudo python3 setup.py install輸出如下
---------------------------snip---------------------------------- ---------------------------snip---------------------------------- c/_cffi_backend.c: In function ‘ctypedescr_dealloc’: c/_cffi_backend.c:407:23: error: lvalue required as left operand of assignment407 | Py_REFCNT(ct) = 43;| ^ c/_cffi_backend.c:410:23: error: lvalue required as left operand of assignment410 | Py_REFCNT(ct) = 0;| ^ c/_cffi_backend.c: In function ‘prepare_callback_info_tuple’: c/_cffi_backend.c:6185:5: warning: ‘PyEval_InitThreads’ is deprecated [-Wdeprecated-declarations]6185 | PyEval_InitThreads();| ^~~~~~~~~~~~~~~~~~ In file included from /usr/include/python3.10/Python.h:130,from c/_cffi_backend.c:2: /usr/include/python3.10/ceval.h:122:37: note: declared here122 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);| ^~~~~~~~~~~~~~~~~~ c/_cffi_backend.c: In function ‘b_callback’: c/_cffi_backend.c:6245:5: warning: ‘ffi_prep_closure’ is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations]6245 | if (ffi_prep_closure(closure, &cif_descr->cif,| ^~ In file included from c/_cffi_backend.c:15: /usr/include/x86_64-linux-gnu/ffi.h:347:1: note: declared here347 | ffi_prep_closure (ffi_closure*,| ^~~~~~~~~~~~~~~~ error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1這里可以看到出現(xiàn)的錯(cuò)誤,和我們用 pip3 安裝時(shí)候報(bào)錯(cuò)一樣,都是在 c/_cffi_backend.c 文件中出錯(cuò),說我們運(yùn)算符用錯(cuò)了這個(gè)那個(gè)的,筆者這里也偷懶一下。
c/_cffi_backend.c: In function ‘ctypedescr_dealloc’:c/_cffi_backend.c:407:23: error: lvalue required as left operand of assignment407 | Py_REFCNT(ct) = 43;| ^c/_cffi_backend.c:410:23: error: lvalue required as left operand of assignment410 | Py_REFCNT(ct) = 0;|我們打開 cffi 1.14.0 里的 _cffi_backend.c 文件,并鎖定到出錯(cuò)行。可以看到報(bào)錯(cuò)是由 ctypedescr_dealloc 函數(shù)引起。
// # File: cffi 1.14.0/c/_cffi_backend.c ##------## ctypedescr_dealloc() static void ctypedescr_dealloc(CTypeDescrObject *ct) {PyObject_GC_UnTrack(ct);if (ct->ct_weakreflist != NULL)PyObject_ClearWeakRefs((PyObject *) ct);if (ct->ct_unique_key != NULL) {/* revive dead object temporarily for DelItem */Py_REFCNT(ct) = 43;PyDict_DelItem(unique_cache, ct->ct_unique_key);assert(Py_REFCNT(ct) == 42);Py_REFCNT(ct) = 0;Py_DECREF(ct->ct_unique_key);}Py_XDECREF(ct->ct_itemdescr);Py_XDECREF(ct->ct_stuff);if (ct->ct_flags & CT_FUNCTIONPTR)PyObject_Free(ct->ct_extra);Py_TYPE(ct)->tp_free((PyObject *)ct); }這里我們對(duì)比 cffi 1.15.0 中的 _cffi_backend.c 文件,同樣找到 ctypedescr_dealloc 函數(shù)位置。可以看到在 1.15.0 版本中已經(jīng)修復(fù)了這個(gè)問題,使用的是新的賦值調(diào)用 Py_SET_REFCNT(ct, 43);
static void ctypedescr_dealloc(CTypeDescrObject *ct) {PyObject_GC_UnTrack(ct);if (ct->ct_weakreflist != NULL)PyObject_ClearWeakRefs((PyObject *) ct);if (ct->ct_unique_key != NULL) {/* revive dead object temporarily for DelItem */Py_SET_REFCNT(ct, 43);PyDict_DelItem(unique_cache, ct->ct_unique_key);assert(Py_REFCNT(ct) == 42);Py_SET_REFCNT(ct, 0);Py_DECREF(ct->ct_unique_key);}Py_XDECREF(ct->ct_itemdescr);Py_XDECREF(ct->ct_stuff);if (ct->ct_flags & CT_FUNCTIONPTR)PyObject_Free(ct->ct_extra);Py_TYPE(ct)->tp_free((PyObject *)ct); }這里我們也不深追代碼了,使用最簡(jiǎn)單的方法——“文件替換”,我們將用 cffi 1.15.0 中的 _cffi_backend.c 文件替換掉 cffi 1.14.0 中的 _cffi_backend.c 文件。
imaginemiracle:cffi-1.14.0$ cp ../cffi-1.15.0/c/_cffi_backend.c ./c/接下來,重新執(zhí)行安裝命令,這個(gè)時(shí)候就會(huì)發(fā)現(xiàn)我們已經(jīng)成功安裝好了 cffi-1.14.0。
imaginemiracle:cffi-1.14.0$ sudo python3 setup.py install ----------------------------snip--------------------------------- Installed /usr/local/lib/python3.10/dist-packages/cffi-1.14.0-py3.10-linux-x86_64.egg Processing dependencies for cffi==1.14.0 Searching for pycparser==2.21 Best match: pycparser 2.21 Adding pycparser 2.21 to easy-install.pth fileUsing /usr/local/lib/python3.10/dist-packages Finished processing dependencies for cffi==1.14.03.2. 安裝 MySQL
3.2.1. 使用 apt 安裝 mysql-server
若不提前安裝 MySQL 后面在設(shè)置創(chuàng)建數(shù)據(jù)庫(kù)時(shí)則會(huì)失敗!
imaginemiracle:~$ sudo apt-get update imaginemiracle:~$ sudo apt-get install mysql-server imaginemiracle:~$ sudo systemctl start mysql.service3.2.2. 查看是否安裝成功
使用 netstat 命令查看 MySQL 的 socket 是否為 listen 監(jiān)聽狀態(tài)。若顯示 LISTEN 則說明安裝成功。
imaginemiracle:~$ netstat -tag | gerp mysql tcp 0 0 localhost:mysql 0.0.0.0:* LISTEN查看 mysql.service 服務(wù)狀態(tài),看是否在運(yùn)行狀態(tài)。
imaginemiracle:~$ sudo systemctl status mysql.service ● mysql.service - MySQL Community ServerLoaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)Active: active (running) since Mon 2022-06-20 05:54:15 UTC; 15min agoMain PID: 29399 (mysqld)Status: "Server is operational"Tasks: 39 (limit: 19069)Memory: 361.5MCPU: 2.610sCGroup: /system.slice/mysql.service└─29399 /usr/sbin/mysqldJun 20 05:54:14 imaginemiracle-linux systemd[1]: Starting MySQL Community Server... Jun 20 05:54:15 imaginemiracle-linux systemd[1]: Started MySQL Community Server.3.2.3. 配置 MySQL
使用 mysql_secure_installation 對(duì) MySQL 初始化。
使用該命令,會(huì)對(duì)你提出幾個(gè)問題讓你回答:
| 是否安裝密碼校驗(yàn)插件 VALIDATE PASSWORD COMPONENT | no |
| 請(qǐng)為 root 管理員賬戶設(shè)置數(shù)據(jù)庫(kù)密碼 | 我是強(qiáng)壯的密碼(這里需要自己設(shè)置哦!) |
| 刪除匿名賬戶嗎 | yes |
| 是否禁止root管理員從遠(yuǎn)程登錄 | no |
| 是否刪除test數(shù)據(jù)庫(kù)并取消對(duì)它的訪問權(quán)限 | yes |
| 是否刷新授權(quán)表,讓初始化的設(shè)定立即生效 | yes |
執(zhí)行 MySQL 配置腳本
imaginemiracle:~$ sudo mysql_secure_installation第一個(gè)提示將詢問你是否要設(shè)置驗(yàn)證密碼插件,該插件可用于在認(rèn)為新用戶有效之前測(cè)試新 MySQL 用戶的密碼強(qiáng)度。
如果你選擇設(shè)置驗(yàn)證密碼插件,則創(chuàng)建的任何使用密碼進(jìn)行身份驗(yàn)證的 MySQL 用戶都需要具有滿足選擇的策略的密碼,所以選擇 No ,便可以使用簡(jiǎn)單的密碼。
Securing the MySQL server deployment.Connecting to MySQL using a blank password.VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?Press y|Y for Yes, any other key for No: YThere are three levels of password validation policy:LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2無論是否選擇設(shè)置驗(yàn)證密碼插件,下一個(gè)提示都是為 MySQL root 用戶設(shè)置密碼。輸入并確認(rèn)你設(shè)置的密碼:
Please set the password for root here.New password:Re-enter new password:如果第一個(gè)問題選擇使用了驗(yàn)證密碼插件,則將收到有關(guān)新密碼強(qiáng)度的反饋。然后腳本將詢問你是要繼續(xù)使用剛剛輸入的密碼還是要輸入新密碼。若對(duì)剛剛輸入的密碼強(qiáng)度感到滿意,則輸入 Y 以繼續(xù)執(zhí)行腳本:
Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : Y后續(xù)將會(huì)繼續(xù)詢問,是否需要?jiǎng)h除匿名用戶、禁用 root 用戶遠(yuǎn)程登錄和 是否刪除 test 數(shù)據(jù)庫(kù),是否確認(rèn)現(xiàn)在重新加載權(quán)限表?,分別回答 Y、N、Y、Y 便可。
By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.Remove anonymous users? (Press y|Y for Yes, any other key for No) : yes Success.Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : no... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.Remove test database and access to it? (Press y|Y for Yes, any other key for No) : yes- Dropping test database... Success.- Removing privileges on test database... Success.Reloading the privilege tables will ensure that all changes made so far will take effect immediately.Reload privilege tables now? (Press y|Y for Yes, any other key for No) : yes Success.All done!3.2.4. 修改 MySQL root 用戶為 mysql_native_password 驗(yàn)證方式
以 root 用戶登錄 MySQL
imaginemiracle:~$ sudo mysql -u root -p使用 ALTER USER 語(yǔ)句修改用戶信息。
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'imaginemiracle'; Query OK, 0 rows affected (0.00 sec)mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.01 sec)mysql> exit Bye3.2.5. 可能發(fā)生的意外(Error: SET PASSWORD has no significance for user ‘root’@‘localhost’)
有的小伙伴可能在第一次使用登錄時(shí),看到下面提示了 Enter password,并沒有使用回車跳過輸入,而是習(xí)慣性的輸入了本機(jī) root 用戶的密碼。
imaginemiracle:~$ sudo mysql -u root -p Enter password: # 未設(shè)置的情況下這里可以直接使用 “回車” 跳過事實(shí)上如果這個(gè)時(shí)候輸入的話,則會(huì)導(dǎo)致后面使用 mysql_secure_installation 設(shè)置 root 密碼失敗。你將會(huì)看到這樣的提示。
… Failed! Error: SET PASSWORD has no significance for user ‘root’@‘localhost’ as the authentication method used doesn’t store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.這個(gè)時(shí)候也莫需慌張,先直接退出設(shè)置,用下面命令重新連接數(shù)據(jù)庫(kù)。
imaginemiracle:~$ sudo mysql這個(gè)時(shí)候可能需要你輸入剛才輸入過的密碼,也就是你機(jī)器的 root 密碼。
進(jìn)入 sql 命令行后,輸入下面命令,并敲回車,則可以將你的密碼改成 imaginemiracle。(這里設(shè)置的密碼根據(jù)自己需要替換即可)
這個(gè)時(shí)候 exit 到終端下,再對(duì) MySQL 重新進(jìn)行設(shè)置,對(duì)于前兩個(gè)問題直接輸入 no 即可。
imaginemiracle:~$ sudo mysql_secure_installation3.3. 安裝 Java 運(yùn)行環(huán)境
Java 運(yùn)行時(shí)環(huán)境 (JRE) 是使用 elasticsearch 進(jìn)行全文搜索的要求。
執(zhí)行下面任意一組命令即可:
(1) Debian 10
(2) Ubuntu 16.04/18.04/20.04/22.04
imaginemiracle:~$ sudo apt-get install openjdk-8-jre -y imaginemiracle:~$ sudo ln -sf /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java /usr/bin/(3) CentOS
imaginemiracle:~$ sudo yum install java-1.8.0-openjdk -y3.4. 安裝 poppler-utils
pdf 文件的全文搜索需要包 poppler-utils。
執(zhí)行下面任意一組命令即可:
(1) Ubuntu/Debian
(2) CentOS
imaginemiracle:~$ sudo yum install poppler-utils -y3.5. 創(chuàng)建安裝目錄
在 /usr/local 目錄下創(chuàng)建 seafile-pro-server/installed(可以自定義命名),由于是在根目錄下 / 創(chuàng)建目錄,因此這里需要超級(jí)權(quán)限,或者可以直接切換到 root 用戶進(jìn)行操作。
imaginemiracle:~$ sudo mkdir -p /usr/local/seafile-pro-server/installed3.6. 創(chuàng)建 seafile 用戶
一般來說不要直接使用 root 用戶來運(yùn)行程序,這里新建一個(gè) seafile 用戶。
使用 adduser 命令創(chuàng)建用戶,并根據(jù)屏幕輸出提示設(shè)置密碼等其它用戶相關(guān)信息。
將在 /usr/local 下剛創(chuàng)建的目錄所有權(quán)更改為新用戶 seafile。
imaginemiracle:~$ sudo chown -R seafile: /usr/local/seafile-pro-server給 seafile 用戶授予 sudo 權(quán)限。
imaginemiracle:~$ sudo usermod -aG sudo seafile切換到 seafile 用戶
imaginemiracle:~$ su seafile3.7. 下載并解壓 Seafile 安裝包
進(jìn)入 installed 目錄。
seafile:~$ cd /usr/local/seafile-pro-server/installed下載 seafile pro server。
seafile:installed$ wget https://download.seafile.com/seafhttp/files/7338d67f-3a22-4243-bfe6-99632f01ca63/seafile-pro-server_9.0.5_x86-64_Ubuntu.tar.gz使用 tar 解壓 seafile 壓縮包。
seafile:installed$ tar -zxvf seafile-pro-server_9.0.5_x86-64_Ubuntu.tar.gz -C /usr/local/seafile-pro-server/進(jìn)入解壓后的目錄:
seafile:installed$ cd /usr/local/seafile-pro-server/seafile-pro-server-9.0.5/創(chuàng)建好的目錄結(jié)構(gòu)大概是這樣的
seafile:seafile-pro-server-9.0.5$ tree /usr/local/seafile-pro-server/ -L 2 /usr/local/seafile-pro-server/ ├── installed │ └── seafile-pro-server_9.0.5_x86-64_Ubuntu.tar.gz └── seafile-pro-server-9.0.5├── check-db-type.py├── check_init_admin.py├── index_op.py├── migrate.py├── migrate-repo.py├── migrate-repo.sh├── migrate.sh├── pro├── remove-objs.py├── remove-objs.sh├── reset-admin.sh├── run_index_master.sh├── run_index_worker.sh├── runtime├── seaf-backup-cmd.py├── seaf-backup-cmd.sh├── seaf-encrypt.sh├── seaf-fsck.sh├── seaf-fuse.sh├── seaf-gc.sh├── seafile├── seafile-background-tasks.sh├── seafile.sh├── seaf-import.sh├── seahub├── seahub.sh├── setup-seafile-mysql.py├── setup-seafile-mysql.sh├── setup-seafile.sh├── sql└── upgrade8 directories, 26 files這樣構(gòu)建目錄的好處在于:
- 與 seafile 相關(guān)配置文件都可以放在 /usr/local/seafile-pro-server/conf 目錄下,便于集中管理;
- 后續(xù)升級(jí)時(shí),只需要解壓最新的安裝包到 /usr/local/seafile-pro-server 目錄下即可。
4. 開始部署 Seafile 服務(wù)器
正常流程的話,我們的當(dāng)前目錄應(yīng)該是:
seafile:seafile-pro-server-9.0.5$ pwd /usr/local/seafile-pro-server/seafile-pro-server-9.0.5如果不在 seafile 解壓后的目錄的話,請(qǐng)移步到此目錄,該目錄的文件大概像下面這樣:
seafile:seafile-pro-server-9.0.5$ ls check-db-type.py migrate.sh run_index_worker.sh seaf-fuse.sh seahub upgrade check_init_admin.py pro runtime seaf-gc.sh seahub.sh index_op.py remove-objs.py seaf-backup-cmd.py seafile setup-seafile-mysql.py migrate.py remove-objs.sh seaf-backup-cmd.sh seafile-background-tasks.sh setup-seafile-mysql.sh migrate-repo.py reset-admin.sh seaf-encrypt.sh seafile.sh setup-seafile.sh migrate-repo.sh run_index_master.sh seaf-fsck.sh seaf-import.sh sql4.1. 執(zhí)行安裝腳本
在安裝目錄下有一個(gè) setup-seafile-mysql.sh 這個(gè)文件,運(yùn)行它。正常情況下它會(huì)依次開始詢問一些配置問題,并引導(dǎo)你來安裝它,雖然再上文有寫過安裝 Java 環(huán)境(那是后來補(bǔ)上的),但由于筆者剛開始沒有安裝,因此它會(huì)提示我來安裝,如果你的系統(tǒng)也缺少的話,那么它也會(huì)提示你的,按照提示安裝即可。
seafile:seafile-pro-server-9.0.5$ ./setup-seafile-mysql.sh Checking python on this machine ...Checking for java ... Java is not found. install it first.On Debian/Ubuntu: apt-get install default-jre On CentOS/RHEL: yum install jreError occured during setup. Please fix possible problems and run the script again.看起來是我的系統(tǒng)里沒有 Java 的運(yùn)行環(huán)境,安裝它。
seafile:seafile-pro-server-9.0.5$ sudo apt-get install default-jre -y安裝完畢后,重新執(zhí)行安裝腳本。
[注]:不是 root 的你記得要加 sudo 哦。
初始化腳本會(huì)檢查是否滿足安裝條件,條件滿足后,按回車即可繼續(xù)安裝。下面會(huì)依次詢問你一些問題,從而引導(dǎo)使用者安裝并配置 Seafile,不輸入直接敲回車則表示使用默認(rèn)配置。
4.1.1. 設(shè)置服務(wù)器名稱
命名要求:由 3-15 個(gè)字符,只允許英文字母、數(shù)字和下劃線(‘_’),不可少也不可多。
4.1.2. 設(shè)置服務(wù)器 ip 或域名
如果本機(jī)使用的是公網(wǎng) IP 的話并且綁定了域名,那么就可以使用域名來設(shè)置,之后便可以通過域名來訪問云盤了。
如果沒有的話,這里設(shè)置本機(jī) IP 即可。
4.1.3. 設(shè)置端口號(hào)
使用哪個(gè)端口訪問,這里可以自定義端口,也可以使用默認(rèn)端口。(在默認(rèn)端口未被占用時(shí),建議使用默認(rèn)端口)
4.1.4. 選擇數(shù)據(jù)庫(kù)構(gòu)建方式
這里提供兩個(gè)選項(xiàng):
[1] 創(chuàng)建新的數(shù)據(jù)庫(kù) ccnet/seafile/seahub,選擇該項(xiàng)則提供 root 密碼,腳本程序會(huì)自動(dòng)為你創(chuàng)建好數(shù)據(jù)庫(kù)和用戶;
[2] 使用已有數(shù)據(jù)庫(kù) ccnet/seafile/seahub,選擇該項(xiàng)則說明已經(jīng)存在創(chuàng)建好的數(shù)據(jù)庫(kù),否則請(qǐng)選擇 [1]。
選擇“ [1]創(chuàng)建新的 ccnet/seafile/seahub 數(shù)據(jù)庫(kù)”時(shí),該腳本會(huì)創(chuàng)建這些數(shù)據(jù)庫(kù),并且 Seafile Server 將使用Seafile Server 訪問它們的 MySQL 用戶。你將需要回答以下問題:
| mysql 服務(wù)器主機(jī) | MySQL 服務(wù)器的主機(jī)地址 | 默認(rèn)是本地主機(jī) | 本機(jī) IP |
| mysql 服務(wù)器端口 | MySQL 服務(wù)器使用的 TCP 端口 | 默認(rèn)端口為 3306。幾乎每個(gè) MySQL 服務(wù)器都使用這個(gè)端口 | 聽她的 |
| mysql root 密碼 | MySQL root 賬戶的密碼 | 創(chuàng)建新數(shù)據(jù)庫(kù)和 MySQL 用戶需要 root 密碼 | 給她你 root 密碼 |
| Seafile 的 mysql 用戶 | 由腳本創(chuàng)建的 MySQL 用戶,Seafile 的組件使用它來訪問數(shù)據(jù)庫(kù) | 默認(rèn)為seafile;除非用戶存在,否則創(chuàng)建用戶 | 我們?cè)缃ê昧?/td> |
| Seafile 用戶的 mysql 密碼 | 上面用戶的密碼,寫在 Seafile 的配置文件中 | 不允許使用百分號(hào) (‘%’) | 我們也設(shè)好了 |
| 數(shù)據(jù)庫(kù)名稱 | ccnet使用的數(shù)據(jù)庫(kù)名稱 | 默認(rèn)為“ccnet-db”,如果數(shù)據(jù)庫(kù)不存在則創(chuàng)建 | \ |
| seafile 數(shù)據(jù)庫(kù)名稱 | Seafile 使用的數(shù)據(jù)庫(kù)名稱 | 默認(rèn)為“seafile-db”,如果數(shù)據(jù)庫(kù)不存在則創(chuàng)建 | \ |
| seahub 數(shù)據(jù)庫(kù)名稱 | seahub 使用的數(shù)據(jù)庫(kù)名稱 | 默認(rèn)為“seahub-db”,如果數(shù)據(jù)庫(kù)不存在則創(chuàng)建 | \ |
| mysql服務(wù)器主機(jī) | MySQL服務(wù)器的主機(jī)地址 | 默認(rèn)是本地主機(jī) | 本機(jī) IP |
| mysql服務(wù)器端口 | MySQL 服務(wù)器使用的 TCP 端口 | 默認(rèn)端口為 3306;幾乎每個(gè) MySQL 服務(wù)器都使用這個(gè)端口 | 聽她的 |
| Seafile 的 mysql 用戶 | Seafile 組件用來訪問數(shù)據(jù)庫(kù)的用戶 | 用戶必須存在 | \ |
| Seafile 用戶的 mysql 密碼 | 上面用戶的密碼 | \ | \ |
| ccnet 數(shù)據(jù)庫(kù)名稱 | ccnet使用的數(shù)據(jù)庫(kù)名稱,默認(rèn)為“ccnet-db” | 數(shù)據(jù)庫(kù)必須存在 | \ |
| seafile 數(shù)據(jù)庫(kù)名稱 | Seafile 使用的數(shù)據(jù)庫(kù)名稱,默認(rèn)為“seafile-db” | 數(shù)據(jù)庫(kù)必須存在 | \ |
| seahub 數(shù)據(jù)庫(kù)名稱 | Seahub 使用的數(shù)據(jù)庫(kù)名稱,默認(rèn)為“seahub-db” | 數(shù)據(jù)庫(kù)必須存在 | \ |
來看看實(shí)際情況,初次安裝都會(huì)選擇 [1] 選項(xiàng)。此時(shí)則會(huì)詢問你如下問題:
(1) 設(shè)置數(shù)據(jù)庫(kù)地址
這里可以使用默認(rèn),也可以自定義設(shè)置。
(2) 設(shè)置可連接主機(jī)
這里的默認(rèn)為 %,該通配符代表允許用戶賬戶從任何主機(jī)都可以連接。一般情況使用默認(rèn)就好。
(3) 設(shè)置數(shù)據(jù)庫(kù)端口號(hào)
沒有特殊情況,使用默認(rèn)即可。
(4) 輸入數(shù)據(jù)庫(kù) root 用戶的密碼
4.1.5. 創(chuàng)建 MySQL seafile 用戶
按上文操作的話,我們已經(jīng)創(chuàng)建好了系統(tǒng)的 seafile 用戶,這里會(huì)為我們創(chuàng)建 MySQL seafile 用戶,這里會(huì)要求我們?cè)O(shè)置 MySQL seafile 用戶的密碼。
4.1.6. 創(chuàng)建數(shù)據(jù)庫(kù)
創(chuàng)建數(shù)據(jù)庫(kù) ccnet-db、seafile-db、seahub-db,這三個(gè)數(shù)據(jù)庫(kù)直接使用默認(rèn)設(shè)置即可,這里輸入三次回車即可。(若此處并無權(quán)限操作,請(qǐng)看后面手動(dòng)創(chuàng)建數(shù)據(jù)庫(kù)過程)
4.1.7. 確認(rèn)設(shè)置
確認(rèn)設(shè)置的信息沒問題直接輸入回車,將會(huì)自動(dòng)為我們安裝好 seafile。
4.1.8. 確認(rèn)完成
若安裝完成將會(huì)出現(xiàn)如下輸出。
此時(shí)的目錄布局如下:
該文件夾 seafile-server-latest 是指向當(dāng)前 Seafile Server 文件夾的符號(hào)鏈接。當(dāng)您稍后升級(jí)到新版本時(shí),升級(jí)腳本會(huì)更新此鏈接以指向最新的 Seafile Server 文件夾。
5. 設(shè)置 MySQL
以 root 用戶登錄數(shù)據(jù)庫(kù)。
imaginemiracle:~$ sudo mysql -u root -p創(chuàng)建 mtsql seafile 用戶,imaginemiracle 則為 seafile 用戶登錄 mysql 的密碼。
mysql> create user 'seafile'@'localhost' identified by 'imaginemiracle';將用戶 seafile 的身份驗(yàn)證插件更改為 mysql_native_password:
mysql> ALTER USER 'seafile'@'localhost' identified with mysql_native_password by 'imaginemiracle';手動(dòng)創(chuàng)建數(shù)據(jù)庫(kù) ccnet、seafile、seahub(已使用腳本成功創(chuàng)建數(shù)據(jù)庫(kù)的讀者無需執(zhí)行)
mysql> create database `ccnet_db` character set = 'utf8';mysql> create database `seafile_db` character set = 'utf8';mysql> create database `seahub_db` character set = 'utf8';賦予 seafile 用戶這三個(gè)數(shù)據(jù)庫(kù)的訪問權(quán)限。(已使用腳本成功創(chuàng)建數(shù)據(jù)庫(kù)的讀者無需執(zhí)行)
mysql> GRANT ALL PRIVILEGES ON `ccnet_db`.* to `seafile`@localhost;mysql> GRANT ALL PRIVILEGES ON `seafile_db`.* to `seafile`@localhost;mysql> GRANT ALL PRIVILEGES ON `seahub_db`.* to `seafile`@localhost;刷新權(quán)限表。
mysql> FLUSH PRIVILEGES;退出 mysql
mysql> exit6. 調(diào)整 conf 文件
由安裝腳本創(chuàng)建的 Seafile 配置文件是為在反向代理后面運(yùn)行的 Seafile 準(zhǔn)備的。
要訪問 Seafile 的 Web 界面并在沒有反向代理的情況下創(chuàng)建工作共享鏈接,需要修改以下兩個(gè)配置文件 /usr/local/seafile-pro-server/conf:
- seahub_settings.py(適用于 9.0.x): 將端口 8000 添加到 SERVICE_URL(即 SERVICE_URL = http://11.22.33.44:8000/);
[注]:此處的 ip 地址僅作為示例。 - ccnet.conf(適用于 8.0.x 或 7.1.x): 將端口 8000 添加到 SERVICE_URL(即 SERVICE_URL = http://11.22.33.44:8000/)。
- gunicorn.conf.py: 將綁定更改為 "0.0.0.0:8000"(即 bind = “0.0.0.0:8000”)。
7. 啟動(dòng) Seafile 服務(wù)器
進(jìn)入 /usr/local/seafile-pro-server/seafile-server-latest 目錄。
seafile:~$ cd /usr/local/seafile-pro-server/seafile-server-latest使用啟動(dòng)如下兩個(gè)腳本。
seafile:seafile-server-latest$ ./seafile.sh start # 啟動(dòng) Seafile 服務(wù) seafile:seafile-server-latest$ ./seahub.sh start # 啟動(dòng) seahub 網(wǎng)站,默認(rèn)端口為 127.0.0.1:8000第一次啟動(dòng) Seahub 時(shí),腳本會(huì)提示您為 Seafile 服務(wù)器創(chuàng)建一個(gè)管理員帳戶。輸入管理員用戶的電子郵件地址和密碼。
當(dāng)輸入完你的 seafile 賬戶后,則會(huì)提示啟動(dòng)完成。
7.1. 可能出現(xiàn)的錯(cuò)誤(Failed to connect to MySQL: Plugin caching_sha2_password could not be loaded)
執(zhí)行完 seafile.sh start 命令后,有可能會(huì)出現(xiàn)如下錯(cuò)誤。
seafile:seafile-server-latest$ ./seafile.sh start** Message: 06:43:27.575: seafile-controller.c(1023): loading seafdav config from /usr/local/seafile-pro-server/conf/seafdav.conf2022-06-21 06:43:27 ../common/seaf-utils.c(409): Use database Mysql 2022-06-21 06:43:27 http-server.c(236): fileserver: worker_threads = 102022-06-21 06:43:27 http-server.c(249): fileserver: backlog = 32 2022-06-21 06:43:27 http-server.c(264): fileserver: fixed_block_size = 8388608 2022-06-21 06:43:27 http-server.c(279): fileserver: web_token_expire_time = 3600 2022-06-21 06:43:27 http-server.c(294): fileserver: max_indexing_threads = 1 2022-06-21 06:43:27 http-server.c(309): fileserver: max_index_processing_threads= 3 2022-06-21 06:43:27 http-server.c(331): fileserver: cluster_shared_temp_file_mode = 600 2022-06-21 06:43:27 http-server.c(409): fileserver: enable_async_indexing = 0 2022-06-21 06:43:27 http-server.c(421): fileserver: async_indexing_threshold = 700 2022-06-21 06:43:27 http-server.c(433): fileserver: fs_id_list_request_timeout = 300 2022-06-21 06:43:27 http-server.c(446): fileserver: max_sync_file_count = 100000 2022-06-21 06:43:27 http-server.c(461): fileserver: put_head_commit_request_timeout = 10 2022-06-21 06:43:27 ../common/license.c(709): License file /usr/local/seafile-pro-server/seafile-license.txt does not exist, allow at most 3 trial users License file /usr/local/seafile-pro-server/seafile-license.txt does not exist, allow at most 3 trial users 2022-06-21 06:43:27 ../common/seaf-db.c(739): Failed to connect to MySQL: Plugin caching_sha2_password could not be loaded: /usr/lib/mariadb/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory 2022-06-21 06:43:27 ../common/user-mgr.c(97): Failed to get user number from DB. 2022-06-21 06:43:27 seafile-session.c(422): Failed to init user manager. failed to run "seaf-server -t" [65280]該錯(cuò)誤是 seafile 無法被驗(yàn)證從而無法連接到數(shù)據(jù)庫(kù),解決方法如下。
以 root 用戶登錄到 MySQL。
將 seafile 用戶的驗(yàn)證插件修改為 mysql_native_password:
mysql> ALTER USER 'seafile'@'127.0.0.1' identified with mysql_native_password by 'imaginemiracle';7.2. 這里沒找到你的錯(cuò)誤???
執(zhí)行 seafile.sh 文件時(shí)一般會(huì)輸出詳細(xì)的錯(cuò)誤信息,根據(jù)錯(cuò)誤信息查詢解決方法即可。
而啟動(dòng) seahub.sh 是不會(huì)給出特別詳細(xì)的錯(cuò)誤信息,這個(gè)時(shí)候使用如下命令啟動(dòng),可以查看更詳細(xì)的信息,根據(jù)錯(cuò)誤信息來查詢相應(yīng)解決方法即可。
8. 訪問 Seafile 云盤服務(wù)器
當(dāng)完全成功通過上文配置后,此時(shí)你將可以在內(nèi)網(wǎng)下通過主機(jī)地址和端口 8000(例如 http://11.22.33.44:8000)的 Web 界面訪問 Seafile。
但這個(gè)時(shí)候在內(nèi)網(wǎng)的主機(jī)也只能通過 IP: Port 的形式訪問網(wǎng)頁(yè),并不能做上傳/下載的操作,只能在本機(jī)上上傳/下載,這完全不符合我們的要求,最起碼可以在內(nèi)網(wǎng)下的主機(jī)都可以上傳下載才行。
9. 配置內(nèi)網(wǎng)(局域網(wǎng))下上傳/下載
9.1. 修改 MySQL 服務(wù)的配置
打開 mysql 的配置文件。
imaginemiracle:~$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf找到 bind-address = 127.0.0.1 和 mysqlx-bind-address = 127.0.0.1,將這兩行注釋掉,即在這兩行最前面加上 # 即可。
重啟 mysql.service。
9.2. 修改 MySQL 的 seafile 用戶設(shè)置
以 root 用戶登錄 mysql。
imaginemiracle:~$ sudo mysql -u root -p選擇 user 表。
mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -ADatabase change查看 user 表,可以看到 seafile 用戶目前只能通過 localhost 也就是本機(jī)的 127.0.0.1 來訪問數(shù)據(jù)庫(kù),由于目前 seahub 是通過 localhost:8082 上傳和下載文件,這也就是為什么不能在其它主機(jī)上上傳和下載的原因。
mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | debian-sys-maint | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | | seafile | localhost | +------------------+-----------+ 6 rows in set (0.00 sec)因此我們需要修改 seafile 用戶的訪問地址,使其可以通過本機(jī)的網(wǎng)絡(luò) IP 訪問數(shù)據(jù)庫(kù),同時(shí)刷新權(quán)限表。這里使用通用符 % 來表示該用戶可以通過任何途徑訪問數(shù)據(jù)庫(kù);
mysql> update user set host='%' where user='seafile'; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | seafile | % | | debian-sys-maint | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | root | localhost | +------------------+-----------+ 6 rows in set (0.00 sec)mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)修改 seafile 用戶信息(修改為可以通過任何途徑連接數(shù)據(jù)庫(kù),即可通過域名訪問或主機(jī) IP 連接數(shù)據(jù)庫(kù),同時(shí)修改 seafile 用戶的驗(yàn)證插件為 mysql_native_password),同時(shí)刷新權(quán)限表。
mysql> ALTER USER 'seafile'@'%' IDENTIFIED WITH mysql_native_password by 'imaginemiracle'; Query OK, 0 rows affected (0.00 sec)mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)9.3. 修改 seafile 可通過域名或 主機(jī)IP 訪問 ccnet、seafile、seahub 數(shù)據(jù)庫(kù)
修改 seafile 訪問數(shù)據(jù)庫(kù)的方式,同時(shí)刷新權(quán)限表。
mysql> GRANT ALL PRIVILEGES ON `ccnet_db`.* to `seafile`@'%'; Query OK, 0 rows affected (0.00 sec)mysql> GRANT ALL PRIVILEGES ON `seafile_db`.* to `seafile`@'%'; Query OK, 0 rows affected (0.00 sec)mysql> GRANT ALL PRIVILEGES ON `seahub_db`.* to `seafile`@'%'; Query OK, 0 rows affected (0.00 sec)mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)MySQL 配置完成,退出 mysql。
mysql> exit Bye重啟 mysql.service。
imaginemiracle:~$ sudo systemctl restart mysql.service9.4. 修改 seafile pro server 配置
進(jìn)入 seafile 服務(wù)器的配置目錄。
seafile:~$ cd /usr/local/seafile-pro-server/conf seafile:conf$ ls ccnet.conf gunicorn.conf.py __pycache__ seafdav.conf seafevents.conf seafile.conf seahub_settings.py(1). 打開 ccnet.conf 文件,將其中 HOST = 127.0.0.1 修改為 HOST = www.imaginemiracle.com;
(2). 打開 seafevents.conf 文件,其中 host = 127.0.0.1 修改為 host = www.imaginemiracle.com;
(3). 打開 seafile.conf 文件,其中 host = 127.0.0.1 修改為 host = www.imaginemiracle.com;
(4). 打開 seahub_settings.py 文件,其中 ‘HOST’ : ‘127.0.0.1’ 修改為 ‘HOST’ : ‘www.imaginemiracle.com’;
[注]:以上僅以 www.imaginemiracle.com 作為示例使用,具體應(yīng)根據(jù)實(shí)際情況修改為正確域名或本機(jī) IP。
9.5. 重啟 seafile 服務(wù)
進(jìn)入 seafile 安裝目錄。
seafile:~$ cd /usr/local/seafile-pro-server/seafile-server-latest重啟服務(wù)。
seafile:seafile-server-latest$ ./seafile.sh start seafile:seafile-server-latest$ ./seahub.sh start9.6. 設(shè)置 seafile 網(wǎng)頁(yè)的文件服務(wù)地址
使用 IP:Prot 進(jìn)入 seafile 網(wǎng)址的系統(tǒng)設(shè)置。(默認(rèn)設(shè)置下的端口應(yīng)該是 8000)
修改 FILE_SERVER_ROOT 的地址為 http://host ip:port。默認(rèn)設(shè)置這里的端口為 8082,可以通過查看 conf/seafile.conf 文件獲取修改配置后的文件服務(wù)端口。
[注]:http://11.22.33.44:8082 僅作為示例,請(qǐng)根據(jù)實(shí)際情況修改。
10. 啟用 Https(可選——但建議)
將服務(wù)器通過加密的 Https 訪問代替現(xiàn)在的從未加密的 Http 訪問。
10.1. 安裝 Nginx
適用于 Debian/Ubuntu
imaginemiracle:~$ sudo apt install nginx -y適用于 CentOS
imaginemiracle:~$ sudo yum install nginx -y安裝成功后,啟動(dòng)它,并開啟隨系統(tǒng)開機(jī)啟動(dòng)。
適用于 CentOS/Debian/Ubuntu
10.2. 準(zhǔn)備工作
適用于 Debian/Ubuntu
在以下位置為 seafile 創(chuàng)建一個(gè)配置文件 /etc/nginx/sites-available/:
/etc/nginx/sites-enabled/ 刪除和中的默認(rèn)文件 /etc/nginx/sites-available:
imaginemiracle:~$ sudo rm /etc/nginx/sites-enabled/default imaginemiracle:~$ sudo rm /etc/nginx/sites-available/default創(chuàng)建符號(hào)鏈接:
imaginemiracle:~$ sudo ln -s /etc/nginx/sites-available/seafile.conf /etc/nginx/sites-enabled/seafile.conf適用于 CentOS
將 SELinux 切換到許可模式并保持設(shè)置:
在以下位置為 seafile 創(chuàng)建一個(gè)配置文件 /etc/nginx/conf.d:
imaginemiracle:~$ touch /etc/nginx/conf.d/seafile.conf10.3. 配置 Nginx
將以下內(nèi)容復(fù)制到剛創(chuàng)建好的 seafile.conf 文件中,并對(duì)以下內(nèi)容做一些修改。
log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $upstream_response_time';server {listen 80;server_name imaginemiracle.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 Serverclient_max_body_size 10000m;access_log /var/log/nginx/seahub.access.log seafileformat;error_log /var/log/nginx/seahub.error.log;}# If you are using [FastCGI](http://en.wikipedia.org/wiki/FastCGI), # which is not recommended, you should use the following config for location `/`. # # location / { # fastcgi_pass 127.0.0.1:8000; # 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; # fastcgi_read_timeout 36000; # # 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 10000m;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;access_log /var/log/nginx/seafhttp.access.log seafileformat;error_log /var/log/nginx/seafhttp.error.log;}location /media {root /usr/local/seafile-pro-server/seafile-server-latest/seahub;} }- 修改 server_name(必須):
該項(xiàng)的默認(rèn)值為 "imaginemiracle.com",這里若有域名則修改為域名,無可用域名則修改為本機(jī) IP 即可。 - location /media(必須):
該項(xiàng)描述的是 seafile 的資源目錄,筆者已經(jīng)在上面提供的配置文件中做出修改,根據(jù)本文安裝的讀者可以不用再次修改,安裝在其他目錄的讀者需根據(jù)自己安裝的目錄自行修改即可。 - 服務(wù)器監(jiān)聽端口 listen(可選):
若希望配置的 seafile 服務(wù)器運(yùn)行在非標(biāo)準(zhǔn)端口上則修改即可。 - location /::proxy_pass(可選):
如果 Seahub 配置為在不同于 8000 的端口上啟動(dòng)。 - ** location /seafhttp::proxy_pass(可選):**
如果 seaf-server 配置為在不同于 8082 的端口上啟動(dòng)。 - 請(qǐng)求正文的最大允許大小 client_max_body_size(可選):
本文給出的默認(rèn)值為 1000m,表示 Nginx 可支持的請(qǐng)求實(shí)體最大為 1GB,可根據(jù)實(shí)際情況調(diào)節(jié)。Seahub 的默認(rèn)值為 1M,上傳較大文件將導(dǎo)致錯(cuò)誤消息 HTTP 錯(cuò)誤代碼 413(“請(qǐng)求實(shí)體太大”)。建議將 client_max_body_size 的值與 conf/seafile.conf 中 max_upload_size 部分 [fileserver] 中的參數(shù)同步。
為所有用戶設(shè)置默認(rèn)配額(例如 2GB)。為此,只需將以下行添加到 conf/seafile.conf 文件中。
[quota] # default user quota in GB, integer only default = 210.4. 為 443 端口添加服務(wù)塊(沒有域名的小伙伴可以忽略此小節(jié))
若有域名的小伙伴可以暫停,先看 11 小節(jié)內(nèi)容,完了再回來繼續(xù)。。
為端口 443 添加一個(gè)服務(wù)器塊,并將 http-to-https 重定向 seafile.conf 到 /etc/nginx。
編輯 /etc/nginx/sites-available/seafile.conf 文件。
log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $upstream_response_time';server {listen 80;server_name www.imaginemiracle.com;rewrite ^ https://$http_host$request_uri? permanent; # Forced redirect from HTTP to HTTPSserver_tokens off; # Prevents the Nginx version from being displayed in the HTTP response header }server {listen 443;ssl on;ssl_certificate /etc/letsencrypt/live/www.imaginemiracle.com/fullchain.pem; # Path to your fullchain.pemssl_certificate_key /etc/letsencrypt/live/www.imaginemiracle.com/privkey.pem; # Path to your privkey.pemserver_name www.imaginemiracle.com;server_tokens off;# HSTS for protection against man-in-the-middle-attacks# 啟用 HTTP 嚴(yán)格傳輸安全 (HSTS) 以防止中間人攻擊add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";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;# proxy_set_header X-Forwarded-For $remote_addr;proxy_set_header X-Forwarded-Proto https;# used for view/edit office file via Office Online Serverclient_max_body_size 0; ... # No changes beyond this point compared to the Nginx configuration without HTTPS以上是筆者修改部分的全部?jī)?nèi)容,是文件的部分內(nèi)容,大家根據(jù)對(duì)比該內(nèi)容,并根據(jù)實(shí)際情況修改相應(yīng)內(nèi)容。
10.5. 重啟 Ngnix
確保您的 seafile.conf 不包含語(yǔ)法錯(cuò)誤并重新啟動(dòng) Nginx 以使配置更改生效。
imaginemiracle:~$ sudo nginx -t imaginemiracle:~$ sudo nginx -s reload10.6. 修改 seahub_settings.py
修改 seahub_settings.py 文件中的 SERVICE_URL = “https://11.22.33.44:8000/”,修改為 SERVICE_URL = “https://www.imaginemiracle.com/”。
重啟 seafile 服務(wù)。
刪除防火墻的 8000 的入站規(guī)則。
seafile:seafile-server-latest$ firewall-cmd --permanent --remove-port=8000/tcp systemctl reload firewalld.service10.7. 修改 seafile.conf 并重啟 seafile 服務(wù)
為了提高安全性,文件服務(wù)器應(yīng)該只能通過 Nginx 訪問。
修改 conf/seafile.conf 文件,在 [fileserver] 塊下添加如內(nèi)容:
更新之后,文件服務(wù)器只接受來自 Nginx 的請(qǐng)求。
重啟 Seafile 服務(wù)。
10.8. 驗(yàn)證
使用域名 www.imaginemiracle.com 或 IP 訪問 seafile 網(wǎng)頁(yè),查看網(wǎng)頁(yè)的管理設(shè)置,就會(huì)發(fā)現(xiàn)這里已經(jīng)變?yōu)?https 的開頭了。
沒有域名的讀者需要在此處將 FILE_SERVER_ROOT 的值設(shè)置為 “http://[host ip]:[port]/seafhttp”
有域名并且根據(jù) 11 章節(jié)完成 SSL 配置后可將 FILE_SERVER_ROOT 的值設(shè)置為 “https://[your domain]/seafhttp”
11. 獲取 Let’s Encrypt 證書 (沒有域名的小伙伴請(qǐng)忽略此章節(jié))
Certbot 讓獲得 Let's Encrypt 證書如此簡(jiǎn)單。Certbot 是一個(gè)免費(fèi)的開源軟件工具,用于請(qǐng)求、接收和更新 Let's Encrypt 證書。
11.1 進(jìn)入 Cerbot 官網(wǎng)
訪問 Cerbot官網(wǎng) 選擇所部署的網(wǎng)絡(luò)服務(wù)器和操作系統(tǒng)類型。
11.2. 根據(jù)提示操作
根據(jù)官網(wǎng)提示一步步操作即可。雖然筆者也將具體步驟寫下來了。
11.3. 與官網(wǎng)同樣的步驟——多余的憂心
原諒筆者出于對(duì)大家不信任的擔(dān)心,這里還是寫下根據(jù)官網(wǎng)說明的具體步驟吧。
一般情況下,若使用的是近幾年發(fā)行版的 Linux,那么其本身已經(jīng)預(yù)裝過 snapd 了,不過我們也可以再安裝一次,反正無所謂。
11.4. 安裝 snapd
imaginemiracle:~$ sudo apt-get update imaginemiracle:~$ sudo apt-get install snap11.5. 更新 snapd
執(zhí)行如下命令來確保使用的 snapd 是最新版,若如下輸出則說明已經(jīng)是最新版。
imaginemiracle:~$ sudo snap install core; sudo snap refresh core snap "core" is already installed, see 'snap help refresh' snap "core" has no updates available可能出現(xiàn)的問題(憂心關(guān)鍵點(diǎn)):
當(dāng)執(zhí)行更新命令時(shí),也有可能是得到如下錯(cuò)誤輸出。
那么此時(shí)檢查 snapd.service 服務(wù)是否開啟。一般這種情況是該服務(wù)未打開導(dǎo)致。
imaginemiracle:~$ sudo systemctl status snapd.service ○ snapd.service - Snap DaemonLoaded: loaded (/lib/systemd/system/snapd.service; enabled; vendor preset: enabled)Active: inactive (dead) TriggeredBy: ○ snapd.socket如上顯示的狀態(tài)是 “未活動(dòng)”,那么將其打開即可。
imaginemiracle:~$ sudo systemctl start snapd.service開啟服務(wù)后再次執(zhí)行更新命令便可成功運(yùn)行。
imaginemiracle:~$ sudo snap install core; sudo snap refresh core11.6. 刪除 cerbot 包
安裝 Cerbot snap 之前需要將之前任意類型的 Cerbot 包卸載掉。
適用于 Debian/Ubuntu:
適用于 CentOS:
imaginemiracle:~$ sudo yum remove certbot適用于 Fedora:
imaginemiracle:~$ sudo dnf remove certbot11.7. 安裝 Cerbot
適用于 Debian/Ubuntu/CentOS/Fedora:
imaginemiracle:~$ sudo snap install --classic certbot在機(jī)器上的命令行執(zhí)行以下指令,保證 certbot 命令可以運(yùn)行。
imaginemiracle:~$ sudo ln -s /snap/bin/certbot /usr/bin/certbot11.8. 獲取證書
根據(jù)官網(wǎng)建議,只獲得一個(gè)證書并自己修改 Nginx 配置。
imaginemiracle:~$ sudo certbot certonly --nginx按照屏幕提示操作即可。驗(yàn)證成功后,Certbot 會(huì)將證書文件保存在以主機(jī)名命名的目錄中 /etc/letsencrypt/live。對(duì)于主機(jī)名 www.imaginemiracle.com,文件存儲(chǔ)在/ etc/letsencrypt/live/www.imaginemiracle.com。
[注]:這里的 www.imaginemiracle.com,僅作為示例。
11.9. 啟用 Nginx 的 SSL 模塊 (可選)
如果你的 Nginx 不支持 SSL,你需要重新編譯它。使用以下命令。
imaginemiracle:~$ sudo ./configure --with-http_stub_status_module --with-http_ssl_module imaginemiracle:~$ sudo make && make install12. 開啟 WebDav
12.1. 修改 seafdav.conf 文件
在 seafile 的部署目錄下的 conf 目錄創(chuàng)建或?yàn)橐延械?seafdav.conf 配置文件添加入內(nèi)容。
[注]:若以本文的指導(dǎo)此目錄應(yīng)該為 /usr/local/seafile-pro-server/conf/seafdav.conf
12.2. 修改 nginx 配置文件
若以本文指導(dǎo)安裝的 Nginx,其配置文件目錄應(yīng)該為 /etc/nginx/sites-available/seafile.conf,其它伙伴可以根據(jù)自己的安裝目錄自行匹配。
為配置文件添加如下內(nèi)容:
12.3. 重啟 Nginx 和 Seafile 服務(wù)
重新加載 Nginx 配置
sudo nginx -s reload重啟 Seafile
./seafile.sh restart ./seafhub.sh restart12.4. 驗(yàn)證
Windwos 端:
可通過瀏覽器使用以配置的域名或 ip 訪問,訪問方式:
也可使用 Windows 資源管理器連接,但該方式僅支持非加密 HTTP 連接。因此,為了安全,唯一可行的選擇是使用第三方客戶端,例如 Cyber??duck 或 Bitkinex。
Linux 端:
在 Linux 上,有更多選擇。可以使用 Nautilus 等文件管理器連接到 webdav 服務(wù)器。
也可在終端命令行中使用 davfs2 打開。
在連接沒有任何報(bào)錯(cuò)后,則會(huì)正常的看到 mount 到的目錄下有了網(wǎng)盤上的內(nèi)容。
使用 sudo umount /media/seafdav 可取消掛載。
建議禁用 davfs2 的 LOCK 操作。編輯 /etc/davfs2/davfs2.conf
13. 開啟郵件服務(wù)
修改 seahub_settings.py 在其中添加如下內(nèi)容:
EMAIL_USE_TLS = True EMAIL_HOST = 'smtp-mail.outlook.com' # smpt server EMAIL_HOST_USER = 'imaginemiracle.wxn@outlook.com' # username and domain EMAIL_HOST_PASSWORD = '*******************' # password EMAIL_PORT = 587 DEFAULT_FROM_EMAIL = EMAIL_HOST_USER SERVER_EMAIL = EMAIL_HOST_USER這里的 EMAIL_HOST_PASSWORD 項(xiàng)需要填寫你的使用郵箱的密碼,為了保護(hù)隱私,筆者這里使用 * 代替。可以看到筆者使用的郵件服務(wù)器是 smtp-mail.outlook.com,他的指定端口是 587,若大家使用的是其它郵件服務(wù)器的話,對(duì)應(yīng)的端口有可能不同,可以在網(wǎng)絡(luò)上檢索一下對(duì)應(yīng)的服務(wù)器。
這里設(shè)置好后們需要開啟對(duì)應(yīng)端口的防火墻,然后重啟 seafile 即可。
14. 日常維護(hù)(數(shù)據(jù)備份)
在服務(wù)器端,Seafile 是通過一種內(nèi)部格式將文件存儲(chǔ)在資料庫(kù)中,并對(duì)于文件和目錄有其獨(dú)有的保存方式(類似于 Git)。默認(rèn)安裝下,這些內(nèi)部對(duì)象,會(huì)被直接存儲(chǔ)在服務(wù)器的文件系統(tǒng)中(例如 Ext4,NTFS)。文件在服務(wù)器上通過分塊存儲(chǔ),以支持大文件的斷點(diǎn)續(xù)傳和增量同步。
在服務(wù)器端可以使用 seaf-fuse.sh 直接將所有目錄掛載到本地目錄下,以普通目錄樹的方式訪問和備份,需要注意的是,此方法掛載的目錄只具有讀權(quán)限,即不可以直接修改目錄文件,只可備份。(加密文件不可使用此方法訪問)
進(jìn)入 seafile 安裝目錄,若如按照本文安裝,則進(jìn)入下面目錄即可。
seafile:~$ cd /usr/local/seafile-pro-server/seafile-server-latest seafile:seafile-server-latest$ ls check-db-type.py pro seaf-backup-cmd.py seafile-background-tasks.sh setup-seafile.sh check_init_admin.py remove-objs.py seaf-backup-cmd.sh seafile.sh sql index_op.py remove-objs.sh seaf-encrypt.sh seaf-import.sh start-seafile.sh migrate.py reset-admin.sh seaf-fsck.sh seahub tmp.log migrate-repo.py run_index_master.sh seaf-fuse.sh seahub.sh upgrade migrate-repo.sh run_index_worker.sh seaf-gc.sh setup-seafile-mysql.py migrate.sh runtime seafile setup-seafile-mysql.sh使用 seaf-fuse.sh 將所有文件掛載到本地目錄。
# 命令格式 ./seaf-fuse.sh start <path> seafile:seafile-server-latest$ ./seaf-fuse.sh start ~/drive-data/Starting seaf-fuse, please wait ... seaf-fuse startedDone.這個(gè)時(shí)候進(jìn)入掛載的目標(biāo)目錄即可看到對(duì)應(yīng)的所有用戶目錄。
卸載目錄命令。
seafile:seafile-server-latest$ ./seaf-fuse.sh stop14.1 如果出現(xiàn) “Permission denied” 的錯(cuò)誤
如果你運(yùn)行 ./seaf-fuse.sh start 時(shí),遇到 "Permission denied" 的錯(cuò)誤信息, 很有可能你沒有在 “fuse用戶組” 解決方法:
(1) 把你的用戶加到 fuse 組
sudo usermod -a -G fuse(2) 退出 shell 重新登陸
(3) 現(xiàn)在試著再一次執(zhí)行 ./seaf-fuse.sh start <path>
#15. 常見問題
以 # 開頭的章節(jié)代表的是該部分內(nèi)容不能算是正文部分,此部分內(nèi)容為附加章節(jié),一般用于提供針對(duì)文章中常常會(huì)出現(xiàn)的問題的一些解決辦法,或者分享筆者的一些啰嗦文字,以及對(duì)于參考的文章發(fā)出的感謝等內(nèi)容。
#15.1. 無法上傳/下載文件
通過以上的所有配置后,發(fā)現(xiàn)仍無法訪問 Web 網(wǎng)址或無法上傳/下載文件。那么需要做的事情有兩點(diǎn)。
(1). 確認(rèn)防火墻是否開放了設(shè)置的端口,若未開放則放開這幾個(gè)端口;(默認(rèn)的幾個(gè)需要放開的端口 8000、8082、3306)
防火墻設(shè)置命令參考:
(2). 檢查 seahub_settings.py 中的 SERVICE_URL 設(shè)置和 seafile 網(wǎng)頁(yè)中的 FILE_SERVER_ROOT 設(shè)置。
#15.2. 網(wǎng)頁(yè)中用戶頭像顯示異常
(1). 進(jìn)入 seafile 的安裝目錄
若是按照本文的安裝步驟安裝,則目錄位于 /usr/local/seafile-pro-server/seafile-server-latest/seahub/seahub/avatar/templatetags
若非本安裝教程安裝,則按此提示進(jìn)入,/自己的安裝目錄/seafile-server-latest/seahub/seahub/avatar/templatetags
(2). 編輯 avatar_tags.py 文件
(3). 修改如下兩部分
- return service_url + url, False, date_uploaded 修改為 return url, False, date_uploaded;
- return service_url + get_default_avatar_url(), True, None 修改為 return get_default_avatar_url(), True, None。
[注]:即刪掉 return 語(yǔ)句中的 service_url + 即可。
@cache_result def api_avatar_url(user, size=AVATAR_DEFAULT_SIZE):service_url = get_service_url()service_url = service_url.rstrip('/')# when store avatars in the media directoryif not AVATAR_FILE_STORAGE:# urlparse('https://192.157.12.3:89/demo')# ParseResult(scheme='https', netloc='192.157.12.3:89', path='/demo', params='', query='', fragment='')parse_result = urlparse(service_url)service_url = '%s://%s' % (parse_result[0], parse_result[1])avatar = get_primary_avatar(user, size=size)if avatar:url = avatar.avatar_url(size)date_uploaded = avatar.date_uploaded# /media/avatars/6/9/5011f01afac2a506b9544c5ce21a0a/resized/32/109af9901c0fd38ab39d018f5cd4baf6.png# 修改前# return service_url + url, False, date_uploaded# 修改后return url, False, date_uploadedelse:# /media/avatars/default.png# 修改前# return service_url + get_default_avatar_url(), True, None# 修改后return get_default_avatar_url(), True, None(4). 刪除系統(tǒng)緩存
imaginemiracle:~$ sudo rm -rf /tmp/seahub_cache/*(5). 重啟 Seafile 服務(wù)
seafile:seafile-server-latest$ ./seafile.sh restart # 啟動(dòng) Seafile 服務(wù) seafile:seafile-server-latest$ ./seahub.sh restart#15.3. 文件夾上傳數(shù)量限制
默認(rèn)的單次上傳文件夾數(shù)量為 1000。
如果這個(gè)數(shù)量也不能滿足你的話,那么打開 conf/seahub_settings.py 文件,并添加或修改項(xiàng) MAX_NUMBER_OF_FILES_FOR_FILEUPLOAD = 100000,修改并保存后,再重啟 seafile 服務(wù)即可。
此時(shí)刷新 web 端,再次上傳大數(shù)量文件夾則不會(huì)限制。
!0. “!” 說明
以 ! 開頭的章節(jié)代表著此章節(jié)具有一定的 “危險(xiǎn)性”(從各方面而言),更多的是提供給讀者用來學(xué)習(xí)參考。本文示例僅供學(xué)習(xí)使用,還請(qǐng)各位讀者切勿將所學(xué)技術(shù)于商業(yè)用途以及其它非法用途。本文里 ! 章節(jié)試圖去突破 Seafile 對(duì)于部署無 lincense 文件的服務(wù)器存在人數(shù)限制最大免費(fèi)注冊(cè)用戶數(shù)量為 3 個(gè)。
!1. Seafile 的 Python 部分
首先通過對(duì) seafile 文件的大致分析,其網(wǎng)頁(yè)端是使用 django 框架由 Python 語(yǔ)言開發(fā),而后端程序是由 C 實(shí)現(xiàn)的。
那么先看其 Python 部分代碼,通過搜查有關(guān) license 的文件。找到了前端檢測(cè) MaxUsers 用戶最大數(shù)的部分代碼,此段代碼會(huì)影響用戶的登錄、注冊(cè)等功能。
修改 ./seahub/seahub/utils/licenseparse.py 文件中的 MaxUsers,能改多大就改多大。
!2. C 部分
再看 C 部分,通過 IDA 軟件可以去查看二進(jìn)制文件,并將其反編譯為匯編代碼,若覺得匯編代碼還不好看的話,還可以進(jìn)一步將其反編譯為 C 的偽代碼形式,說是偽代碼,其實(shí)已經(jīng)和真實(shí)的代碼差不多了。
[注]:這里所說的偽代碼,實(shí)際上這類代碼有一個(gè)準(zhǔn)確的名稱叫做——中間代碼形式。
經(jīng)過對(duì) seafile.sh 啟動(dòng)腳本的分析,找到了啟動(dòng)時(shí)會(huì)執(zhí)行的幾個(gè)二進(jìn)制文件,并將其逐一使用 IDA 打開查看,查找有關(guān) license 部分的代碼,最終被定位到一個(gè)具體的二進(jìn)制文件里。
此處為了一定程度上保護(hù) Seafile 不被破解濫用,就不在這里說明具體的 文件 位置了。畢竟也是國(guó)產(chǎn)軟件,支持國(guó)產(chǎn)!
通過找到對(duì)應(yīng)二進(jìn)制文件的 main 函數(shù)開始閱讀代碼,很快就找到了于之相關(guān)的判斷。
其檢測(cè)部分的函數(shù)調(diào)用結(jié)構(gòu)很簡(jiǎn)單。如下:
簡(jiǎn)單分析以下這里的判斷,首先我們已經(jīng)可以明確兩點(diǎn):
- 第一,這個(gè)函數(shù)就是 License 的檢查函數(shù);
- 第二,這個(gè)函數(shù)會(huì)返回一個(gè)值用來判斷 License 是否檢測(cè)成功,若返回值小于 0 則表示不成功程序會(huì)直接退出。
查看 sub_9DE30(__int64 a1, unsigned int a2, time_t **a3, _DWORD *a4) 函數(shù)的定義。
if ( !(unsigned int)g_file_test(v7, 16LL) ){if ( a4 )*a4 = 3; // Address: 0009DE9Cg_log(0LL,16LL,"%s(%d): License file %s does not exist, allow at most %d trial users\n","../common/license.c",709LL,v7,3LL); // Address: 0009DEC8v8 = 0;__fprintf_chk(stdout, 1LL, "License file %s does not exist, allow at most %d trial users\n", v7, 3LL); // Address: 0009DEDBg_free(v7);goto LABEL_6;}很明顯的找到了判斷無 license 文件時(shí)的情況,可以看到這里有一個(gè)關(guān)鍵變量被賦值為 3,那么這個(gè)變量就是用來顯示用戶數(shù)量的關(guān)鍵點(diǎn)。雖然我們只用修改 a4 變量賦值的那一個(gè)地方既可,但為了更加明顯的判斷我們的修改是否有效,這里我們將出現(xiàn)的兩次打印中的 3 也修改一下。
轉(zhuǎn)回到匯編代碼,使用二進(jìn)制修改,這樣不容易出問題。建議不要嘗試使用其它方式修改,很容易導(dǎo)致崩潰無法運(yùn)行。具體做法:
修改:edit > Patch program > Change byte…
保存:edit > Patch program > Apply aptches to input file…
這里由于第二個(gè)地方的變量長(zhǎng)度只有 8 位,因此只能修改成最大整數(shù) 127,其余兩個(gè)修改為 0x1F40 十進(jìn)制的值為 8000。那么按照想法來說修改完后的用戶上限應(yīng)該為 8000。
修改完并保存后再反編譯為 C 語(yǔ)言再來查看,可以檢查是否修改成功以及是否影響其它代碼。事實(shí)證明這樣修改是沒有問題的,也不會(huì)影響到其它地方的代碼。
這段代碼最后有一條 goto 跳轉(zhuǎn)語(yǔ)句千萬不能忽視。goto LABEL_6;,我們看看 LABEL_6 是怎么寫的。
可以看出該函數(shù)最終的返回值為 result,該值會(huì)在返回之前使用 v8 變量的值對(duì)其賦值,雖然我們直接在二進(jìn)制中不容易修改變量名為整數(shù)值,但我們可以做的是將 v8 可能會(huì)被賦值為負(fù)值的地方改為正數(shù)即可,這樣為了保證不讓 main 函數(shù)退出而繼續(xù)執(zhí)行下去。也不用全部看只需要修改 LABEL_89 之后的所有便可。
LABEL_89 標(biāo)簽后一共存在四次對(duì) v8 變量的賦值。如下圖:
(1)&(2) v8 = -1;
(3) v8 = -1;
(4) v8 = -1;
四處的語(yǔ)句是一樣的,因此在匯編中看到的也是一樣的,這里只展示其中一個(gè),將其修改為 0 或者任意大于 0 的數(shù)均可。
對(duì)文件的修改已經(jīng)完成,現(xiàn)在重啟 seafile 服務(wù)測(cè)試。
成功啟動(dòng)就表示著已經(jīng)突破完成。我們現(xiàn)在已經(jīng)成功將沒有 license 的試用人數(shù)改為 8000 個(gè)用戶,與預(yù)期結(jié)果一樣,不用管上面顯示的 127,為什么呢?
還記得在修改變量值的時(shí)候,那個(gè) 127 只是一行輸出,是個(gè)無關(guān)緊要的值,無需關(guān)心它即可,重點(diǎn)只用看后面有無輸出,同時(shí)查看網(wǎng)頁(yè)端能否新加用戶。
這里筆者已經(jīng)測(cè)試了,現(xiàn)在已經(jīng)可以任意的添加用戶而不受限制。
!3. 再次聲明
請(qǐng)杜絕傳播破解軟件!
本文內(nèi)容僅供學(xué)習(xí),請(qǐng)勿用于商業(yè)用途以及其它非法用途。若按照本文教程學(xué)習(xí)并成功破解的讀者,請(qǐng)保護(hù)網(wǎng)絡(luò)環(huán)境和軟件環(huán)境,請(qǐng)勿以任意途徑分享破解文件或中間文件,否則全部法律責(zé)任將由文件分享者全部承擔(dān)。
如需商業(yè)用途請(qǐng)購(gòu)買正版,為國(guó)產(chǎn)軟件的助力!
#參考文章
(1) Seafile 管理員手冊(cè)
(2) 使用 Nginx 啟用 HTTPS
覺得這篇文章對(duì)你有幫助的話,就留下一個(gè)贊吧v*
請(qǐng)尊重作者,轉(zhuǎn)載還請(qǐng)注明出處!感謝配合~
[作者]: Imagine Miracle
[版權(quán)]: 本作品采用知識(shí)共享署名-非商業(yè)性-相同方式共享 4.0 國(guó)際許可協(xié)議進(jìn)行許可。
[本文鏈接]: https://blog.csdn.net/qq_36393978/article/details/125327701
總結(jié)
以上是生活随笔為你收集整理的Linux 上部署 Seafile 9.0.x 专业版(Seafile Server端)——踩一路坑,溅一身水的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 免费HTML5期末大作业:我的家乡网站设
- 下一篇: Linux搭建邮件服务器postfix