Installing Rocket.Chat Server on Rocky Linux 8
The following guide describes how to install Rocket.Chat on Rocky Linux 8 It's easy to install with the Snap package manager.
Feel free to read.
First, we run the terminal and update the packages:
1 | sudo dnf update |
The next step is to install the necessary packages:
1 | sudo dnf install wget curl nano unzip yum-utils -y |
We add a docker repo:
1 2 3 | sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo |
We install the docker:
1 | sudo dnf install docker-ce docker-ce-cli containerd.io |
The following tutorial describes how to install Snapd package manager on AlamaLinux:
1 | sudo systemctl enable docker --now |
We add sudo permissions to docker:
1 | sudo usermod -aG docker $(whoami) |
We install Docker Compose
1 | mkdir ~/.docker/cli-plugins -p |
1 | curl -SL https://github.com/docker/compose/releases/download/v2.10.0/docker-compose-linux-x86_64 -o ~/.docker/cli-plugins/docker-compose |
1 | chmod +x ~/.docker/cli-plugins/docker-compose |
we verify the installation with the command:
1 | docker compose version |
We proceed to installing RocketChat. First, we create a directory:
1 | mkdir ~/rocketchat |
Go to the directory
1 | cd ~/rocketchat |
We create the RocketChat container image in docker-compose.
create a file:
1 | nano docker-compose.yml |
content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | volumes: mongodb_data: rocketchat-uploads: services: rocketchat: image: registry.rocket.chat/rocketchat/rocket.chat:5.0.4 restart: on-failure volumes: - rocketchat-uploads:/app/uploads environment: MONGO_URL: mongodb://mongodb:27017/rocketchat?replicaSet=rs0 MONGO_OPLOG_URL: mongodb://mongodb:27017/local?replicaSet=rs0 ROOT_URL: https://rocketchat.example.com PORT: 3000 DEPLOY_METHOD: docker Accounts_UseDNSDomainCheck: 'false' MAIL_URL: 'smtps://AmazonSESuser:AmazonSESKey@email-smtp.us-west-2.amazonaws.com:587' depends_on: - mongodb expose: - 3000 ports: - 3000:3000 healthcheck: test: > /usr/local/bin/node -e ' const http = require("http"); const options = { host: "localhost", port: 3000, path: "/api/info", timeout: 2000 }; const healthCheck = http.request(options, (res) => { console.log(`HEALTHCHECK STATUS: $${res.statusCode}`); if (res.statusCode == 200) { process.exit(0); } else { process.exit(1); } }); healthCheck.on("error", function (err) { console.error("ERROR"); process.exit(1); }); healthCheck.end();' interval: 10s timeout: 5s retries: 3 start_period: 60s mongodb: image: bitnami/mongodb:4.4 restart: on-failure volumes: - mongodb_data:/bitnami/mongodb environment: MONGODB_REPLICA_SET_MODE: primary MONGODB_REPLICA_SET_NAME: rs0 MONGODB_PORT_NUMBER: 27017 MONGODB_INITIAL_PRIMARY_HOST: mongodb MONGODB_INITIAL_PRIMARY_PORT_NUMBER: 27017 MONGODB_ADVERTISED_HOSTNAME: mongodb MONGODB_ENABLE_JOURNAL: 'true' ALLOW_EMPTY_PASSWORD: 'yes' healthcheck: test: echo 'db.runCommand("ping").ok' | mongo mongodb:27017/test --quiet interval: 10s timeout: 5s retries: 3 start_period: 60s |
We save the file and run the container.
1 | docker compose up -d |
We run ssl for our chat:
1 | sudo dnf install epel-release |
1 | sudo dnf install certbot |
And we generate a certificate:
1 | sudo certbot certonly --standalone --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m adres@e-mail.pl -d rocketchat.domena.pl |
address@e-mail.pl is replaced with our e-mail address
We replace rocketchat.domena.pl with our domain from rocket.chat
1 | sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096 |
We create the letsencrypt directory
1 | sudo mkdir -p /var/lib/letsencrypt |
we create a cron that will automatically renew our certificate:
1 | sudo nano /etc/cron.daily/certbot-renew |
content:
1 2 | #!/bin/sh certbot renew --cert-name rocketchat.domena.pl --webroot -w /var/lib/letsencrypt/ --post-hook "systemctl reload nginx" |
We replace rocketchat.domena.pl with our domain from rocket.chat
let's give permission:
1 | sudo chmod +x /etc/cron.daily/certbot-renew |
We make nginx as a proxy:
we create a repo:
1 | sudo nano /etc/yum.repos.d/nginx.repo |
content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | [nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true |
we save files we install:
1 | sudo dnf install nginx |
we run in the system :
1 | sudo systemctl enable nginx --now |
We create a vhost for rocket.chat
We create a piik:
1 | sudo nano /etc/nginx/conf.d/rocket.conf |
The content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | # Redirect all non-encrypted to encrypted server { listen 80; listen [::]:80; server_name rocketchat.domena.pl; return 301 https://$host$request_uri; } # HTTPS Server server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name rocketchat.example.com; access_log /var/log/nginx/rocketchat_access.log main; error_log /var/log/nginx/rocketchat_error.log; ssl_certificate /etc/letsencrypt/live/rocketchat.domena.pl/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/rocketchat.domena.pl/privkey.pem; ssl_trusted_certificate /etc/letsencrypt/live/rocketchat.domena.pl/chain.pem; ssl_dhparam /etc/ssl/certs/dhparam.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384'; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:20m; ssl_session_tickets off; ssl_session_timeout 180m; ssl_stapling on; ssl_stapling_verify on; location / { proxy_pass http://rocketchat.domena.pl:3000/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; 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 https; proxy_set_header X-Nginx-Proxy true; proxy_redirect off; } } |
We replace rocketchat.domena.pl with our domain from rocket.chat
edit file:
1 | sudo nano /etc/nginx/nginx.conf |
And we add:
1 | server_names_hash_bucket_size 64; |
We reload nginx
1 | sudo systemctl restart nginx |
Access to rocket.chat should now work at: rocketchat.domena.pl should be redirected with A record to the IP of our server.