Cloudeve
- 特性:
☁️ 支持本机、从机、七牛、阿里云 OSS、腾讯云 COS、又拍云、OneDrive (包括世纪互联版) 、S3兼容协议 作为存储端
📤 上传/下载 支持客户端直传,支持下载限速
💾 可对接 Aria2 离线下载,可使用多个从机节点分担下载任务
📚 在线 压缩/解压缩、多文件打包下载
💻 覆盖全部存储策略的 WebDAV 协议支持
⚡ 拖拽上传、目录上传、流式上传处理
🗃️ 文件拖拽管理
👩👧👦 多用户、用户组、多存储策略
🔗 创建文件、目录的分享链接,可设定自动过期
👁️🗨️ 视频、图像、音频、 ePub 在线预览,文本、Office 文档在线编辑
🎨 自定义配色、黑暗模式、PWA 应用、全站单页应用、国际化支持
🚀 All-In-One 打包,开箱即用
本地安装部署
使用环境Ubuntu2404-server
tar -xf cloudreve_3.8.3_linux_amd64.tar.gz
chmod +x ./cloudreve
首次启动时,Cloudreve 会在同级目录下创建名为conf.ini的配置文件,可以修改此文件进行一些参数的配置,保存后需要重新启动 Cloudreve 生效。或者可以在启动时加入-c参数指定配置文件路径
./cloudreve -c /path/to/conf.ini
完整的配置文件示例如下
[System]
; 运行模式
Mode = master
; 监听端口
Listen = :5212
; 是否开启 Debug
Debug = false
; Session 密钥, 一般在首次启动时自动生成
SessionSecret = 23333
; Hash 加盐, 一般在首次启动时自动生成
HashIDSalt = something really hard to guss
; 呈递客户端 IP 时使用的 Header
ProxyHeader = X-Forwarded-For
; 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
; 设置产生的 socket 文件的权限
Perm = 0666
; 数据库相关,如果你只想使用内置的 SQLite 数据库,这一部分直接删去即可
[Database]
; 数据库类型,目前支持 sqlite/mysql/mssql/postgres
Type = mysql
; MySQL 端口
Port = 3306
; 用户名
User = root
; 密码
Password = root
; 数据库地址
Host = 127.0.0.1
; 数据库名称
Name = v3
; 数据表前缀
TablePrefix = cd_
; 字符集
Charset = utf8mb4
; SQLite 数据库文件路径
DBFile = cloudreve.db
; 进程退出前安全关闭数据库连接的缓冲时间
GracePeriod = 30
; 使用 Unix Socket 连接到数据库
UnixSocket = false
; 从机模式下的配置
[Slave]
; 通信密钥
Secret = 1234567891234567123456789123456712345678912345671234567891234567
; 回调请求超时时间 (s)
CallbackTimeout = 20
; 签名有效期
SignatureTTL = 60
; 跨域配置
[CORS]
AllowOrigins = *
AllowMethods = OPTIONS,GET,POST
AllowHeaders = *
AllowCredentials = false
SameSite = Default
Secure = lse
; Redis 相关
[Redis]
Server = 127.0.0.1:6379
Password =
DB = 0
; 从机配置覆盖
[OptionOverwrite]
; 可直接使用 `设置名称 = 值` 的格式覆盖
max_worker_num = 50
这里使用默认启动
./cloudreve
root@huhy:~# ./cloudreve
___ _ _
/ __\ | ___ _ _ __| |_ __ _____ _____
/ / | |/ _ \| | | |/ _ | '__/ _ \ \ / / _ \
/ /___| | (_) | |_| | (_| | | | __/\ V / __/
\____/|_|\___/ \__,_|\__,_|_| \___| \_/ \___|
V3.8.3 Commit #88409cc Pro=false
================================================
[Info] 2024-08-27 01:23:25 Initializing database connection...
[Info] 2024-08-27 01:23:25 Start initializing database schema...
[Info] 2024-08-27 01:23:25 Admin user name: admin@cloudreve.org
[Info] 2024-08-27 01:23:25 Admin password: 0Sw7Myff
[Info] 2024-08-27 01:23:25 Start executing database script "UpgradeTo3.4.0".
[Info] 2024-08-27 01:23:25 Finish initializing database schema.
[Info] 2024-08-27 01:23:25 Initialize task queue with WorkerNum = 10
[Info] 2024-08-27 01:23:25 Initialize crontab jobs...
[Info] 2024-08-27 01:23:25 Current running mode: Master.
[Info] 2024-08-27 01:23:25 Listening to ":5212"
界面IP登录:IP:5212
用户名和密码在脚本执行后初始化信息可查看 admin@cloudreve.org / 0Sw7Myff
启动后会同级目录生成几个配置文件
-
uploads
存放网盘的文件目录 -
cloudreve.db
数据库缓存 -
conf.ini
初始化主配文件信息
配置反向代理
可选参数;
在自用或者小规模使用的场景下,你完全可以使用 Cloudreve 内置的 Web 服务器。但是如果你需要使用 HTTPS,亦或是需要与服务器上其他 Web 服务共存时,你可能需要使用主流 Web 服务器反向代理 Cloudreve ,以获得更丰富的扩展功能。
nginx配置;在网站的server字段中加入:
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;
}
apache配置;在VirtualHost字段下加入反代配置项ProxyPass,比如:
<VirtualHost *:80>
ServerName myapp.example.com
ServerAdmin webmaster@example.com
DocumentRoot /www/myapp/public
# 以下为关键部分
AllowEncodedSlashes NoDecode
ProxyPass "/" "http://127.0.0.1:5212/" nocanon
</VirtualHost>
配置进程守护
编辑配置文件
vi /usr/lib/systemd/system/cloudreve.service
将下文 PATH_TO_CLOUDREVE 更换为程序所在目录
[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 daemon-reload
# 启动服务
systemctl start cloudreve
# 设置开机启动
systemctl enable cloudreve
# 启动服务
systemctl start cloudreve
# 停止服务
systemctl stop cloudreve
# 重启服务
systemctl restart cloudreve
# 查看状态
systemctl status cloudreve
[root@localhost ~]# systemctl enable cloudreve
Created symlink from /etc/systemd/system/multi-user.target.wants/cloudreve.service to /usr/lib/systemd/system/cloudreve.service.
[root@localhost ~]# systemctl start cloudreve
[root@localhost ~]# systemctl status cloudreve
● cloudreve.service - Cloudreve
Loaded: loaded (/usr/lib/systemd/system/cloudreve.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2024-09-21 03:35:47 EDT; 4s ago
Docs: https://docs.cloudreve.org
Main PID: 12421 (cloudreve)
CGroup: /system.slice/cloudreve.service
└─12421 /root/cloudreve
Sep 21 03:35:47 localhost.localdomain systemd[1]: Started Cloudreve.
[root@localhost ~]#
如果忘记密码了!可重置
[root@localhost ~]# ./cloudreve --database-script ResetAdminPassword
___ _ _
/ __\ | ___ _ _ __| |_ __ _____ _____
/ / | |/ _ \| | | |/ _ | '__/ _ \ \ / / _ \
/ /___| | (_) | |_| | (_| | | | __/\ V / __/
\____/|_|\___/ \__,_|\__,_|_| \___| \_/ \___|
V3.8.3 Commit #88409cc Pro=false
================================================
[Info] 2024-09-21 04:05:46 Initializing database connection...
[Info] 2024-09-21 04:05:46 Database version fulfilled, skip schema migration.
[Info] 2024-09-21 04:05:46 Initialize task queue with WorkerNum = 10
[Info] 2024-09-21 04:05:46 Initialize crontab jobs...
[Info] 2024-09-21 04:05:46 Start executing database script "ResetAdminPassword".
[Info] 2024-09-21 04:05:46 Initial admin user password changed to:sumqIqvO
[Info] 2024-09-21 04:05:46 Finish executing database script "ResetAdminPassword".
校准用户容量
如果因为系统故障、手动操作数据库记录导致用户已用空间与实际不符时,你可以运行以下数据库脚本,Cloudreve 会重新校准所有已注册用户的容量使用。
./cloudreve --database-script CalibrateUserStorage
使用docker部署
使用环境Ubuntu2404
请确保运行之前:
-
手动创建 conf.ini 空文件或者符合 Cloudreve 配置文件规范的 conf.ini, 并将 <path_to_your_config> 替换为该路径
-
手动创建 cloudreve.db 空文件, 并将 <path_to_your_db> 替换为该路径
-
手动创建 uploads 文件夹, 并将 <path_to_your_uploads> 替换为该路径
-
手动创建 avatar 文件夹,并将 <path_to_your_avatar> 替换为该路径
运行 docker container:注意替换路径
docker run -d \
-p 5212:5212 \
--mount type=bind,source=<path_to_your_config>,target=/cloudreve/conf.ini \
--mount type=bind,source=<path_to_your_db>,target=/cloudreve/cloudreve.db \
-v <path_to_your_uploads>:/cloudreve/uploads \
-v <path_to_your_avatar>:/cloudreve/avatar \
cloudreve/cloudreve:latest
安装docker
apt -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt-get -y install docker-ce
systemctl enable --now docker
opt下创建相关的文件和文件夹
mkdir -p /opt/cloudreve/uploads
mkdir /opt/cloudreve/avatar
touch /opt/cloudreve/conf.ini
touch /opt/cloudreve/cloudreve.db
这个镜像拉取需要先禁用ipv6拉取
cat /etc/docker/daemon.json
{
"ipv6": false
}
systemctl daemon-reload
systemctl restart docker
docker pull cloudreve/cloudreve:latest
root@huhy~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cloudreve/cloudreve latest 328970d33c60 11 months ago 108MB
运行 Docker 容器
docker run -d \
-p 5212:5212 \
--mount type=bind,source=/opt/cloudreve/conf.ini,target=/cloudreve/conf.ini \
--mount type=bind,source=/opt/cloudreve/cloudreve.db,target=/cloudreve/cloudreve.db \
-v /opt/cloudreve/uploads:/cloudreve/uploads \
-v /opt/cloudreve/avatar:/cloudreve/avatar \
cloudreve/cloudreve:latest