35
loading...
This website collects cookies to deliver better user experience
ami-03d5c68bab01f3496
.sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
fallocate
, lock its permissions down then deploy it as memory swap. you can see the effects immediately with free -h
./etc/fstab
as root in your favourite text editor and drop this line at the bottom:/swapfile none swap sw 0 0
build-essentials
which includes gcc
and make
and other similar tools.sudo apt update
sudo apt install curl build-essential graphicsmagick
node
12.22.1, so we will install the latest node from 12.x.curl -sL 'https://deb.nodesource.com/setup_12.x' | sudo bash -
sudo apt update
sudo apt install nodejs
node --version
wget -qO - <https://www.mongodb.org/static/pgp/server-5.0.asc> | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] <https://repo.mongodb.org/apt/ubuntu> focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list
sudo apt update
sudo apt install mongodb-org
sudo sed -i "s/^# engine:/ engine: wiredTiger/" /etc/mongod.conf
sudo sed -i "s/^#replication:/replication:\n replSetName: rs01/" /etc/mongod.conf
mmapv1
. that's deprecated in mongodb 5.0, so we will be using wildTiger
instead.mongodb
user. /etc/sysctl.conf
and paste this at the bottom of the file.fs.file-max = 200000
sudo sysctl -p
/etc/security/limits.conf
and add, at the bottom:mongodb soft nproc 200000
mongodb hard nproc 200000
mongodb soft nofile 200000
mongodb hard nofile 200000
mongodb soft memlock 2048
mongodb hard memlock 2048
/etc/pam.d/common-session
and add, at the bottom:session required pam_limits.so
sudo systemctl enable mongod.service
sudo systemctl restart mongod.service
sudo systemctl status mongod.service
curl -L https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz
cd /tmp/
tar xzf rocket.chat.tgz
cd /tmp/bundle/programs/server
npm install
/opt
. many people much smarter than i have waged war over /opt
vs. /usr/local/bin
and, while i do have opinions, it is probably better to stick with the 'canonical' decision, if for no other reason than to make the official documentation easier to use. 'opt' it issudo mv /tmp/bundle /opt/rocket.chat
sudo useradd -M rocketchat
sudo usermod -L rocketchat
sudo chown -R rocketchat:rocketchat /opt/rocket.chat
nginx
is, so we want to be able to run it as a daemon in the same way. doing this involves creating a fairly straight forward systemd
configuration file./lib/systemd/system/rocketchat.service
[Unit]
Description=The Rocket.Chat server
After=network.target remote-fs.target nss-lookup.target nginx.service mongod.service
[Service]
ExecStart=/usr/bin/node /opt/rocket.chat/main.js
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=rocketchat
User=rocketchat
Environment=MONGO_URL=mongodb://localhost:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://localhost:27017/local?replicaSet=rs01 ROOT_URL=<PUBLIC_URL> PORT=3000
[Install]
WantedBy=multi-user.target
Environment
line. you will need to put in the url you intend to serve rocketchat on here and specify the port 3000. ie. http://rocket.example.ca:3000
. note that this is http
not https
, and don't forget to add the :3000
port at the end.node
bin actually lives in /usr/bin/node
and edit accordingly.mongo --eval "printjson(rs.initiate())"
sudo systemctl enable rocketchat
sudo systemctl start rocketchat
sudo systemctl status rocketchat
ROOT_URL
above, ie http://rocket.example.ca:3000
and follow the instructions.sudo apt update
sudo apt install nginx
etc/nginx/sites-available/001-rocketchat.conf
# Upstreams
upstream backend {
server 127.0.0.1:3000;
}
# HTTPS Server
server {
listen 80;
server_name your_hostname.com;
# You can increase the limit if your need to.
client_max_body_size 200M;
error_log /var/log/nginx/rocketchat.access.log;
location / {
proxy_pass http://backend;
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;
}
}
server_name your_hostname.com;
. change your_hostname.com
to the hostname you set in ROOT_URL
minus the port, ie rocket.example.ca
. now savesites-enabled
:cd /etc/nginx/sites-enabled/
sudo ln -s ../sites-available/001-rocketchat.conf
sudo nginx -t
sudo systemctl restart nginx.service
certbot
tool to get a free signed certificate and install it.certbot
tool. this is delivered as a snap:sudo snap install core; sudo snap refresh core
sudo snap install certbot --classic
sudo certbot --nginx
certbot
is done, we can inspect, if we choose, our nginx configuration at etc/nginx/sites-available/001-rocketchat.conf
and see the changes certbot
has made.sudo certbot renew --dry-run
ROOT_URL
on https, ie https://rocket.example.ca
and troll whoever is there.