Ubuntu 22.04にLet's Chatをインストールする方法
Ubuntu 22.04にLet's Chatをインストールする方法
このページで
- 前提条件
- Node.JSをインストールする
- MongoDBデータベースをインストールする
- Let's Chatをインストールする
- Let's ChatのためのSystemdサービスファイルを作成する
- Let's ChatのためにNginxを設定する
- アクセスレッツチャットウェブインターフェース
- 結論
Let's Chatは、Node.jsとMongoDB上で動作する無料のオープンソースの永続的メッセージングアプリケーションです。これは、LDAP/Kerberos認証、RESTのようなAPI、XMPPサポートなどの豊富な機能を提供する、小規模で親密なチーム向けに設計されています。Let's Chatを使用すると、あらゆる種類のメッセージを送信でき、興味グループチャットやボイスステッカー、クールな絵文字を見つけることもできます。
この記事では、Ubuntu 22.04でNginxをリバースプロキシとして使用してLet's Chatをインストールする方法を紹介します。
前提条件
- Ubuntu 22.04を実行しているサーバー。
- サーバーにはルートパスワードが設定されています。
Node.JSをインストールする
始める前に、サーバーにNode.jsをインストールする必要があります。Node.jsの最新バージョンをインストールするには、APTにNode Sourceリポジトリを追加する必要があります。
まず、次のコマンドで必要な依存関係をすべてインストールしてください:
apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common -yすべての依存関係がインストールされたら、Node.js リポジトリを APT に追加します。
curl -sL https://deb.nodesource.com/setup_18.x | bash -
リポジトリが追加されたら、次のコマンドでNode.jsをインストールできます:
apt-get install nodejs -y成功裏にインストールされた後、以下のコマンドでNode.jsのバージョンを確認してください:
node -v次の出力が得られます:
v18.7.0
MongoDBデータベースをインストールする
サーバーにMongoDBデータベースをインストールする必要があります。
まず、次のコマンドを使ってlibsslパッケージをダウンロードしてインストールします:
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb次に、次のコマンドを使用してMongoDBのGPGキーとリポジトリを追加します:
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list次に、以下のコマンドでリポジトリキャッシュを更新してください:
apt updateリポジトリが更新されたら、以下のコマンドを使用してMongoDBをインストールします:
apt install -y mongodb-orgMongoDBパッケージがインストールされたら、次のコマンドでMongoDBサービスを開始し、有効にします:
systemctl start mongod
systemctl enable mongod次のコマンドでMongoDBサービスのステータスを確認できます:
systemctl status mongod
次の出力が表示されるはずです:
? mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2022-07-31 04:00:08 UTC; 6s ago
Docs: https://docs.mongodb.org/manual
Main PID: 42274 (mongod)
Memory: 61.1M
CPU: 1.014s
CGroup: /system.slice/mongod.service
??42274 /usr/bin/mongod --config /etc/mongod.conf
Jul 31 04:00:08 ubuntu2204 systemd[1]: Started MongoDB Database Server.
Let's Chatをインストールする
まず、GitHubリポジトリからLet's Chatの最新バージョンをダウンロードする必要があります。次のコマンドを使用してダウンロードできます:
git clone https://github.com/sdelements/lets-chat.gitダウンロードが完了したら、ダウンロードしたディレクトリに移動し、次のコマンドを使用して必要な依存関係をすべてインストールします:
cd lets-chat
npm install次に、サンプル設定ファイルをコピーし、次のコマンドでLet's Chatサーバーを起動します。
cp settings.yml.sample settings.yml
npm start次の出力が表示されるはずです:
> [email start
> node app.js
(node:42373) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/4.x/docs/connections.html#use-mongo-client
(Use `node --trace-deprecation ...` to show where the warning was created)
??? ????????????????????????? ?????????? ??? ?????? ?????????
??? ????????????????????????? ??????????? ????????????????????
??? ?????? ??? ???????? ??? ???????????????? ???
??? ?????? ??? ???????? ??? ???????????????? ???
???????????????? ??? ???????? ??????????? ?????? ??? ???
???????????????? ??? ???????? ?????????? ?????? ??? ???
Release 0.4.8
CTRL + Cを押して、Let's Chatサービスを停止してください。
Let's ChatのためのSystemdサービスファイルを作成する
次に、Let's Chatのためのsystemdサービスファイルを作成する必要があります。次のコマンドで作成できます:
nano /etc/systemd/system/letschat.service次の行を追加してください:
[Unit]
Description=Let's Chat Server
Wants=mongodb.service
After=network.target mongod.service
[Service]
Type=simple
WorkingDirectory=/root/lets-chat
ExecStart=/usr/bin/npm start
User=root
Group=root
Restart=always
RestartSec=9
[Install]
WantedBy=multi-user.target
ファイルを保存して閉じてから、次のコマンドでsystemdデーモンを再読み込みします:
systemctl daemon-reload次に、以下のコマンドでLet's Chatサービスを開始し、有効にします。
systemctl start letschat
systemctl enable letschat
次に、以下のコマンドでLet's Chatのステータスを確認してください。
systemctl status letschat次の出力が表示されるはずです:
? letschat.service - Let's Chat Server
Loaded: loaded (/etc/systemd/system/letschat.service; disabled; vendor preset: enabled)
Active: active (running) since Sun 2022-07-31 04:02:34 UTC; 4s ago
Main PID: 42429 (npm start)
Tasks: 23 (limit: 2242)
Memory: 157.9M
CPU: 4.457s
CGroup: /system.slice/letschat.service
??42429 "npm start" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
??42440 sh /tmp/start-b5e830e4.sh
??42441 letschat "" "" ""
Jul 31 04:02:34 ubuntu2204 npm[42429]: > node app.js
Jul 31 04:02:38 ubuntu2204 npm[42441]: (node:42441) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead>
Jul 31 04:02:38 ubuntu2204 npm[42441]: (Use `node --trace-deprecation ...` to show where the warning was created)
Jul 31 04:02:38 ubuntu2204 npm[42441]: ??? ????????????????????????? ?????????? ??? ?????? ?????????
Jul 31 04:02:38 ubuntu2204 npm[42441]: ??? ????????????????????????? ??????????? ????????????????????
Jul 31 04:02:38 ubuntu2204 npm[42441]: ??? ?????? ??? ???????? ??? ???????????????? ???
Jul 31 04:02:38 ubuntu2204 npm[42441]: ??? ?????? ??? ???????? ??? ???????????????? ???
Jul 31 04:02:38 ubuntu2204 npm[42441]: ???????????????? ??? ???????? ??????????? ?????? ??? ???
Jul 31 04:02:38 ubuntu2204 npm[42441]: ???????????????? ??? ???????? ?????????? ?????? ??? ???
Jul 31 04:02:38 ubuntu2204 npm[42441]: Release 0.4.8
この時点で、Let's Chatサービスが開始され、ポート5000で待機しています。次のコマンドで確認できます:
ss -antpl | grep 5000次の出力が表示されるはずです:
LISTEN 0 511 127.0.0.1:5000 0.0.0.0:* users:(("letschat",pid=42441,fd=20))
Let's ChatのためにNginxを設定する
次に、Let's ChatのリバースプロキシとしてNginxをインストールして設定する必要があります。これにより、ポート80を通じてLet's Chatにアクセスできるようになります。
まず、次のコマンドを使ってNginxサーバーパッケージをインストールします:
apt install nginx -y次に、Nginxのバーチャルホスト構成ファイルを作成します:
nano /etc/nginx/conf.d/letschat.conf次の設定を追加してください:
server {
server_name letschat.example.com;
listen 80;
access_log /var/log/nginx/lets_chat-access.log;
error_log /var/log/nginx/lets_chat-error.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass $http_upgrade;
proxy_pass http://127.0.0.1:5000;
}
}
ファイルを保存して閉じてから、Nginxに構文エラーがないか確認してください:
nginx -t次の出力が表示されるはずです:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
最後に、設定変更を適用するためにNginxサービスを再起動してください:
systemctl restart nginx次のコマンドを使用してNginxのステータスを確認することもできます。
systemctl status nginx次の出力にNginxのステータスが表示されるはずです:
? nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-07-31 04:04:23 UTC; 5s ago
Docs: man:nginx(8)
Process: 43193 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 43194 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 43195 (nginx)
Tasks: 2 (limit: 2242)
Memory: 2.5M
CPU: 35ms
CGroup: /system.slice/nginx.service
??43195 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
??43196 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
Jul 31 04:04:23 ubuntu2204 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 31 04:04:23 ubuntu2204 systemd[1]: Started A high performance web server and a reverse proxy server.
アクセス レッツ チャット ウェブ インターフェース
今、ウェブブラウザを開き、URL http://letschat.example.com を使用してLet's Chatのウェブインターフェースにアクセスしてください。
アカウントを作成するには、「アカウントが必要です」ボタンをクリックする必要があります。次のページが表示されるはずです:
ユーザー名、パスワード、メールアドレスを入力し、登録ボタンをクリックしてください。登録が成功すると、次の画面が表示されます:
OKボタンをクリックしてください。あなたはLet's Chatのログイン画面にリダイレクトされます:
Let's Chatのユーザー名とパスワードを入力し、サインインボタンをクリックしてください。次の画面にLet's Chatのダッシュボードが表示されるはずです:
結論
おめでとうございます!Ubuntu 22.04にNginxをリバースプロキシとして使用して、Let's Chatサーバーを正常にインストールしました。これで、作業環境にLet's Chatをデプロイし、他のチームメンバーとコミュニケーションを始めることができます。質問があれば遠慮なく聞いてください。




