Cloudreve網盤搭建


Cloudreve網盤搭建

Cloudreve簡單簡潔的一個網盤,個人使用足夠了,沒有nextcloud那么復雜和龐大。

環境:
Centos 8
nginx(用作代理)
寶塔面板(方便部署)

下載源碼

地址:https://github.com/cloudreve/Cloudreve/releases

簡單安裝

使用GO語言重構之后解壓完成之后只有一個cloudreve二進制啟動文件
上傳到網站根目錄並解壓

./cloudreve執行,出現下面提示表示成功運行了。會出現默認賬號和密碼以及監聽端口,默認是5212.

[root@centos8 cloudreve]# ./cloudreve 

   ___ _                 _                    
  / __\ | ___  _   _  __| |_ __ _____   _____ 
 / /  | |/ _ \| | | |/ _ | '__/ _ \ \ / / _ \
/ /___| | (_) | |_| | (_| | | |  __/\ V /  __/
\____/|_|\___/ \__,_|\__,_|_|  \___| \_/ \___|

   V3.2.1  Commit #3b22b4f  Pro=false
================================================

[Info]    2021-04-21 19:49:21 初始化數據庫連接
[Info]    2021-04-21 19:49:21 開始進行數據庫初始化...
[Info]    2021-04-21 19:49:22 初始管理員賬號:admin@cloudreve.org
[Info]    2021-04-21 19:49:22 初始管理員密碼:BnAc9TkN
[Info]    2021-04-21 19:49:22 數據庫初始化結束
[Info]    2021-04-21 19:49:22 初始化任務隊列,WorkerNum = 10
[Info]    2021-04-21 19:49:22 初始化定時任務...
[Info]    2021-04-21 19:49:22 當前運行模式:Master
[Info]    2021-04-21 19:49:22 開始監聽 :5212
[Info]    2021-04-21 19:49:24 有新的版本 [3.3.1] 可用,下載:https://github.com/cloudreve/Cloudreve/releases/tag/3.3.1

開啟防火牆和雲服務器的安全組5212端口。
瀏覽器登錄。
http://ip:5212
輸入剛剛的賬號密碼進去之后再修改密碼。

利用nginx反向代理

因為cloudreve默認不是使用nginx等web服務器的,應該是內置的那種。
使用寶塔或者命令行建立一個網站,修改網站的配置文件,代理本機的5212服務。
如下配置:

location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://127.0.0.1:5212;

    # 如果您要使用本地存儲策略,請將下一行注釋符刪除,並更改大小為理論最大文件尺寸
    # client_max_body_size 20000m;
}

高級功能配置

添加參數啟動

./cloudreve -c /path/to/conf.ini  # 指定配置文件

默認采用sqsli,如果需要配置使用mysql需修改配置文件

conf.ini

在后面添加如下配置

[Database]
; 數據庫類型,目前支持 sqlite | mysql
Type = mysql
; MySQL 端口
Port = 3306
; 用戶名
User = cloudreve
; 密碼
Password = cloudreve
; 數據庫地址
Host = 127.0.0.1
; 數據庫名稱
Name = cloudreve
; 數據表前綴
TablePrefix = cd

配置redis

如果需要配置redis緩存,在后面添加如下內容。

[Redis]
Server = 127.0.0.1:6379
Password = 
DB = 1

管理員密碼

使用nginx代理cloudreve,添加mysql,redis,ssl證書在nginx配置

忘記密碼或者無法登錄解決方法。

將cloudreve數據庫刪除,使用./cloudreve -c conf.ini重寫數據庫,出現默認用戶密碼,登錄進去再進行修改

重置管理員密碼

./cloudreve --database-script ResetAdminPassword

配置ssl證書,在nginx中配置

在網站配置中配置ssl證書和密鑰路以及端口。

systemctl進程

創建文件
vim /usr/lib/systemd/system/cloudreve.service

[Unit]
Description=Cloudreve
Documentation=https://docs.cloudreve.org
After=network.target
After=mysqld.service
Wants=network.target

[Service]
WorkingDirectory=/PATH_TO_CLOUDREVE
ExecStart=/PATH_TO_CLOUDREVE/cloudreve
Restart=on-abnormal
RestartSec=5s
KillMode=mixed

StandardOutput=null
StandardError=syslog

[Install]
WantedBy=multi-user.target

使用systemctl管理進程
systemctl start cloudreve #啟動進程
systemctl stop cloudreve #停止進程
systemctl enable cloudreve #開機啟動進程

完整配置示例參考

[System]
; 運行模式
Mode = master
; 監聽端口
Listen = :5000
; 是否開啟 Debug
Debug = false
; Session 密鑰, 一般在首次啟動時自動生成
SessionSecret = 23333
; Hash 加鹽, 一般在首次啟動時自動生成
HashIDSalt = something really hard to guss

; SSL 相關
[SSL]
; SSL 監聽端口
Listen = :443
; 證書路徑
CertPath = C:\Users\i\Documents\fullchain.pem
; 私鑰路徑
KeyPath = C:\Users\i\Documents\privkey.pem

; 啟用 Unix Socket 監聽
[UnixSocket]
Listen = /run/cloudreve/cloudreve.sock

; 數據庫相關,如果你只想使用內置的 SQLite數據庫,這一部分直接刪去即可
[Database]
; 數據庫類型,目前支持 sqlite | mysql
Type = mysql
; MySQL 端口
Port = 3306
; 用戶名
User = root
; 密碼
Password = root
; 數據庫地址
Host = 127.0.0.1
; 數據庫名稱
Name = v3
; 數據表前綴
TablePrefix = cd_
; SQLite 數據庫文件路徑
DBFile = cloudreve.db

; 從機模式下的配置
[Slave]
; 通信密鑰
Secret = 1234567891234567123456789123456712345678912345671234567891234567
; 回調請求超時時間 (s)
CallbackTimeout = 20
; 簽名有效期
SignatureTTL = 60

; 跨域配置
[CORS]
AllowOrigins = *
AllowMethods = OPTIONS,GET,POST
AllowHeaders = *
AllowCredentials = false

; Redis 相關
[Redis]
Server = 127.0.0.1:6379
Password =
DB = 0

; 從機模式縮略圖
[Thumbnail]
MaxWidth = 400
MaxHeight = 300
FileSuffix = ._thumb

問題

如果遇到使用反向代理之后上傳大文件卡在處理的問題,修改nginx的性能調整,最大上傳大小。


免責聲明!

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



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