================================================================================
WHATSAPP GATEWAY - PANDUAN HOSTING
================================================================================

Ringkasan cara install WhatsApp Gateway di berbagai jenis hosting.

================================================================================
JENIS HOSTING & COMPATIBILITY
================================================================================

✅ SUPPORT (Bisa Install):
---------------------------
1. VPS (Virtual Private Server)
   - DigitalOcean, Vultr, Linode, AWS EC2
   - Full control, SSH access
   - Install Node.js sendiri
   - RECOMMENDED! ⭐

2. Cloud Hosting dengan Node.js
   - Hostinger Business/Cloud
   - Niagahoster Bisnis/Cloud
   - Dewaweb Cloud
   - Ada menu Node.js di cPanel

3. Platform Cloud (PaaS)
   - Heroku (free tier)
   - Railway.app (free tier)
   - Render.com (free tier)
   - Vercel (dengan modifikasi)
   - Auto-deploy dari GitHub

❌ TIDAK SUPPORT (Tidak Bisa):
-------------------------------
1. Shared Hosting Biasa
   - Tanpa Node.js support
   - Tanpa SSH access
   - Auto-kill long-running process

2. Hosting Murah
   - Tidak ada terminal
   - Tidak support custom port
   - Resource terbatas

================================================================================
CARA CEK HOSTING ANDA
================================================================================

1. Login ke cPanel
2. Cari menu "Node.js" atau "Setup Node.js App"
3. Jika ADA → Bisa lanjut ✅
4. Jika TIDAK ADA → Tidak support ❌

Atau via SSH:
ssh username@your-hosting.com
node --version
# Jika muncul versi → Support ✅
# Jika error → Tidak support ❌

================================================================================
PILIHAN INSTALASI
================================================================================

OPTION 1: VPS/CLOUD SERVER (RECOMMENDED)
-----------------------------------------
Keuntungan:
✅ Full control
✅ Performance terbaik
✅ Bisa custom semua
✅ Tidak ada batasan

Kekurangan:
❌ Perlu skill server management
❌ Harga lebih mahal (~$5-10/bulan)

Panduan: WHATSAPP_HOSTING_GUIDE.md

OPTION 2: SHARED HOSTING + NODE.JS
-----------------------------------
Keuntungan:
✅ Mudah setup via cPanel
✅ Harga lebih murah
✅ Tidak perlu skill server

Kekurangan:
❌ Resource terbatas
❌ Tidak semua hosting support
❌ Mungkin ada batasan

Panduan: WHATSAPP_SHARED_HOSTING_GUIDE.md

OPTION 3: PLATFORM CLOUD (HEROKU, RAILWAY, RENDER)
---------------------------------------------------
Keuntungan:
✅ Free tier available
✅ Auto-deploy dari GitHub
✅ Mudah setup
✅ Auto-scaling

Kekurangan:
❌ Free tier ada batasan
❌ Mungkin sleep jika tidak dipakai
❌ Perlu GitHub repository

Panduan: WHATSAPP_SHARED_HOSTING_GUIDE.md (bagian Alternative)

OPTION 4: LOCALHOST (DEVELOPMENT)
----------------------------------
Keuntungan:
✅ Gratis
✅ Mudah testing
✅ Full control

Kekurangan:
❌ Hanya untuk development
❌ Tidak bisa diakses dari internet
❌ Komputer harus selalu nyala

Panduan: WHATSAPP_SELFHOSTED_QUICKSTART.md

================================================================================
QUICK START - VPS/CLOUD SERVER
================================================================================

1. SSH ke server:
   ssh root@your-server-ip

2. Install Node.js:
   curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
   sudo apt-get install -y nodejs

3. Upload MikhMon:
   scp -r mikhmon/ username@server-ip:/var/www/html/

4. Install dependencies:
   cd /var/www/html/mikhmon/whatsapp-gateway
   npm install

5. Configure:
   cp .env.example .env
   nano .env
   # Edit API_KEY, DB credentials

6. Start with PM2:
   npm install -g pm2
   pm2 start server.js --name mikhmon-wa-gateway
   pm2 startup
   pm2 save

7. Scan QR Code:
   https://yourdomain.com/mikhmon/settings/whatsapp_gateway_admin.php

Detail: WHATSAPP_HOSTING_GUIDE.md

================================================================================
QUICK START - SHARED HOSTING (cPanel + Node.js)
================================================================================

1. Upload MikhMon via FTP/File Manager

2. Setup Node.js App di cPanel:
   - Menu: Setup Node.js App
   - Create Application
   - Application root: public_html/mikhmon/whatsapp-gateway
   - Startup file: server.js
   - Run NPM Install

