renansigolo
10/5/2017 - 7:10 AM

01. Initial Server Setup Digital Ocean

Initial Server Setup Digital Ocean for the following servicesInstall* Server updates* NodeJS * Nginx * MongoDB* PM2Configure* MongoDB

Inicial Setup

https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04

Connect SSH

ssh root@SERVER_IP_ADDRESS

https://www.digitalocean.com/community/tutorials/how-to-connect-to-your-droplet-with-ssh?utm_source=Customerio&utm_medium=Email_Internal&utm_campaign=Email_UbuntuDistroNginxWelcome&mkt_tok=eyJpIjoiTlRCaU1HVTFPV1ZoTURObCIsInQiOiJvXC9NNUhmM1BYUFd4QjlsYUw2R0hGYnJJNDg5akZMK0dUN1U0YmFjMVVvTldOVEFFUk5OTTg1clJJOXlsbURlVmY3NUhGU2p1Sk1md2ZUSkxcL25zTHY5Rm54a09hOE5tQnFNZVVWY3VFWHF2OHdrdkd4XC9CTDVwQUdZc0pzTTZaRSJ9

Update Ubuntu

sudo apt-get update && sudo apt-get upgrade -y

apt-get install

Upgrade Ubuntu

apt list --upgradable -a

apt update

apt upgrade

Install Node v.9.x

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs

https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

Install Nginx

sudo apt-get update
sudo apt-get install -y nginx

Now test your serve by accessing your server's ip adress on Google Chrome.

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04

Install Mongo DB v.3.6

sudo 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

sudo apt-get update

sudo apt-get install -y mongodb-org

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

Configure MongoDB

sudo nano /etc/systemd/system/mongodb.service

Paste this code

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

Inicia o MongoDB

sudo systemctl start mongodb

Checa o Status do MongoDB

sudo systemctl status mongodb

Configura para o MongoDB iniciar automaticamente

sudo systemctl enable mongodb

https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04

Config Remote Access to MongoDb

Set the permission that enables mongo to be accessed through this user@serverIP

mongo
ssh -L 4321:localhost:27017 user@your.ip.address -f -N
mongo --port 4321

Edit your /etc/mongod.conf configuration

Replace

bindIp: 127.0.0.1

For

bindIpAll: true

This will enable acces at IPv4 and IPv6

Reboot your server

reboot

Don't forget to change your DB address at the backEnd 'mongodb://your.ip.address/your.db.name'

Try access with MongoDB Compass

https://www.digitalocean.com/community/tutorials/how-to-use-the-mongodb-one-click-application

Install PM2

sudo npm install -g pm2

Navigate util your folder and run

pm2 startup upstart

pm2 save

Check Versions Installed

node -v

nginx -v

mongo --version

pm2 -v

Extra

service --status-all