Skip to content

Instantly share code, notes, and snippets.

@imran-vz
Last active June 17, 2022 08:53
Show Gist options
  • Save imran-vz/1f74daca9101f99fc881f91485d0bc3d to your computer and use it in GitHub Desktop.
Save imran-vz/1f74daca9101f99fc881f91485d0bc3d to your computer and use it in GitHub Desktop.
Install NodeJS, MongoDB and Nginx
#!/usr/bin/env bash
echo "
----------------------
NODE
----------------------
"
# add nodejs 14 ppa (personal package archive) from nodesource
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
# install nodejs and npm
sudo apt-get install -y nodejs
echo "
----------------------
MONGODB
----------------------
"
# import mongodb 4.0 public gpg key
sudo apt-get install gnupg
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
# create the /etc/apt/sources.list.d/mongodb-org-4.0.list file for mongodb
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
# reload local package database
sudo apt-get update
# install the latest version of mongodb
sudo apt-get install -y mongodb-org
# start mongodb
sudo systemctl start mongod
# set mongodb to start automatically on system startup
sudo systemctl enable mongod
echo "
----------------------
NGINX
----------------------
"
# install nginx
sudo apt-get install -y nginx
echo "
----------------------
UFW (FIREWALL)
----------------------
"
# allow ssh connections through firewall
sudo ufw allow OpenSSH
# allow http & https through firewall
sudo ufw allow 'Nginx Full'
# enable firewall
sudo ufw --force enable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment