Created
November 26, 2018 10:16
-
-
Save szepnapot/a673c1a6aae6e391f0c1703ce34a4c90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
readonly CHAT_HOME=/opt/Rocket.Chat | |
readonly DOMAIN=[FILL-ME] | |
readonly WEBMASTER_MAIL=[FILL-ME] | |
# MongoDB | |
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 | |
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list | |
# Node.js | |
apt-get update -yq && apt-get install -yq curl && curl -sL curl -sL https://deb.nodesource.com/setup_8.x | sudo bash - | |
# Install deps | |
apt-get install -yq build-essential mongodb-org nodejs graphicsmagick | |
npm install -g inherits n && sudo n 8.11.3 | |
# Rocket.Chat | |
curl -sSL https://releases.rocket.chat/latest/download -o /tmp/rocket.chat.tgz | |
tar -xzf /tmp/rocket.chat.tgz -C /tmp | |
# Install -> $CHAT_HOME | |
cd /tmp/bundle/programs/server && npm install | |
mv /tmp/bundle $CHAT_HOME | |
# Configure Rocket.Chat service | |
useradd -M rocketchat && sudo usermod -L rocketchat | |
chown -R rocketchat:rocketchat /opt/Rocket.Chat | |
# Create systemd entry | |
echo -e "[Unit]\nDescription=The Rocket.Chat server\nAfter=network.target remote-fs.target nss-lookup.target nginx.target mongod.target\n[Service]\nExecStart=/usr/local/bin/node /opt/Rocket.Chat/main.js\nStandardOutput=syslog\nStandardError=syslog\nSyslogIdentifier=rocketchat\nUser=rocketchat\nEnvironment=MONGO_URL=mongodb://localhost:27017/rocketchat ROOT_URL=http://${DOMAIN}:3000/ PORT=3000\n[Install]\nWantedBy=multi-user.target" | sudo tee /lib/systemd/system/rocketchat.service | |
# Enable and start services | |
systemctl enable mongod && systemctl start mongod | |
systemctl enable rocketchat && systemctl start rocketchat | |
# Setup Nginx | |
apt-get install nginx -yq | |
sudo su -c 'cat > /etc/nginx/sites-available/default <<EOL | |
server { | |
server_name ${DOMAIN}; | |
} | |
upstream backend { | |
server 127.0.0.1:3000; | |
} | |
EOL' | |
nginx -t | |
apt-get install -yq python-certbot-nginx | |
certbot --non-interactive --agree-tos --nginx -d $DOMAIN -m $WEBMASTER_MAIL --rsa-key-size 4096 --must-staple --hsts --staple-ocsp --redirect | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment