Follow instructions of node webpage: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
Recomended install build-essential
sudo apt-get install -y build-essential
node --version
Follow instructions https://docs.mongodb.com/master/tutorial/install-mongodb-on-ubuntu/?_ga=1.261646340.820421326.1484596210.
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
This file add the mongo repository.
echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod start
mongo
use appdatabase
db.createUser({
user: "appuser",
pwd: "passworduser",
roels: ["readWrite"]
})
Modify /etc/mongod.conf
, adding in security section:
security:
authorization: "enabled"
sudo nano /etc/systemd/system/mongodb.service
Add to mongodb.service file:
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=username
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
sudo systemctl start mongodb
sudo systemctl enable mongodb
sudo systemctl status mongodb
sudo adduser appname
sudo passwd -l appname
Follow its instructions to install it in the appname user
Install as root.
sudo npm install pm2 -g
cd /route/
pm2 start app.js --name "AppName"
pm2 save
To restart PM2 in the boot/reboot of the server obtain the script required:
pm2 startup
And execute it as root.
pm2 unstartup appname
pm2 list