VPS 部署系统为 Ubuntu 20.04
Cloudreve:官方文档 ; Github 项目地址
Cloudreve 3.8.x
版本部分功能不会提供完整 URL,仅提供路径,外置播放器、Aria2 离线下载 torrent 功能有问题,推荐切换到 3.7.1
版本使用
# 安装 Cloudreve
下载安装包到想安装的目录,如 /home/cloudreve
#解压获取到的主程序 | |
tar -zxvf cloudreve_VERSION_OS_ARCH.tar.gz | |
# 赋予执行权限 | |
chmod +x ./cloudreve | |
# 启动 Cloudreve | |
./cloudreve |
Cloudreve 在首次启动时,会创建初始管理员账号,请注意保管管理员密码,此密码只会在首次启动时出现。如果您忘记初始管理员密码,需要删除同级目录下的 cloudreve.db
,重新启动主程序以初始化新的管理员账户。
Cloudreve 默认会监听 5212
端口。你可以在浏览器中访问 http://服务器IP:5212
进入 Cloudreve。进入后可修改用户名、邮箱、密码等信息。
# 进程守护
使用 Systemd
# 编辑配置文件 | |
vim /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 |
# 反向代理及配置 SSL 证书
在自用或者小规模使用的场景下,你完全可以使用 Cloudreve 内置的 Web 服务器。但是如果你需要使用 HTTPS,亦或是需要与服务器上其他 Web 服务共存时,你可能需要使用主流 Web 服务器反向代理 Cloudreve ,以获得更丰富的扩展功能。
你需要在 Web 服务器中新建一个虚拟主机,完成所需的各项配置(如启用 HTTPS),然后在网站配置文件中加入反代规则。
在网站的 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; | |
} |
可同时在 server 中添加 SSL 证书
申请 SSL 证书方式请见:申请 Let’s Encrypt 证书
sever 配置样例:
server { | |
server_name YOUR_DOMAIN_NAME; | |
listen 80; | |
listen 443 ssl; | |
if ($scheme != https) { | |
rewrite ^/(.*) https://$server_name/$1 permanent; | |
} | |
if ($http_x_forwarded_proto = "http") { | |
return 301 https://$server_name$request_uri; | |
} | |
ssl_certificate /etc/letsencrypt/live/YOUR_DOMAIN_NAME/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/YOUR_DOMAIN_NAME/privkey.pem; | |
ssl_session_timeout 5m; | |
ssl_ciphers HIGH:!aNULL:!MD5:!kEDH; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; | |
add_header Strict-Transport-Security "max-age=31536000"; | |
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 50000m; | |
} | |
} |
配置好后重启 Nginx
systemctl reload nginx |
# 配置 Aria2 离线下载
Aria2 安装脚本:
wget -N git.io/aria2.sh && chmod +x aria2.sh |
启动脚本
./aria2.sh |
使用脚本 启用RPC服务
,查看 RPC 授权令牌
和 监听端口
和 下载目录
,如下
# 启用 RPC 服务 | |
enable-rpc=true | |
# RPC 监听端口 | |
rpc-listen-port= | |
# RPC 授权令牌,可自行设定 | |
rpc-secret= | |
#下载目录 | |
下载目录: |
打开 Cloudreve管理面板
的 离线下载节点
进行配置:
RPC 服务器地址: http://127.0.0.1:6800/
,其他信息见上。配置完后测试 Aria2 通信,完成。
# 修改 Cloudreve 网页图标 Logo
- 首先停止 Cloudreve 的运行
# 停止服务 | |
systemctl stop cloudreve |
- 在 Cloudreve 文件根目录执行命令,释放出静态资源
./cloudreve -eject |
进入
\statics\static\img
替换favicon.ico
、logo192.png
、logo512.png
文件启动 Cloudreve 进入网站,刷新缓存
# 启动服务 | |
systemctl start cloudreve |