3. Create .env file via File Manager:
   - Copy dari .env.example
   - Edit API_KEY, DB credentials

4. Setup Database via cPanel:
   - MySQL Databases
   - Create database & user
   - Import SQL via phpMyAdmin

5. Start Application:
   - cPanel → Node.js App
   - Click "Start"

6. Scan QR Code:
   https://yourdomain.com/mikhmon/settings/whatsapp_gateway_admin.php

Detail: WHATSAPP_SHARED_HOSTING_GUIDE.md

================================================================================
QUICK START - HEROKU (FREE)
================================================================================

1. Install Heroku CLI:
   npm install -g heroku

2. Login:
   heroku login

3. Create app:
   cd whatsapp-gateway
   heroku create mikhmon-wa-gateway

4. Set environment:
   heroku config:set API_KEY=your-key
   heroku config:set DB_HOST=your-db-host
   # ... set semua env variables

5. Deploy:
   git init
   git add .
   git commit -m "Initial"
   git push heroku master

6. Update MikhMon config:
   define('SELFHOSTED_API_URL', 'https://mikhmon-wa-gateway.herokuapp.com/api/send');

7. Scan QR Code via admin panel

Detail: WHATSAPP_SHARED_HOSTING_GUIDE.md (bagian Heroku)

================================================================================
PERBANDINGAN HOSTING
================================================================================

┌──────────────────┬─────────┬──────────┬───────────┬──────────┐
│ Jenis Hosting    │ Harga   │ Setup    │ Control   │ Performa │
├──────────────────┼─────────┼──────────┼───────────┼──────────┤
│ VPS              │ $5-10   │ Medium   │ Full      │ Excellent│
│ Cloud Hosting    │ $3-8    │ Easy     │ Limited   │ Good     │
│ Heroku Free      │ FREE    │ Easy     │ Limited   │ Good     │
│ Railway Free     │ FREE    │ Easy     │ Limited   │ Good     │
│ Render Free      │ FREE    │ Easy     │ Limited   │ Good     │
│ Localhost        │ FREE    │ Easy     │ Full      │ Excellent│
└──────────────────┴─────────┴──────────┴───────────┴──────────┘

REKOMENDASI:
- Production: VPS ⭐⭐⭐⭐⭐
- Budget: Heroku/Railway Free ⭐⭐⭐⭐
- Mudah: Cloud Hosting cPanel ⭐⭐⭐
- Development: Localhost ⭐⭐⭐⭐⭐

================================================================================
KEBUTUHAN MINIMUM
================================================================================

VPS/Cloud Server:
- RAM: 512MB (recommended 1GB)
- Storage: 1GB
- CPU: 1 core
- Bandwidth: Unlimited
- OS: Ubuntu 20.04+ / Debian 10+

Shared Hosting:
- Node.js 16+ support
- SSH access atau Terminal
- MySQL database
- 500MB storage
- Custom port support

Platform Cloud:
- GitHub account
- Free tier available
- Auto-deploy support

================================================================================
BIAYA ESTIMASI
================================================================================

VPS (DigitalOcean, Vultr, Linode):
- Basic: $5/month (1GB RAM, 1 CPU)
- Standard: $10/month (2GB RAM, 1 CPU)
- Premium: $20/month (4GB RAM, 2 CPU)

Cloud Hosting:
- Hostinger Business: ~$3-5/month
- Niagahoster Bisnis: ~$4-6/month
- Dewaweb Cloud: ~$5-8/month

Platform Cloud:
- Heroku: FREE (dengan batasan)
- Railway: FREE (dengan batasan)
- Render: FREE (dengan batasan)

