# Add nodejs 10 personal package from nodesource
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

# Install Node.js & npm
sudo apt-get install -y nodejs

# Import GPK key for MongoDB
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 4B7C549A058F8B6B

# Add MongoDB APT repository at /etc/apt/sources.list.d/mongodb.list
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list

# Instal MongoDB on Ubuntu
sudo apt update
sudo apt-get install -y mongodb-org

# Start MongoDB
sudo systemctl start mongod

# Start MongoDB automatically on startup
sudo systemctl enable mongod

# Install pm2
sudo npm install -g pm2

# Start pm2 automatically on startup
sudo pm2 startup systemd

# Install nginx
sudo apt-get install -y nginx

# Enable UWF--allow SSH with firewall
sudo ufw allow OpenSSH

# Allow HTTP/HTTPS with firewall
sudo ufw allow 'Nginx Full'

# Enable firewall
sudo ufw --force enable