deployment:apps:9router

Instalasi 9Router Native (NPM + Systemd) di Debian 13

Dokumentasi instalasi 9Router secara native menggunakan Node.js (NPM) di debian 13.

Instal Node.js v22 LTS dari NodeSource beserta paket build-essential untuk menghindari error kompilasi modul native (seperti better-sqlite3).

sudo apt update && sudo apt install -y curl ca-certificates build-essential
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs

Verifikasi:

node -v && npm -v

Pastikan versi Node.js yang tampil adalah v22.x.


Instal paket 9router secara global melalui NPM:

sudo npm install -g 9router

Verifikasi:

which 9router

Pastikan output mengarah ke path binary (umumnya /usr/bin/9router).


Buat direktori permanen untuk penyimpanan data serta direktori konfigurasi:

sudo mkdir -p /var/lib/9router /etc/9router
sudo chown -R $USER:$USER /var/lib/9router

Buat file environment di /etc/9router/9router.env (ganti YourStrongPasswordHere dengan password dashboard yang diinginkan):

sudo tee /etc/9router/9router.env > /dev/null <<EOF
NODE_ENV=production
PORT=20128
HOSTNAME=0.0.0.0
DATA_DIR=/var/lib/9router
INITIAL_PASSWORD=YourStrongPasswordHere
JWT_SECRET=$(openssl rand -hex 32)
EOF
sudo chmod 600 /etc/9router/9router.env

Buat unit file systemd agar 9Router berjalan di background dan otomatis aktif saat server reboot:

sudo tee /etc/systemd/system/9router.service > /dev/null <<EOF
[Unit]
Description=9Router AI Gateway Service
After=network-online.target
Wants=network-online.target
 
[Service]
Type=simple
User=root
WorkingDirectory=/var/lib/9router
EnvironmentFile=/etc/9router/9router.env
ExecStart=/usr/bin/script -qefc "/usr/bin/9router" /dev/null
Restart=always
RestartSec=5
 
[Install]
WantedBy=multi-user.target
EOF

Reload daemon systemd, aktifkan, dan jalankan service:

sudo systemctl daemon-reload
sudo systemctl enable --now 9router

  1. Cek status service:
    sudo systemctl status 9router
 
  Pastikan status menunjukkan ''active (running)''.
- **Uji endpoint API lokal:**
  <code bash>
  curl -I http://localhost:20128/v1/models
  </code>
- **Buka port firewall (jika menggunakan UFW):**
  <code bash>
  sudo ufw allow 20128/tcp
  </code>
- **Akses Dashboard:** Buka browser ke ''http://<IP-SERVER-DEBIAN>:20128'' dan login menggunakan ''INITIAL_PASSWORD'' yang sudah diatur.

Kebutuhan Perintah
Cek log secara real-time journalctl -u 9router -f
Restart service sudo systemctl restart 9router
Update ke versi terbaru sudo npm install -g 9router@latest && sudo systemctl restart 9router
Ubah konfigurasi
  • deployment/apps/9router.txt
  • Last modified: 2026/11/25 22:32
  • by ilyasa