抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

Chevereto是目前最好的图床之一功能也非常强大且支持中文。
使用WebServer部署方式的文档参考以上官方和中文文档 本文着重记录使用Docker来部署

-w1403

Chevereto有免费开源版与付费版,在活动的时候购买也是非常划算的。
-w1064

免费版和收费版的区别主要是:
收费版多了硬盘扩展,社交分享功能和及时的技术支持。

硬盘扩展指的是你可以通过sftp等方式把上传的文件储存在其他服务器上。

官方文档 https://v3-docs.chevereto.com/
中文文档 https://docs.doge.uk/zh/chevereto/

Dcoker安装

部署要求: Docker、MySQL 8/MariaDB 10
使用 Docker 安装
Docker 可以让你轻松安装软件的容器版本

👏🏾 所有的Docker镜像都是 第三方用户提供

列举比较热门的镜像

  • linuxserver/chevereto
  • nmtan/chevereto
  • zaywalker/chevereto
  • einverne/chevereto

本文使用Dcoker nmtan/chevereto 镜像来部署
DockerHub地址 https://hub.docker.com/r/nmtan/chevereto/

(1)准备数据库

数据库建议实机安装,备选Dcoker数据库;
建立数据库chevereto 并授权相应用户
例:

类型
数据库名称 chevereto
chevereto数据库用户 chevereto
chevereto数据库用户密码 Password

(2)拉取并启动镜像

在已安装Docker的服务器上输入命令:

1
docker pull nmtan/chevereto

nmtan/chevereto启动命令:

1
2
3
4
5
6
7
8
9
10
docker run -it --name chevereto -d \
-p 80:80 \
-v "$PWD/images":/var/www/html/images \
-e "CHEVERETO_DB_HOST=db" \
-e "CHEVERETO_DB_USERNAME=chevereto" \
-e "CHEVERETO_DB_PASSWORD=Password" \
-e "CHEVERETO_DB_NAME=chevereto" \
-e "CHEVERETO_DB_PREFIX=chv_" \
--restart=always \
nmtan/chevereto

如使用Docker数据库则加入--link mysql:mysql \ 来连接数据库
其中$PWD/images需要改为宿主机目标存储位置

这时,访问宿主机80端口 就进入管理员设置。

为进入生产环境再进行准备

这就进行生产了?
答案并不是,这样的部署面临几个问题:

  1. chevereto在Docker环境里 无法获取访问用户的真实IP
  2. php.ini最大上传限制为2MB
  3. 没有SSL证书 不能HTTPS加密访问

本文记录时 为nmtan/chevereto:1.1.4版本,如版本差异大需要进行相应的路径确认。
查询得知使用Apache2作为WebServer且是有mod_remoteip模块的,只需要开启和加入相应的配置即可获得访问用户的真实IP

1). 删除原容器

1
2
docker stop chevereto
docker rm chevereto

2). 准备本地配置文件

创建宿主配置目录

1
mkdir -p /chevereto/config

php.ini配置
1
2
3
4
5
sudo tee /chevereto/config/fileup.ini <<-'EOF'
upload_max_filesize = 8M
post_max_size = 64M
memory_limit = 256M
EOF

mod_remoteip配置

1
2
3
4
5
sudo tee /chevereto/config/httpd-remoteip.conf <<-'EOF'
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 172.17.0.1/16 127.0.0.1/32
EOF

其中172.17.0.1/16为Docker网段,按需正确配置

3). 部署Docker

图片数据存储位置

1
mkdir -p /chevereto/images

1
2
3
4
5
6
7
8
9
10
11
12
docker run -it --name chevereto -d \
-p 80:80 \
-v /chevereto/images:/var/www/html/images \
-v /chevereto/config/fileup.ini:/usr/local/etc/php/conf.d/fileup.ini \
-v /chevereto/config/httpd-remoteip.conf:/etc/aoache2/conf-enabled/httpd-remoteip.conf \
-e "CHEVERETO_DB_HOST=db" \
-e "CHEVERETO_DB_USERNAME=chevereto" \
-e "CHEVERETO_DB_PASSWORD=Password" \
-e "CHEVERETO_DB_NAME=chevereto" \
-e "CHEVERETO_DB_PREFIX=chv_" \
--restart=always \
nmtan/chevereto

登陆到chevereto容器

1
docker exec -it chevereto /bin/bash

确认登陆后
输入命令

1
sudo a2enmod remoteip

mod_remoteip模块成功开启

这时候,最大单个文件上传限制为8MB 可同时上传8个线程
访问IP已正确

3). HTTPS访问

拉取Nginx进行反代即可

评论