Domain & SSL:
- Domain: $10-15/year
- SSL: FREE (Let's Encrypt)

TOTAL ESTIMASI:
- VPS + Domain: ~$70-130/year
- Cloud Hosting + Domain: ~$50-100/year
- Platform Cloud + Domain: ~$10-15/year (domain only)

================================================================================
TROUBLESHOOTING UMUM
================================================================================

1. "Node.js not found"
   → Hosting tidak support Node.js
   → Upgrade paket atau ganti hosting

2. "Port 3000 blocked"
   → Gunakan port lain (edit .env)
   → Atau setup reverse proxy

3. "Application auto-stop"
   → Hosting auto-kill long-running process
   → Gunakan VPS atau platform cloud

4. "Database connection error"
   → Check credentials di .env
   → Pastikan database sudah dibuat

5. "Permission denied"
   → Fix permissions: chmod -R 755
   → Check ownership: chown -R www-data

6. "QR Code tidak muncul"
   → Check application running
   → Check port accessible
   → Restart application

Detail troubleshooting: Lihat panduan masing-masing hosting

================================================================================
SECURITY CHECKLIST
================================================================================

[ ] API key sudah diganti (bukan default)
[ ] API key sama di .env dan whatsapp_config.php
[ ] Database password strong
[ ] Port 3000 tidak terbuka ke public
[ ] SSL certificate installed (HTTPS)
[ ] Firewall configured
[ ] Regular backup (session data)
[ ] File .env tidak di-commit ke git
[ ] Folder auth_info di-backup
[ ] Update dependencies secara berkala

================================================================================
MONITORING
================================================================================

VPS:
- pm2 status
- pm2 logs mikhmon-wa-gateway
- htop (CPU/RAM)
- df -h (disk space)

Shared Hosting:
- cPanel → Node.js App status
- cPanel → Resource Usage
- Error logs via cPanel

Platform Cloud:
- Dashboard masing-masing platform
- Logs via web interface
- Metrics & analytics

Admin Panel:
- https://yourdomain.com/mikhmon/settings/whatsapp_gateway_admin.php
- Connection status
- Test message

Health Check:
- http://localhost:3000/health (VPS)
- https://yourdomain.com/health (dengan proxy)

================================================================================
BACKUP & RECOVERY
================================================================================

Yang Perlu Di-Backup:
1. Session data: whatsapp-gateway/auth_info/
2. Configuration: whatsapp-gateway/.env
3. Database: wa_message_logs, wa_sessions
4. MikhMon config: include/whatsapp_config.php

Cara Backup:
VPS:
  tar -czf backup.tar.gz auth_info/ .env
  mysqldump mikhmon_agents > backup.sql

Shared Hosting:
  Download via FTP/File Manager
  Export database via phpMyAdmin

Platform Cloud:
  Download dari dashboard
  Export database

Frequency:
- Daily: Session data (auth_info/)
- Weekly: Full backup
- Monthly: Archive backup

Recovery:
1. Restore session data → No need scan QR
2. Restore config → Same API key
3. Restore database → Message history
4. Restart gateway

================================================================================
DOKUMENTASI LENGKAP
================================================================================

Localhost/Development:
→ WHATSAPP_SELFHOSTED_QUICKSTART.md (5 menit)
→ WHATSAPP_SELFHOSTED_GUIDE.md (lengkap)

VPS/Cloud Server:
→ WHATSAPP_HOSTING_GUIDE.md (detail VPS)

Shared Hosting:
→ WHATSAPP_SHARED_HOSTING_GUIDE.md (cPanel + Node.js)

Platform Cloud:
→ WHATSAPP_SHARED_HOSTING_GUIDE.md (Heroku, Railway, Render)

Index:
→ WHATSAPP_GATEWAY_INDEX.md (semua dokumentasi)

Quick Reference:
→ QUICK_REFERENCE.txt (command cepat)

Checklist:
→ WHATSAPP_GATEWAY_CHECKLIST.txt (instalasi checklist)

Architecture:
→ WHATSAPP_GATEWAY_ARCHITECTURE.txt (arsitektur sistem)

================================================================================
SUPPORT
================================================================================

Dokumentasi: Lihat file .md di folder mikhmon/
Admin Panel: https://yourdomain.com/mikhmon/settings/whatsapp_gateway_admin.php
Health Check: http://localhost:3000/health
Logs: pm2 logs mikhmon-wa-gateway

Hosting Support:
- VPS: Check hosting documentation
- Shared: Contact hosting support
- Platform: Check platform docs

================================================================================
KESIMPULAN
================================================================================

PILIH HOSTING BERDASARKAN:

1. Budget Unlimited → VPS ($5-10/month) ⭐⭐⭐⭐⭐
   - Performance terbaik
   - Full control
   - Scalable

2. Budget Terbatas → Heroku/Railway FREE ⭐⭐⭐⭐
   - Gratis (dengan batasan)
   - Mudah setup
   - Auto-deploy

3. Mudah & Cepat → Cloud Hosting cPanel ($3-8/month) ⭐⭐⭐
   - Setup via cPanel
   - Tidak perlu skill server
   - Support bagus

4. Development → Localhost FREE ⭐⭐⭐⭐⭐
   - Gratis
   - Full control
   - Testing

REKOMENDASI KAMI: VPS untuk production, Heroku untuk testing! 🚀

================================================================================

Version: 1.0.0
License: GPL-2.0
Author: MikhMon Team

Happy Hosting! 🚀

================================================================================
