国外开源客服系统chathoot部署,使用教程

发布于:2025-06-27 ⋅ 阅读:(14) ⋅ 点赞:(0)

目录

一、系统版本要求:

二、部署步骤

2.1 安装docker 和docker-compose

2.2 准备docker-compose.yaml

2.3 初始化数据库

2.4 安装nginx

2.6 启动项目

三、使用教程


一、系统版本要求:

  • linux ubuntu 22.04+
  • 2核4G 40GB(或以上)
  • 公网ip一个
  • 端口白名单:80、443(0.0.0.0/0)

二、部署步骤

2.1 安装docker 和docker-compose

apt update && apt install docker.io -y
wget https://github.com/docker/compose/releases/download/v2.30.1/docker-compose-linux-x86_64
mv docker-compose-linux-x86_64 docker-compose && chmod +x ./docker-compose && mv ./docker-compose /usr/bin/

2.2 准备docker-compose.yaml

mkdir /data/chatwoot
vim /data/chatwoot/docker-compose.yaml

将下面配置文件复制到/docker-compose.yaml

version: '3'

services:
  base: &base
    image: chatwoot:latest
    env_file: .env ## Change this file for customized env variables
    volumes:
      - storage_data:/app/storage

  rails:
    <<: *base
    depends_on:
      - postgres
      - redis
    ports:
      - '127.0.0.1:3000:3000'
    environment:
      - NODE_ENV=production
      - RAILS_ENV=production
      - INSTALLATION_ENV=docker
    entrypoint: docker/entrypoints/rails.sh
    command: ['bundle', 'exec', 'rails', 's', '-p', '3000', '-b', '0.0.0.0']
    restart: always

  sidekiq:
    <<: *base
    depends_on:
      - postgres
      - redis
    environment:
      - NODE_ENV=production
      - RAILS_ENV=production
      - INSTALLATION_ENV=docker
    command: ['bundle', 'exec', 'sidekiq', '-C', 'config/sidekiq.yml']
    restart: always

  postgres:
    image: pgvector:pg16
    restart: always
    ports:
      - '0.0.0.0:5432:5432'
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=chatwoot
      - POSTGRES_USER=postgres
      # Please provide your own password.
      - POSTGRES_PASSWORD=qishuo&_123

  redis:
    image: redis:alpine
    restart: always
    command: ["sh", "-c", "redis-server --requirepass \"$REDIS_PASSWORD\""]
    env_file: .env
    volumes:
      - redis_data:/data
    ports:
      - '127.0.0.1:6379:6379'

volumes:
  storage_data:
  postgres_data:
  redis_data:

 如果国内下载失败,可以尝试使用阿里、清华源

docker-compose up -d

2.3 初始化数据库

注意,容器名可能不叫chatwoot-rails-1,docker ps查看容器名确认后执行

 docker-compose run --rm chatwoot-rails-1 bundle exec rails db:chatwoot_prepare

2.4 安装nginx

目的是暴露到外网

apt install nginx

配置下面的nginx文件,注意修改server_name xxxx 为自己的域名

vim /etc/nginx/conf.d/chatwoot.conf

server {
  server_name xxxx;

  # Point upstream to Chatwoot App Server
  set $upstream 127.0.0.1:3000;

  # Nginx strips out underscore in headers by default
  # Chatwoot relies on underscore in headers for API
  # Make sure that the config is set to on.
  underscores_in_headers on;
  location /.well-known {
    alias /var/www/ssl-proof/chatwoot/.well-known;
  }

  location / {
    proxy_pass_header Authorization;
    proxy_pass http://$upstream;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Ssl on; # Optional

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_http_version 1.1;
    proxy_buffering off;

    client_max_body_size 0;
    proxy_read_timeout 36000s;
    proxy_redirect off;
  }
  listen 80;
}

加载nginx配置

nginx -t && nginx -s reload

配置证书,最后一步需要填写你自己的域名

apt install certbot
apt-get install python3-certbot-nginx
mkdir -p /var/www/ssl-proof/chatwoot/.well-known
certbot --webroot -w /var/www/ssl-proof/chatwoot -d 你的域名 -i nginx

2.6 启动项目

访问域名 https://你的域名

三、使用教程

待更新


网站公告

今日签到

点亮在社区的每一天
去签到