{"id":9630,"date":"2021-08-28T03:32:55","date_gmt":"2021-08-28T03:32:55","guid":{"rendered":"https:\/\/linuxways.net\/?p=9630"},"modified":"2021-09-01T17:45:19","modified_gmt":"2021-09-01T17:45:19","slug":"how-to-deploy-mattermost-on-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/ubuntu\/how-to-deploy-mattermost-on-ubuntu-20-04\/","title":{"rendered":"How to Deploy Mattermost on Ubuntu 20.04"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Mattermost is a self-hosted and open-source online chat. It is developed as a private conversation for organizations and companies.<\/p>\n<p>It&#8217;s a tool with features like Slack and Microsoft Teams. And Mattermost is often installed with PostgreSQL database server.<\/p>\n<p>Below is the guide on how to deploy Mattermost on Ubuntu 20.04 as we go through below.<\/p>\n<h2>Step 1 &#8211; Update system<\/h2>\n<p>Run apt command:<\/p>\n<pre>$ sudo apt update<\/pre>\n<p>Then run the command:<\/p>\n<pre>$ sudo apt upgrade<\/pre>\n<p>Output: <img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"286\" class=\"wp-image-9631\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-502.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-502.png 992w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-502-300x86.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-502-768x221.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/p>\n<p>Lastly, set proper server hostname:<\/p>\n<pre>$ sudo hostnamectl set-hostname NEW_HOSTNAME --static<\/pre>\n<p>Here, we set a hostname named \u201c<strong>chat.ubuntu<\/strong>\u201d<\/p>\n<pre>$ sudo hostnamectl set-hostname chat.ubuntu --static<\/pre>\n<h2>Step 2 &#8211; Install PostgreSQL Database Server<\/h2>\n<p>Run the apt command to install:<\/p>\n<pre>$ sudo apt install postgresql postgresql-contrib<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"991\" height=\"171\" class=\"wp-image-9632\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-503.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-503.png 991w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-503-300x52.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-503-768x133.png 768w\" sizes=\"auto, (max-width: 991px) 100vw, 991px\" \/><\/p>\n<p>Then login to the postgres account:<\/p>\n<pre>$ sudo --login --user postgres<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"46\" class=\"wp-image-9633\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-504.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-504.png 992w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-504-300x14.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-504-768x36.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/p>\n<p>Start the PostgeSQL on the terminal and create the Mattermost database\/user. Here I named it \u201c<strong>linuxer<\/strong>\u201d with the password \u201c<strong>linuxer@123<\/strong>\u201d<\/p>\n<pre>psql<\/pre>\n<pre>CREATE DATABASE mattermost;<\/pre>\n<pre>CREATE USER linuxer WITH PASSWORD 'linuxer@123';<\/pre>\n<pre>GRANT ALL PRIVILEGES ON DATABASE mattermost to linuxer;<\/pre>\n<pre>\\q<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"307\" class=\"wp-image-9634\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-25.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-25.jpeg 992w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-25-300x93.jpeg 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-25-768x238.jpeg 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/p>\n<h2>Step 3 &#8211; Create Mattermost system user and group<\/h2>\n<p>We will create a system user and group named \u201c<strong>mattermost<\/strong>\u201d:<\/p>\n<pre>$ sudo useradd --system --user-group mattermost<\/pre>\n<p>You can confirm by the command:<\/p>\n<pre>$ id mattermost<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"84\" class=\"wp-image-9635\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-505.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-505.png 992w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-505-300x25.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-505-768x65.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/p>\n<h2>Step 4 &#8211; Install Mattermost<\/h2>\n<p>Firstly, you must create a folder named \u201c<strong>mattermost<\/strong>\u201d<\/p>\n<pre>$ mkdir mattermost<\/pre>\n<p>Then navigate to it:<\/p>\n<pre>$ cd mattermost<\/pre>\n<p>Run the wget command to download Mattermost:<\/p>\n<pre>$ wget https:\/\/releases.mattermost.com\/5.38.1\/mattermost-5.38.1-linux-amd64.tar.gz<\/pre>\n<p>Output:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"992\" height=\"367\" class=\"wp-image-9636\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-506.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-506.png 992w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-506-300x111.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-506-768x284.png 768w\" sizes=\"auto, (max-width: 992px) 100vw, 992px\" \/><\/p>\n<p>Extract the package:<\/p>\n<pre>$ tar -xvzf mattermost*.gz<\/pre>\n<p>Copy the extracted file to \/otp directory:<\/p>\n<pre>$ sudo cp -r mattermost \/opt<\/pre>\n<p>Create a folder for Mattermost to contain user data:<\/p>\n<pre>$ sudo mkdir \/opt\/mattermost\/data<\/pre>\n<p>Set correct ownership and permissions:<\/p>\n<pre>$ sudo chown -R mattermost:mattermost \/opt\/mattermost<\/pre>\n<p>Finally, let\u2019s grant write permission to \/opt\/mattermost directory:<\/p>\n<pre>$ sudo chmod -R g+w \/opt\/mattermost<\/pre>\n<h2>Step 5 &#8211; Configure Mattermost Server<\/h2>\n<p>Config setting in the file \/opt\/mattermost\/config\/config.json<\/p>\n<pre>$ sudo nano \/opt\/mattermost\/config\/config.json<\/pre>\n<p>Then configure PostgreSQL database settings: <img loading=\"lazy\" decoding=\"async\" width=\"993\" height=\"573\" class=\"wp-image-9637\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-507.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-507.png 993w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-507-300x173.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-507-768x443.png 768w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/p>\n<p>After the text editor is opened, press Ctrl + W and search \u201c<strong>DriverName<\/strong>\u201d <img loading=\"lazy\" decoding=\"async\" width=\"1143\" height=\"574\" class=\"wp-image-9638\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-26.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-26.jpeg 1143w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-26-300x151.jpeg 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-26-1024x514.jpeg 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-26-768x386.jpeg 768w\" sizes=\"auto, (max-width: 1143px) 100vw, 1143px\" \/><\/p>\n<p>Change the line in red part:<\/p>\n<pre>\"postgres:\/\/matteruser:password@localhost:5432\/mattermost?sslmode=disable&amp;connect_timeout=10\",<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1233\" height=\"574\" class=\"wp-image-9639\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-508.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-508.png 1233w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-508-300x140.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-508-1024x477.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-508-768x358.png 768w\" sizes=\"auto, (max-width: 1233px) 100vw, 1233px\" \/><\/p>\n<p>Save it.<\/p>\n<h2>Step 6 &#8211; Configure Systemd Service<\/h2>\n<p>Create Mattermost Systemd:<\/p>\n<pre>$ sudo vim \/etc\/systemd\/system\/mattermost.service<\/pre>\n<p>Type the lines below:<\/p>\n<pre>[Unit]\r\n\r\nDescription=Mattermost\r\n\r\nAfter=network.target\r\n\r\nAfter=postgresql.service\r\n\r\nRequires=postgresql.service\r\n\r\n[Service]\r\n\r\nType=notify\r\n\r\nExecStart=\/opt\/mattermost\/bin\/mattermost\r\n\r\nTimeoutStartSec=3600\r\n\r\nRestart=always\r\n\r\nRestartSec=10\r\n\r\nWorkingDirectory=\/opt\/mattermost\r\n\r\nUser=mattermost\r\n\r\nGroup=mattermost\r\n\r\nLimitNOFILE=49152\r\n\r\n[Install]\r\n\r\nWantedBy=multi-user.target<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1145\" height=\"576\" class=\"wp-image-9640\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-509.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-509.png 1145w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-509-300x151.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-509-1024x515.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-509-768x386.png 768w\" sizes=\"auto, (max-width: 1145px) 100vw, 1145px\" \/><\/p>\n<p>Press ESC + :wq to save.<\/p>\n<p>Load the new unit into systemd:<\/p>\n<pre>$ sudo systemctl daemon-reload<\/pre>\n<p>Confirm service running status:<\/p>\n<pre>$ systemctl status mattermost.service<\/pre>\n<p>Output: <img loading=\"lazy\" decoding=\"async\" width=\"1142\" height=\"209\" class=\"wp-image-9641\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-510.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-510.png 1142w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-510-300x55.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-510-1024x187.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-510-768x141.png 768w\" sizes=\"auto, (max-width: 1142px) 100vw, 1142px\" \/><\/p>\n<p>Enable mattermost service:<\/p>\n<pre>$ sudo systemctl enable mattermost.service<\/pre>\n<h2>Step 7 &#8211; Install Nginx<\/h2>\n<pre>$ sudo apt -y install nginx<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1230\" height=\"150\" class=\"wp-image-9642\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-511.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-511.png 1230w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-511-300x37.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-511-1024x125.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-511-768x94.png 768w\" sizes=\"auto, (max-width: 1230px) 100vw, 1230px\" \/><\/p>\n<p>You need to type your domain in the Mattermost configuration file:<\/p>\n<pre>$ sudo nano \/opt\/mattermost\/config\/config.json<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1057\" height=\"573\" class=\"wp-image-9643\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-27.jpeg\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-27.jpeg 1057w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-27-300x163.jpeg 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-27-1024x555.jpeg 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-27-768x416.jpeg 768w\" sizes=\"auto, (max-width: 1057px) 100vw, 1057px\" \/><\/p>\n<p>Save it.<\/p>\n<p>Open the text editor to config able to access your domain:<\/p>\n<pre>$ sudo nano \/etc\/nginx\/sites-available\/mattermost.conf<\/pre>\n<p>Add the lines below:<\/p>\n<pre>upstream backend {\r\n\r\nserver localhost:8065;\r\n\r\nkeepalive 32;\r\n\r\n}\r\n\r\nproxy_cache_path \/var\/cache\/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;\r\n\r\nserver {\r\n\r\nlisten 80;\r\n\r\nserver_name your domain;\r\n\r\nlocation ~ \/api\/v[0-9]+\/(users\/)?websocket$ {\r\n\r\nproxy_set_header Upgrade $http_upgrade;\r\n\r\nproxy_set_header Connection \"upgrade\";\r\n\r\nclient_max_body_size 50M;\r\n\r\nproxy_set_header Host $http_host;\r\n\r\nproxy_set_header X-Real-IP $remote_addr;\r\n\r\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n\r\nproxy_set_header X-Forwarded-Proto $scheme;\r\n\r\nproxy_set_header X-Frame-Options SAMEORIGIN;\r\n\r\nproxy_buffers 256 16k;\r\n\r\nproxy_buffer_size 16k;\r\n\r\nclient_body_timeout 60;\r\n\r\nsend_timeout 300;\r\n\r\nlingering_timeout 5;\r\n\r\nproxy_connect_timeout 90;\r\n\r\nproxy_send_timeout 300;\r\n\r\nproxy_read_timeout 90s;\r\n\r\nproxy_pass http:\/\/backend;\r\n\r\n}\r\n\r\nlocation \/ {\r\n\r\nclient_max_body_size 50M;\r\n\r\nproxy_set_header Connection \"\";\r\n\r\nproxy_set_header Host $http_host;\r\n\r\nproxy_set_header X-Real-IP $remote_addr;\r\n\r\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n\r\nproxy_set_header X-Forwarded-Proto $scheme;\r\n\r\nproxy_set_header X-Frame-Options SAMEORIGIN;\r\n\r\nproxy_buffers 256 16k;\r\n\r\nproxy_buffer_size 16k;\r\n\r\nproxy_read_timeout 600s;\r\n\r\nproxy_cache mattermost_cache;\r\n\r\nproxy_cache_revalidate on;\r\n\r\nproxy_cache_min_uses 2;\r\n\r\nproxy_cache_use_stale timeout;\r\n\r\nproxy_cache_lock on;\r\n\r\nproxy_http_version 1.1;\r\n\r\nproxy_pass http:\/\/backend;\r\n\r\n}\r\n\r\n}\r\n\r\n<img loading=\"lazy\" decoding=\"async\" width=\"1060\" height=\"575\" class=\"wp-image-9644\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-512.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-512.png 1060w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-512-300x163.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-512-1024x555.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-512-768x417.png 768w\" sizes=\"auto, (max-width: 1060px) 100vw, 1060px\" \/><\/pre>\n<p>Save it.<\/p>\n<p>To make this site configuration work, you must create a softlink for it in the folder \/etc\/nginx\/sites-enabled:<\/p>\n<pre>$ sudo ln -s \/etc\/nginx\/sites-available\/mattermost.conf \/etc\/nginx\/sites-enabled\/mattermost.conf<\/pre>\n<p>Run this command to check the validity of the configuration:<\/p>\n<pre>$ sudo nginx -t<\/pre>\n<p>Output: <img loading=\"lazy\" decoding=\"async\" width=\"1059\" height=\"83\" class=\"wp-image-9645\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-513.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-513.png 1059w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-513-300x24.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-513-1024x80.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-513-768x60.png 768w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/p>\n<p>Restart Nginx:<\/p>\n<pre>$ sudo systemctl restart nginx<\/pre>\n<p>Then start mattermost service:<\/p>\n<pre>$ sudo systemctl start mattermost<\/pre>\n<p>You can try to access your domain.<\/p>\n<h2>Conclusion<\/h2>\n<p>You\u2019ve already gone through the details of how to deploy Mattermost on Ubuntu 20.04.Thanks for reading.<\/p>","protected":false},"excerpt":{"rendered":"<p>Introduction Mattermost is a self-hosted and open-source online chat. It is developed as a private conversation for organizations and companies. It&#8217;s a tool with features like Slack and&hellip;<\/p>","protected":false},"author":1,"featured_media":9762,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[509,100],"class_list":["post-9630","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ubuntu","tag-mattermost","tag-ubuntu-20-04"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=9630"}],"version-history":[{"count":2,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9630\/revisions"}],"predecessor-version":[{"id":9761,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9630\/revisions\/9761"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/9762"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=9630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=9630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=9630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}