更新升级 专属应用 系统故障 硬件故障 电脑汽车 鸿蒙刷机 鸿蒙开发Linux教程 鸿蒙开发Linux命令
当前位置:HMXT之家 > 鸿蒙开发Linux教程 > 在Ubuntu 20.04上安装和配置Chatwoot的方法

在Ubuntu 20.04上安装和配置Chatwoot的方法

更新时间:2022-12-25 16:05:33浏览次数:539+次

本文介绍在Ubuntu 20.04 Linux系统上安装和配置Chatwoot的方法,可以使用Let's Encrypt SSL在Ubuntu 20.04上安装Chatwoot。Chatwoot是用于实时消息传递渠道的客户支持工具,这可以帮助企业通过社交媒体渠道为客户提供良好的客户支持。

在Ubuntu 20.04上安装Chatwoot

我们将介绍如何使用Let's Encrypt在Ubuntu 20.04上安装自托管的Chatwoot实时聊天服务器。

在开始安装之前,请注意以下要求:

Ubuntu 20.04 LTS服务器,升级了所有软件包。

Nginx服务器安装。

Let's Encrypt的Certbot。

FQDN–完全限定的域名。

使用以下步骤在Ubuntu 20.04主机上安装功能齐全的Chatwoot服务器。

步骤1、下载安装脚本

在您的终端中,运行以下命令下载将用于安装chatwot的脚本:

wget https://raw.githubusercontent.com/chatwoot/chatwoot/develop/deployment/setup_20.04.sh -O setup.sh

步骤2、在Ubuntu 20.04上安装Chatwoot

使下载的脚本可执行并作为sudo运行:

chmod 755 setup.sh

sudo ./setup.sh

安装程序将下载并安装Chatwoot所需的软件包。

成功安装后,您将看到如下输出:

Woot! Woot!! Chatwoot server installation is complete

The server will be accessible at http://<server-ip>:3000

To configure a domain and SSL certificate, follow the guide at https://www.chatwoot.com/docs/deployment/deploy-chatwoot-in-linux-vm

该服务可直接访问,地址格式如下:

http://<server-ip>:3000

步骤3、安装Nginx Web服务器

Chatwoot可以通过http://<server-ip>:3000访问。您应该将防火墙配置为允许端口3000。

在此设置中,我们需要安装Nginx并将其用作Chatwoot的反向代理。

我们还将在nginxVirtualhost上设置Let's Encrypt。

在Ubuntu上安装nginx:

sudo apt update

sudo apt install nginx

配置nginx,取消链接默认nginx配置:

sudo unlink /etc/nginx/sites-enabled/default

创建虚拟主机:

cd /etc/nginx/sites-available

sudo nano chatwoot.conf

在conf文件中添加以下配置:

server {

  server_name <yourdomain.com>;

  # 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 turned 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_set_header Connection “”;

    proxy_buffering off;

    client_max_body_size 0;

    proxy_read_timeout 36000s;

    proxy_redirect off;

  }

  listen 80;

}

将配置文件链接到/etc/nginx/sites-enabled:

sudo ln -s /etc/nginx/sites-available/chatwoot.conf /etc/nginx/sites-enabled/chatwoot.conf

验证Nginx配置是否正常,然后重新启动Nginx服务:

sudo nginx -t

sudo systemctl reload nginx

步骤4、为Chatwoot配置Let's Encrypt SSL

添加certbot存储库:

sudo add-apt-repository ppa:certbot/certbot

为Nginx安装certbot:

sudo apt update

sudo apt install python-certbot-nginx

运行Let's Encrypt:

sudo mkdir -p /var/www/ssl-proof/chatwoot/.well-known

sudo certbot --webroot -w /var/www/ssl-proof/chatwoot/ -d yourdomain.com -i nginx

您现在可以从访问Chatwoot实时服务器https://yourdomain.com,如下界面:

\

\

1、配置Chatwoot环境

您需要配置chatwoot环境以使系统正常运行。

以Chatwoot用户身份登录:

# Login as chatwoot user

sudo -i -u chatwoot

cd chatwoot

配置Facebook频道,需要在他们的开发者门户中创建一个Facebook应用程序,地址https://developers.facebook.com/docs/apps/#register。

然后需要在.env文件中填写以下详细信息:

##edit the .env file

$ nano .env

FB_VERIFY_TOKEN=

FB_APP_SECRET=

FB_APP_ID=

配置电子邮件,在.env文件中,在以下字段中添加SMTP详细信息:

MAILER_SENDER_EMAIL=

SMTP_ADDRESS=

SMTP_USERNAME=

SMTP_PASSWORD=

配置存储,可以将Chatwoot配置为使用云存储,例如Amazon s3,而不是使用默认的本地存储。这可以在.env文件的以下字段中更改:

ACTIVE_STORAGE_SERVICE='local'

在.env文件中进行任何更新/更改后,重新启动chatwoot服务:

sudo systemctl restart chatwoot.target

2、如何升级Chatwoot

使用以下步骤升级到Chatwoot的更新版本:

#以Chatwoot用户身份登录

sudo -i -u chatwoot

#导航到Chatwoot目录

cd chatwoot

#拉动主分支的最新版本

git checkout master && git pull

#更新依赖项

bundle

yarn

#重新组合资产

rake assets:precompile RAILS_ENV=production

#迁移数据库架构

RAILS_ENV=production bundle exec rake db:migrate

#重新启动chatwoot服务器

systemctl restart chatwoot.target

结论

通过以上步骤,我们已经在一个自托管的Ubuntu 20.04主机上安装并配置了Chatwoot实时聊天服务器。