使用 Docker 安装 Chevereto 图床

引用

https://juejin.cn/post/6857029114718355463

1.安装 Docker-Compose

apt install docker-compose

2.安装 mariaDb

docker pull mariadb

3.安装 chevereto

docker pull nmtan/chevereto

4.准备Docker Compose 文件

创建一个目录用于存放 docker-compose.yml 文件

mkdir chevereto
touch docker-compose.yml

文件内容如下,配置了依赖的 chevereto 以及 mariadb

version: '3'

services:
  db:
    image: mariadb
    container_name: chevereto-mysql
    # 挂载容器中的mysql数据卷到本地database文件夹
    volumes:
      - ./database:/var/lib/mysql:rw
    restart: always
    networks:
      - chevereto-net
    # 设置容器中的mysql的root用户密码以及其他用户
    environment:
      MYSQL_ROOT_PASSWORD: 123
      MYSQL_DATABASE: chevereto
      MYSQL_USER: chevereto
      MYSQL_PASSWORD: chevereto
    ports:
     - 9097:3306

  chevereto:
    depends_on:
      - db
    image: nmtan/chevereto
    container_name: chevereto
    restart: always
    networks:
      - chevereto-net
    # 设置CHEVERETO_DB的一些参数
    environment:
      CHEVERETO_DB_HOST: db
      CHEVERETO_DB_USERNAME: chevereto
      CHEVERETO_DB_PASSWORD: chevereto
      CHEVERETO_DB_NAME: chevereto
      CHEVERETO_DB_PREFIX: chv_
    # 挂载容器中的images文件夹到本地的chevereto_images文件夹,以及
    # 将本地的conf/upload.ini配置文件挂载到容器的/usr/local/etc/php/conf.d/中
    volumes:
      - ${PWD}/chevereto_images:/var/www/html/images:rw
      - ${PWD}/conf/upload.ini:/usr/local/etc/php/conf.d/upload.ini:rw
    # 端口映射,本机:容器,需要配置安全组
    ports:
      - 9099:80
networks:
  chevereto-net:
volumes:
  database:
  chevereto_images:

5.启动容器

docker-compose up -d

5.1.停止容器

docker-compose down

7.为 images 文件夹添加权限

进入 chevereto 运行中的容器,为 images 目录开放权限,此文件夹会被用于存放图片。chevereto 启动后如果提示其它目录无访问权限,也可依照此法进行修改。

docker exec -it chevereto /bin/bash
chmod 777 /var/www/html/images

8.修改图上上传大小限制

post_max_size = 100M
upload_max_filesize = 100M

9.nginx转发

server {
        listen [::]:443 ssl;
        listen 443 ssl;
        server_name _;
        client_max_body_size 100M;
        location / {
                proxy_pass http://127.0.0.1:9099;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Real-Port $remote_port;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header HTTP_X_FORWARDED_FOR $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $host;
                proxy_set_header X-NginX-Proxy true;

                proxy_redirect default;

                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }
}

10. 设置cheveteo 上传图片大小

url: /dashboard/settings/image-upload

dashboard > settings > image-upload > Maximum upload file size [MB]
dashboard > settings > image-upload > Maximum upload file size (guests)

评论

还没有人评论,抢个沙发吧...

Viagle Blog

欢迎来到我的个人博客网站