Skip to main content

Environment Configuration

Environment Configuration

NuSaaS requires two separate configuration files. You can generate these automatically using the interactive installer, or create them manually.

One-Line Interactive Setup

curl -fsSL https://get.nusaas.com/install.sh -o install.sh && bash install.sh

1. API Backend Configuration (/opt/nusaas/.env)

APP_DEPLOYMENT=self-hosted
APP_NAME="Your Business Name"
APP_ENV=production
APP_DEBUG=false
APP_KEY=base64:GENERATE_VIA_OPENSSL_RAND_BASE64_32
APP_URL=https://api.yourdomain.com
FRONTEND_URL=https://app.yourdomain.com
APP_TIMEZONE=Africa/Nairobi
APP_CURRENCY=KES

# Security
CORS_ALLOWED_ORIGIN_PATTERNS=#^https?://.*$#
TRUSTED_PROXIES=*
BCRYPT_ROUNDS=12

# Database (MySQL 8.0)
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=nusaas
DB_USERNAME=nusaas
DB_PASSWORD=CHOOSE_A_STRONG_PASSWORD

# Redis (Queue & Cache)
REDIS_HOST=cache
REDIS_PORT=6379
REDIS_CLIENT=predis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
CACHE_STORE=redis

# JWT Token Auth
JWT_SECRET=GENERATE_VIA_OPENSSL_RAND_HEX_32
JWT_TTL=60

# Meilisearch
SCOUT_DRIVER=meilisearch
MEILISEARCH_HOST=http://search:7700
MEILISEARCH_KEY=CHOOSE_A_STRONG_MASTER_KEY

# WebSocket (Laravel Reverb)
BROADCAST_CONNECTION=reverb
REVERB_APP_ID=GENERATE_VIA_OPENSSL
REVERB_APP_KEY=GENERATE_VIA_OPENSSL
REVERB_APP_SECRET=GENERATE_VIA_OPENSSL
REVERB_HOST=ws
REVERB_PORT=8083
REVERB_SCHEME=http

# Mail (SMTP)
MAIL_MAILER=smtp
MAIL_HOST=smtp.your-provider.com
MAIL_PORT=587
MAIL_USERNAME=your_smtp_username
MAIL_PASSWORD=your_smtp_password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="noreply@yourdomain.com"

Cryptographic Keys Generation

Run these commands to generate random keys for your .env:

# Generate APP_KEY
openssl rand -base64 32

# Generate JWT_SECRET
openssl rand -hex 32

# Generate Reverb ID, KEY, SECRET
openssl rand -hex 8
openssl rand -hex 10
openssl rand -hex 32

2. Frontend Configuration (/opt/nusaas/web/.env.frontend)

VITE_API_URL=https://api.yourdomain.com/api
VITE_API_BASE_URL=https://api.yourdomain.com
VITE_APP_NAME="Your Business Name"
VITE_BILLING_ENABLED=false
VITE_DEPLOYMENT=self-hosted

# Must match backend REVERB_APP_KEY
VITE_REVERB_APP_KEY=SAME_AS_BACKEND_REVERB_APP_KEY
VITE_REVERB_HOST=ws.yourdomain.com
VITE_REVERB_PORT=443
VITE_REVERB_SCHEME=wss