如何在基于 CentOS 和 Debian 的系统上安装 Let's Chat
Let’s Chat 是一款免费、开源、自托管的聊天应用程序,专为相对较小的团队设计。它的功能丰富;使用Node.js构建并使用MongoDB来存储应用程序数据。
让我们聊天功能:
- 支持持久化消息
- 支持多个房间
- 支持本地/Kerberos/LDAP身份验证
- 带有类似 REST 的 API
- 支持私人和密码保护的房间
- 提供对新消息警报/通知的支持
- 还支持提及(嘿@howtoing/@all)
- 提供对图像嵌入/Giphy 搜索的支持
- 允许粘贴代码
- 支持文件上传(本地或从 Amazon S3 或 Azure)
- 还支持 XMPP 多用户聊天 (MUC) 和 XMPP 用户之间的一对一聊天等等。
重要的是,它旨在轻松部署在满足以下所有要求的任何系统上。
要求
- Node.js (0.11+)
- MongoDB (2.6+)
- Python (2.7.x)
在本文中,我们将解释如何在基于 CentOS 和 Debian 的系统上为小型团队安装和使用 Let’s Chat 消息应用程序。
第 1 步:更新系统
1. 首先确保通过安装必要的软件包来执行系统范围的更新,如下所示。
-------------- On CentOS/RHEL/Fedora --------------
sudo yum update && sudo yum upgrade
-------------- On Debian/Ubuntu --------------
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install software-properties-common git build-essential
2.完成系统更新后,重新启动服务器(可选)。
sudo reboot
第 2 步:安装 Node.js
3.使用所示的nodesource存储库安装最新版本的NodeJS(即撰写本文时的版本7.x)。
-------------- On CentOS/RHEL/Fedora --------------
curl -sL https://rpm.nodesource.com/setup_7.x | sudo -E bash -
sudo yum install nodejs
-------------- On Debian/Ubuntu --------------
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt install nodejs
第三步:安装MongoDB服务器
4.接下来您需要安装MongoDB社区版本,但是,它在YUM存储库中不可用。因此,您必须启用 MongoDB 存储库,如下所述。
在 CentOS/RHEL/Fedora 上
cat <<EOF | sudo tee -a /etc/yum.repos.d/mongodb-org-3.4.repo
[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
EOF
现在安装并启动最新版本的 MongoDB Server(即 3.4)。
sudo yum install mongodb-org
sudo systemctl start mongod.service
sudo systemctl enable mongod.service
在 Debian/Ubuntu 上
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo 'deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse' | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo systemctl start mongod.service
sudo systemctl enable mongod.service
第 4 步:安装 Let’s Chat 服务器
5. 首先安装 git 来克隆 Let's Chat 存储库并安装依赖项,如图所示。
sudo yum install git ##RHEL/CentOS
sudo apt install git ##Debian/Ubuntu
cd /srv
sudo git clone https://github.com/sdelements/lets-chat.git
cd lets-chat
sudo npm install
注意:安装过程中,上面输出的npm WARN信号是正常的。忽略它们即可。
6. 安装完成后,从示例文件创建应用程序配置文件 (/srv/lets-chat/settings.yml) 并在其中定义自定义设置:
sudo cp settings.yml.sample settings.yml
我们将使用示例设置文件中提供的默认设置。
7.最后启动 Let's Chat 服务器。
npm start
要保持 Let's Chat 守护进程运行,请按 Ctrl-C 退出,然后创建一个 Systemd 单元文件以在系统启动时启用它。
第5步:创建Let’s Chat启动文件
8. 为 Let's Chat 创建一个 systemd 单元文件。
sudo vi /etc/systemd/system/letschat.service
将下面的单位配置复制并粘贴到文件中。
[Unit]
Description=Let's Chat Server
Wants=mongodb.service
After=network.target mongodb.service
[Service]
Type=simple
WorkingDirectory=/srv/lets-chat
ExecStart=/usr/bin/npm start
User=root
Group=root
Restart=always
RestartSec=9
[Install]
WantedBy=multi-user.target
9. 现在同时启动服务并使其在系统启动时自动启动。
sudo systemctl start letschat
sudo systemctl enable letschat
sudo systemctl status letschat
第 6 步:访问 Let's Chat 网页界面
10. 一切就绪后,您可以通过以下 URL 访问 Let's Chat 网络界面。
https://SERVER_IP:5000
OR
https://localhost:5000
11.点击“我需要一个帐户”创建一个帐户并填写所需信息,然后点击“注册”。
您可能还喜欢以下相关文章:
- 在 Linux 中创建命令行聊天服务器的有用命令
- 在 Linux 中使用“Openfire”创建您自己的即时消息/聊天服务器
让我们聊天 Github 存储库:https://github.com/sdelements/lets-chat
享受!您现在已经在系统上安装了 Let’s Chat 应用程序。要与我们分享任何想法,请使用下面的反馈表。