2023-07-26 更新 78 阅读

1、前期准备(Linux为例)

①. 服务器
②. 域名
③. 域名证书

2、下载主程序

到 Cloudreve Github 站点,根据自己服务的架构下载相对应的主程序

点我去 Cloudreve Github 站点-link

3、安装 Cloudreve

#解压获取到的主程序
tar -zxvf cloudreve_VERSION_OS_ARCH.tar.gz

# 赋予执行权限
chmod +x ./cloudreve

# 启动 Cloudreve
./cloudreve

Cloudreve 在首次启动时,会创建初始管理员账号,请注意保管管理员密码,此密码只会在首次启动时出现。如果您忘记初始管理员密码,需要删除同级目录下的cloudreve.db,重新启动主程序以初始化新的管理员账户。
Cloudreve 默认会监听5212端口。你可以在浏览器中访问http://服务器IP:5212进入 Cloudreve。
以上步骤操作完后,最简单的部署就完成了。你可能需要一些更为具体的配置,才能让 Cloudreve 更好的工作,具体流程请参考下面的配置流程。

4、反向代理(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;
}

5、进程守护

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