웹사이트 검색

Ubuntu 22.04에 Lets Chat을 설치하는 방법


이 페이지에서

  1. 전제 조건
  2. Node.JS 설치
  3. MongoDB 데이터베이스 설치
  4. Lets Chat 설치
  5. Lets Chat용 Systemd 서비스 파일 만들기
  6. Lets Chat용 Nginx 구성
  7. Access Lets Chat 웹 인터페이스
  8. 결론

Lets Chat은 Node.js 및 MongoDB에서 실행되는 무료 오픈 소스 영구 메시징 애플리케이션입니다. LDAP/Kerberos 인증, REST와 유사한 API 및 XMPP 지원과 같은 다양한 기능 세트를 제공하는 소규모의 친근한 팀을 위해 설계되었습니다. Lets Chat을 사용하면 모든 종류의 메시지를 보낼 수 있으며 관심 그룹 채팅, 음성 스티커 및 멋진 이모티콘도 찾을 수 있습니다.

이 게시물에서는 Ubuntu 22.04에서 Lets Chat with Nginx를 리버스 프록시로 설치하는 방법을 보여줍니다.

전제 조건

  • Ubuntu 22.04를 실행하는 서버.\n
  • 루트 암호는 서버에서 구성됩니다.\n

Node.JS 설치

시작하기 전에 서버에 Node.js를 설치해야 합니다. 최신 버전의 Node.js를 설치하려면 APT에 노드 소스 리포지토리를 추가해야 합니다.

먼저 다음 명령을 사용하여 필요한 모든 종속 항목을 설치합니다.

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-org

MongoDB 패키지가 설치되면 다음 명령을 사용하여 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.

Lets Chat 설치

먼저 Git Hub 저장소에서 최신 버전의 Lets Chat을 다운로드해야 합니다. 다음 명령으로 다운로드할 수 있습니다.

git clone https://github.com/sdelements/lets-chat.git

다운로드가 완료되면 디렉토리를 다운로드한 디렉토리로 변경하고 다음 명령을 사용하여 필요한 모든 종속성을 설치합니다.

cd lets-chat
npm install

다음으로 샘플 구성 파일을 복사하고 다음 명령을 사용하여 Lets Chat 서버를 시작합니다.

cp settings.yml.sample settings.yml
npm start

다음 출력이 표시되어야 합니다.

>  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를 눌러 Lets Chat 서비스를 중지합니다.

Lets Chat용 Systemd 서비스 파일 생성

다음으로 Lets 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

다음으로 다음 명령을 사용하여 Lets Chat 서비스를 시작하고 활성화합니다.

systemctl start letschat
systemctl enable letschat

다음으로 다음 명령을 사용하여 Lets 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

이 시점에서 Lets Chat 서비스가 시작되고 포트 5000에서 수신 대기합니다. 다음 명령을 사용하여 ti를 확인할 수 있습니다.

ss -antpl | grep 5000

다음 출력이 표시되어야 합니다.

LISTEN 0      511        127.0.0.1:5000       0.0.0.0:*    users:(("letschat",pid=42441,fd=20))     

Lets Chat을 위한 Nginx 구성

다음으로 Lets Chat의 리버스 프록시로 Nginx를 설치하고 구성해야 합니다. 따라서 포트 80을 통해 Lets 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.

Access Lets Chat 웹 인터페이스

이제 웹 브라우저를 열고 URL http://letschat.example.com을 사용하여 Lets Chat 웹 인터페이스에 액세스하십시오.

계정을 만들려면 "계정이 필요합니다\ 버튼을 클릭해야 합니다. 다음 페이지가 표시됩니다.

사용자 이름, 비밀번호, 이메일 주소를 제공하고 등록 버튼을 클릭합니다. 성공적으로 등록되면 다음 화면이 표시됩니다.

확인 버튼을 클릭합니다. Lets Chat 로그인 화면으로 리디렉션됩니다.

Lets Chat 사용자 이름과 비밀번호를 제공하고 로그인 버튼을 클릭합니다. 다음 화면에 Lets Chat 대시보드가 표시되어야 합니다.

결론

축하합니다! Ubuntu 22.04에서 Nginx를 리버스 프록시로 사용하여 Lets Chat 서버를 성공적으로 설치했습니다. 이제 작업 환경에 Lets Chat을 배포하고 다른 팀원과 커뮤니케이션을 시작할 수 있습니다. 궁금한 점이 있으면 언제든지 문의해 주세요.