Instalar Servidor Linux com Tomcat, NodeJS, NPM, PostgreSQL

Instalar Servidor Linux com Tomcat, NodeJS, NPM, PostgreSQL

atualizar pacotes


apt-get update

coisas essenciais


apt-get install git-core curl build-essential openssl libssl-dev

instalar postgres


apt-get install postgresql

criar usuario postgresql


su - postgres
psql -d template1 -U postgres
CREATE USER usuario WITH PASSWORD 'senha';
CREATE DATABASE meu_banco;
GRANT ALL PRIVILEGES ON DATABASE meu_banco to usuario;
\q //sair
su - root

agora vamos configurar o postgres


cd /etc/postgresql/9.6/main
nano postgresql.conf
listen_addresses = '*' //para escutar todos os ips
#liberar nosso ip
host    all             all             meu.ip.fixo/32            md5
service postgresql restart
//tentar logar pgadmin
//tudo funcionando

otimizar postgresql


http://pgtune.leopard.in.ua/
db version: 9.6
os type: linux
db type: web aplicattions
ram: 512 MB
number connections: 100 //ou mais dependendo da ram
//aplicar as mudanças recomendads no postgresql.conf
service postgresql restart // reiniciar
service postgresql status // verificar se status está verde 'active'

instalar tomcat


apt-get install tomcat8 ou tomcat9 se tiver
apt-get install tomcat8-admin
apt-get install default-jdk
apt-get install ant git
nano /etc/tomcat8/tomcat-users.xml
service tomcat8 restart

service tomcat8 restart


//instalar node-js npm
apt-get install nodejs
apt-get install nodejs-legacy
apt-get install npm // mais facil com este instalar npm
npm i -g npm //atualizar npm

mongo-db


apt-get install mongodb
git clone projectlink.git
npm install -g node-autostart //auto iniciar projeto no servidor
autostart enable -n "AppName" -p "/root/app-dir" -c "npm start"