Ubuntu 20.04에 Mattermost 팀 메시징 시스템을 설치하는 방법
이 튜토리얼은 다음 OS 버전에 대해 존재합니다.
- Ubuntu 22.04(Jammy Jellyfish)
- Ubuntu 20.04(Focal Fossa)
이 페이지에서
- 전제 조건
- 시작하기\n
- MariaDB 설치 및 구성
- Mattermost 설치 및 구성
- Mattermost용 Systemd 서비스 파일 생성
- Nginx를 역방향 프록시로 구성\n
- Lets Encrypt SSL로 Mattermost 보안 유지
- Mattermost 웹 인터페이스에 액세스
- 결론
Mattermost는 채팅, 파일 공유, 검색 및 통합에 사용되는 오픈 소스 및 자체 호스팅 메시징 애플리케이션입니다. 모든 팀 커뮤니케이션을 한 곳으로 가져오는 Slack 채팅의 대안입니다. React 및 Golang으로 작성되었으며 백엔드에서 PostgreSQL 또는 MySQL 데이터베이스를 사용합니다. 푸시 알림, 무제한 검색 기록, 사용자 정의 이모티콘, Webhook 및 명령, Active Directory, 다중 노드 데이터베이스 배포 지원, 포럼, 토론 게시판 등을 포함한 다양한 기능을 제공합니다.
이 튜토리얼에서는 Ubuntu 20.04에서 Mattermost와 Nginx 및 Lets Encrypt SSL을 설치하는 방법을 보여줍니다.
전제 조건
- Ubuntu 20.04를 실행하는 서버.\n
- 서버 IP를 가리키는 유효한 도메인 이름입니다.\n
- 루트 암호는 서버에서 구성됩니다.\n
시작하기
먼저 시스템 패키지를 최신 버전으로 업데이트하는 것이 좋습니다. 다음 명령을 실행하여 업데이트할 수 있습니다.
apt-get update -y
모든 패키지가 업데이트되면 다음 명령을 실행하여 다른 필수 종속성을 설치합니다.
apt-get install curl wget vim git unzip gnupg2 -y
필요한 패키지를 모두 설치한 후 다음 단계로 진행할 수 있습니다.
MariaDB 설치 및 구성
Mattermost는 MySQL/MariaDB를 데이터베이스 백엔드로 사용합니다. 따라서 서버에 MariaDB 서버가 설치되어 있어야 합니다. 설치되어 있지 않은 경우 다음 명령으로 설치할 수 있습니다.
apt-get install mariadb-server -y
MariaDB 서버를 설치한 후 다음 명령을 사용하여 MariaDB에 로그인합니다.
mysql
로그인한 후 다음 명령을 사용하여 Mattermost에 대한 데이터베이스와 사용자를 생성합니다.
MariaDB [(none)]> CREATE DATABASE mattermostdb;
MariaDB [(none)]> CREATE USER 'mattermost'@'%' IDENTIFIED BY 'password';
다음으로 다음 명령을 사용하여 Mattermost에 모든 권한을 부여합니다.
MariaDB [(none)]> GRANT ALL PRIVILEGES ON mattermostdb.* TO 'mattermost'@'%';
그런 다음 권한을 플러시하고 다음 명령을 사용하여 MariaDB 셸을 종료합니다.
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
MariaDB 데이터베이스가 구성되면 다음 단계로 진행할 수 있습니다.
Mattermost 설치 및 구성
먼저 공식 웹사이트에서 최신 버전의 Mattermost를 다운로드해야 합니다. 다음 명령으로 다운로드할 수 있습니다.
wget https://releases.mattermost.com/5.24.2/mattermost-5.24.2-linux-amd64.tar.gz
다운로드가 완료되면 다음 명령을 사용하여 다운로드한 파일의 압축을 풉니다.
tar -xvzf mattermost-5.24.2-linux-amd64.tar.gz
그런 다음 추출된 디렉터리를 /opt에 복사합니다.
cp -r mattermost /opt
다음으로 Mattermost에 대한 데이터 디렉터리를 만듭니다.
mkdir /opt/mattermost/data
다음으로 Mattermost를 실행하려면 별도의 사용자를 생성해야 합니다. 다음 명령으로 만들 수 있습니다.
useradd --system --user-group mattermost
그런 다음 가장 중요한 디렉터리의 소유권을 가장 중요한 것으로 변경하고 다음 명령을 사용하여 적절한 권한을 부여합니다.
chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermost
다음으로 Mattermost 기본 구성 파일을 편집하고 데이터베이스 설정 및 사이트 URL을 정의합니다.
nano /opt/mattermost/config/config.json
필요에 따라 다음 줄을 변경합니다.
"SiteURL": "https://mattermost.linuxbuz.com", "DriverName": "mysql", "DataSource": "mattermost:(localhost:3306)/mattermostdb?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s",
완료되면 파일을 저장하고 닫습니다.
Mattermost에 대한 Systemd 서비스 파일 생성
다음으로 Mattermost 서비스를 관리하기 위해 systemd 서비스 파일을 생성해야 합니다. 다음 명령으로 만들 수 있습니다.
nano /lib/systemd/system/mattermost.service
다음 줄을 추가합니다.
[Unit] Description=Mattermost After=network.target After=mysql.service Requires=mysql.service [Service] Type=notify User=mattermost Group=mattermost ExecStart=/opt/mattermost/bin/mattermost TimeoutStartSec=3600 Restart=always RestartSec=10 WorkingDirectory=/opt/mattermost LimitNOFILE=49152 [Install] WantedBy=mariadb.service
파일을 저장하고 닫은 후 다음 명령을 사용하여 systemd 데몬을 다시 로드합니다.
systemctl daemon-reload
그런 다음 Mattermost 서비스를 시작하고 다음 명령을 사용하여 시스템 재부팅 시 시작되도록 활성화합니다.
systemctl start mattermost
systemctl enable mattermost
그런 다음 다음 명령을 사용하여 Mattermost 서비스의 상태를 확인합니다.
systemctl status mattermost
다음 출력이 표시되어야 합니다.
? mattermost.service - Mattermost Loaded: loaded (/lib/systemd/system/mattermost.service; disabled; vendor preset: enabled) Active: active (running) since Sat 2020-08-01 09:12:52 UTC; 17s ago Main PID: 4106 (mattermost) Tasks: 20 (limit: 2353) Memory: 85.9M CGroup: /system.slice/mattermost.service ??4106 /opt/mattermost/bin/mattermost ??4198 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64 Aug 01 09:12:52 ubunt4 mattermost[4106]: {"level":"info","ts":1596273172.131499,"caller":"mlog/sugar.go:19","msg":"Sent notification of ne> Aug 01 09:12:52 ubunt4 mattermost[4106]: {"level":"info","ts":1596273172.1841655,"caller":"jobs/workers.go:73","msg":"Starting workers"} Aug 01 09:12:52 ubunt4 mattermost[4106]: {"level":"info","ts":1596273172.1842792,"caller":"bleveengine/bleve.go:267","msg":"UpdateConf Ble> Aug 01 09:12:52 ubunt4 mattermost[4106]: {"level":"info","ts":1596273172.1930475,"caller":"jobs/schedulers.go:74","msg":"Starting schedule> Aug 01 09:12:52 ubunt4 mattermost[4106]: {"level":"info","ts":1596273172.20063,"caller":"app/web_hub.go:83","msg":"Starting websocket hubs> Aug 01 09:12:52 ubunt4 mattermost[4106]: {"level":"info","ts":1596273172.2099638,"caller":"app/license.go:37","msg":"License key from http> Aug 01 09:12:52 ubunt4 mattermost[4106]: {"level":"info","ts":1596273172.2205582,"caller":"app/server.go:525","msg":"Starting Server..."} Aug 01 09:12:52 ubunt4 mattermost[4106]: {"level":"info","ts":1596273172.2208374,"caller":"app/server.go:594","msg":"Server is listening o> Aug 01 09:12:52 ubunt4 mattermost[4106]: {"level":"info","ts":1596273172.2211802,"caller":"commands/server.go:106","msg":"Sending systemd > Aug 01 09:12:52 ubunt4 systemd[1]: Started Mattermost.
이 시점에서 Mattermost는 실행 중이며 포트 8065에서 수신 대기 중입니다.
Nginx를 역방향 프록시로 구성
다음으로 Nginxx를 Mattermost의 리버스 프록시로 구성해야 합니다. 먼저 다음 명령을 사용하여 Nginx 패키지를 설치합니다.
apt-get install nginx -y
설치가 완료되면 다음 명령을 사용하여 Nginx 가상 호스트 구성 파일을 만듭니다.
nano /etc/nginx/sites-available/mattermost.conf
다음 줄을 추가합니다.
upstream mattermost { server localhost:8065; keepalive 32; } proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off; server { listen 80; server_name mattermost.linuxbuz.com; location ~ /api/v[0-9]+/(users/)?websocket$ { proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; client_max_body_size 50M; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_buffers 256 16k; proxy_buffer_size 16k; client_body_timeout 60; send_timeout 300; lingering_timeout 5; proxy_connect_timeout 90; proxy_send_timeout 300; proxy_read_timeout 90s; proxy_pass http://mattermost; } location / { client_max_body_size 50M; proxy_set_header Connection ""; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Frame-Options SAMEORIGIN; proxy_buffers 256 16k; proxy_buffer_size 16k; proxy_read_timeout 600s; proxy_cache mattermost_cache; proxy_cache_revalidate on; proxy_cache_min_uses 2; proxy_cache_use_stale timeout; proxy_cache_lock on; proxy_http_version 1.1; proxy_pass http://mattermost; } }
파일을 저장하고 닫은 후 다음 명령을 사용하여 가상 호스트 구성을 활성화합니다.
ln -s /etc/nginx/sites-available/mattermost.conf /etc/nginx/sites-enabled/mattermost.conf
다음으로 구성 오류가 있는지 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
Lets Encrypt SSL로 Mattermost 보호
먼저 Lets Encrypt SSL을 관리하려면 시스템에 Certbot 클라이언트를 설치해야 합니다. 다음 명령으로 설치할 수 있습니다.
apt-get install python3-certbot-nginx -y
Certbot을 설치한 후 다음 명령을 실행하여 웹사이트에 Lets Encrypt SSL을 설치합니다.
certbot --nginx -d mattermost.linuxbuz.com
유효한 이메일 주소를 제공하고 아래와 같이 서비스 약관에 동의하라는 메시지가 표시됩니다.
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator nginx, Installer nginx Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Obtaining a new certificate Performing the following challenges: http-01 challenge for mattermost.linuxbuz.com Waiting for verification... Cleaning up challenges Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/mattermost.conf
다음으로 HTTP 트래픽을 HTTPS로 리디렉션할지 여부를 선택합니다.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
2를 입력하고 Enter 키를 눌러 Lets Encrypt SSL을 도메인에 설치합니다. 설치되면 다음 출력이 표시됩니다.
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/mattermost.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://mattermost.linuxbuz.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=mattermost.linuxbuz.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/mattermost.linuxbuz.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/mattermost.linuxbuz.com/privkey.pem Your cert will expire on 2020-10-30. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le - We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.
Mattermost 웹 인터페이스에 액세스
이제 웹 브라우저를 열고 URL https://mattermost.linuxbuz.com을 입력합니다. Mattermost 가입 화면으로 리디렉션됩니다.
이메일 주소, 이름, 비밀번호를 입력하고 계정 만들기 버튼을 클릭합니다. 다음 화면이 표시됩니다.
팀 만들기 버튼을 클릭합니다. 다음 화면이 표시됩니다.
팀 이름을 입력하고 다음 버튼을 클릭합니다. 다음 화면이 표시됩니다.
팀 URL을 제공하고 마침 버튼을 클릭합니다. Mattermost 시작 화면이 표시되어야 합니다.
튜토리얼 건너뛰기 버튼을 클릭합니다. 다음 화면에 Mattermost 대시보드가 표시되어야 합니다.
결론
이 가이드에서는 Ubuntu 20.04 서버에 Mattermost Team Messaging 애플리케이션을 설치하는 방법을 배웠습니다. 또한 Nginx를 리버스 프록시로 구성하고 Lets Encrypt SSL로 보호하는 방법도 배웠습니다. 이제 Mattermost 서비스를 탐색하고 팀과 함께 작업할 수 있습니다.