启动cloudreve
Cloudreve 在首次启动时,会创建初始管理员账号,请注意保管管理员密码,此密码只会在首次启动时出现。如果您忘记初始管理员密码,需要删除同级目录下的cloudreve.db
,重新启动主程序以初始化新的管理员账户。
Cloudreve 默认会监听5212
端口。你可以在浏览器中访问http://服务器IP:5212
进入 Cloudreve。
#解压获取到的主程序
tar -zxvf cloudreve_VERSION_OS_ARCH.tar.gz
# 赋予执行权限
chmod +x ./cloudreve
# 启动 Cloudreve
./cloudreve
启动HTTPS
openssl生成SSL证书
在cloudreve文件夹下输入:
生成私钥
openssl genrsa -out server.key 4096
生成证书请求
openssl req -new -key server.key -out server.csr
填写信息(可以直接回车不填)
颁发证书
使用server.key(私钥文件)和server.csr 文件生成新证书(.crt)
生成证书文件,输入下面命令:
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
使用证书
在conf.ini中添加
[SSL]
Listen = :443
CertPath = /server.crt路径
KeyPath = /server.key路径
使用 MySQL
默认情况下,Cloudreve 会使用内置的 SQLite 数据库,并在同级目录创建数据库文件cloudreve.db
,如果您想要使用 MySQL,请在配置文件中加入以下内容,并重启 Cloudreve。注意,Cloudreve 只支持大于或等于 5.7 版本的 MySQL 。
系统安装mysql
apt install mysql-server
进入mysql(默认root密码为空回车即可)
mysql -u root -p
默认的root账户我试了几次不成功,先在mysql创建一个cloudreve的用户,并创建一个cloudreve数据库提供给cloudreve服务使用
创建用户 CREATE USER 'cloudreve'@'localhost' IDENTIFIED BY 'password'; 创建数据库 CREATE DATABASE cloudreve CHARACTER SET utf8; 用户授权 GRANT ALL ON *.* TO 'cloudreve'@'localhost'; 刷新命令 FLUSH PRIVILEGES;
编辑conf.ini加入以下配置
[Database]
; 数据库类型,目前支持 sqlite/mysql/mssql/postgres
Type = mysql
; MySQL 端口
Port = 3306
; 用户名
User = cloudreve
; 密码
Password = password
; 数据库地址
Host = 127.0.0.1
; 数据库名称
Name = cloudreve
; 数据表前缀
TablePrefix = cd
; 字符集
Charset = utf8
;SQLite 数据库文件路径
DBFile = cloudreve.db
注意:更换数据库配置后,Cloudreve 会重新初始化数据库,原有的数据将会丢失。
添加后重启cloudreve
进程守护
# 编辑配置文件
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