Skip to content

Instantly share code, notes, and snippets.

@Juan-Severiano
Created September 8, 2025 19:50
Show Gist options
  • Select an option

  • Save Juan-Severiano/da9cb2f091fc6e11a5d17dc2e7e3385f to your computer and use it in GitHub Desktop.

Select an option

Save Juan-Severiano/da9cb2f091fc6e11a5d17dc2e7e3385f to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
echo "=== Atualizando pacotes ==="
sudo apt update && sudo apt upgrade -y
echo "=== Instalando dependências ==="
sudo apt install -y curl software-properties-common
echo "=== Instalando unzip ==="
sudo apt-get install -y unzip
echo "=== Instalando Node.js 24 ==="
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
sudo apt install -y nodejs build-essential
echo "=== Verificando versão do Node e npm ==="
node -v
npm -v
echo "=== Instalando PM2 ==="
sudo npm install -g pm2
echo "=== Configurando PM2 para iniciar no boot ==="
pm2 startup systemd -u $USER --hp $HOME
sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u $USER --hp $HOME
echo "=== Instalando e configurando Nginx ==="
sudo apt install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
echo "=== Configurando ambiente de produção ==="
# Adiciona NODE_ENV=production no profile global
echo "export NODE_ENV=production" | sudo tee -a /etc/profile.d/node_env.sh
sudo chmod +x /etc/profile.d/node_env.sh
source /etc/profile.d/node_env.sh
echo "=== Configuração concluída ==="
echo "Node.js versão: $(node -v)"
echo "NPM versão: $(npm -v)"
echo "NODE_ENV: $NODE_ENV"
echo "Agora você pode usar 'pm2 start app.js' e 'pm2 save' para manter seus apps ativos."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment