🌥️ Cloudreve 部署笔记(基于 Ubuntu + Nginx + MariaDB)

📌 系统环境

  • 操作系统:Ubuntu
  • 部署方式:二进制 + Systemd 管理服务
  • Web 服务器:Nginx(通过宝塔或手动安装)
  • 数据库:MariaDB
  • 域名yun.luoxingding.com
  • SSL:手动配置 /etc/nginx/ssl/luoxingding.com/{cert.pem, key.pem}

1️⃣ 下载 Cloudreve 并配置运行目录

mkdir -p /www/wwwroot/yun.luoxingding.com
cd /www/wwwroot/yun.luoxingding.com
 
# 上传 cloudreve 可执行文件并赋权
chmod +x cloudreve

2️⃣ 配置数据库

🔹 创建数据库和用户

CREATE DATABASE cloudreve DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'Cloudreve'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON cloudreve.* TO 'Cloudreve'@'localhost';
FLUSH PRIVILEGES;

⚠️ 注意数据库名为小写 cloudreve,用户名为 Cloudreve


3️⃣ 编辑配置文件 conf.ini

路径:/www/wwwroot/yun.luoxingding.com/data/conf.ini

[System]
Mode = master
Listen = 127.0.0.1:5212
Debug = false
LogLevel = info
 
[Database]
Type = mysql
Port = 3306
User = Cloudreve
Password = yourpassword
Host = 127.0.0.1
Name = cloudreve
Charset = utf8mb4
 
[UnixSocket]
Listen = 
 
[CORS]
AllowOrigins = *
AllowMethods = OPTIONS,GET,POST
AllowHeaders = *
AllowCredentials = false

4️⃣ 配置 Systemd 服务

路径:/etc/systemd/system/cloudreve.service

[Unit]
Description=Cloudreve
Documentation=https://docs.cloudreve.org
After=network.target
Wants=network.target
 
[Service]
WorkingDirectory=/www/wwwroot/yun.luoxingding.com
ExecStart=/www/wwwroot/yun.luoxingding.com/cloudreve
Restart=on-failure
RestartSec=5s
KillMode=mixed
User=www
Group=www
 
StandardOutput=syslog
StandardError=syslog
 
[Install]
WantedBy=multi-user.target

启动服务

systemctl daemon-reload
systemctl enable cloudreve
systemctl start cloudreve

5️⃣ 配置 Nginx 反向代理

路径:/etc/nginx/conf.d/yun.luoxingding.com.conf

server {
    listen 80;
    server_name yun.luoxingding.com;
    return 301 https://$host$request_uri;
}
 
server {
    listen 443 ssl;
    server_name yun.luoxingding.com;
 
    ssl_certificate /etc/nginx/ssl/luoxingding.com/cert.pem;
    ssl_certificate_key /etc/nginx/ssl/luoxingding.com/key.pem;
 
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers HIGH:!aNULL:!MD5;
 
    location / {
        proxy_pass http://127.0.0.1:5212;
        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-Proto $scheme;
 
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

重启 Nginx

nginx -t && systemctl reload nginx

6️⃣ 防火墙安全

ufw delete allow 5212

✅ 验证部署成功

打开浏览器访问:

https://yun.luoxingding.com

确认 Cloudreve 登录页面正常显示即部署完成。


📎 补充建议

  • 若使用 Cloudreve Pro,请设置授权密钥:
    在 Systemd 配置中添加 Environment="CR_LICENSE_KEY=xxx"

  • 可配置对象存储后端(如 MinIO、阿里云 OSS、腾讯云 COS)

  • 可加入反向代理缓存、加密网盘等进阶功能