Langfuse Installation & Configuration
This skill provides a step-by-step guide for installing and configuring Langfuse in a self-contained environment, specifically optimized for Akash Network deployments.
Prerequisites
- PostgreSQL: Database
langfuseand userlangfusemust exist. - ClickHouse: Must be running and accessible on port 8123.
- Node.js: Recommended version 24+.
Step 1: Redis Setup (Self-Contained)
Langfuse requires Redis for its background worker. To maintain framework isolation:
- Install Redis:
apt-get install -y redis-server - Move Binaries: Copy
redis-serverandredis-clito a localredis/directory within the service path. - Start Redis:
./redis/redis-server --requirepass YOUR_PASSWORD --port 6379 --daemonize yes
Step 2: Environment Configuration
Create or update the .env file in the source directory with the following mandatory variables:
DATABASE_URL: PostgreSQL connection string.DIRECT_URL: Same asDATABASE_URL(required for Prisma migrations).NEXTAUTH_URL: The public URL of your Langfuse instance.NEXTAUTH_SECRET: Generate viaopenssl rand -base64 32.SALT: Generate viaopenssl rand -base64 32.ENCRYPTION_KEY: 64-character hex string.REDIS_HOST,REDIS_PORT,REDIS_AUTH: Redis connection details.CLICKHOUSE_URL,CLICKHOUSE_USER,CLICKHOUSE_PASSWORD: ClickHouse connection details.LANGFUSE_S3_EVENT_UPLOAD_BUCKET: Set to a placeholder value (e.g., "unused") if not using S3.
Step 3: Database Migrations
Run Prisma migrations using the db:deploy command to avoid shadow database requirements:
export PATH="/path/to/nodejs/bin:$PATH"
turbo run db:deploy
Step 4: Standalone Web Server Setup
Next.js standalone mode is preferred for performance.
- Link Static Assets: Manually link
publicand.next/staticto thestandalone/web/directory:ln -s ../../public .next/standalone/web/public ln -s ../../.next/static .next/standalone/web/.next/static - Startup Script: Create a wrapper (
start-web.sh) that sources.envand executesnode web/server.js.
Step 5: Worker Process Setup
The worker process handles background tasks.
- Startup Script: Create a wrapper (
start-worker.sh) that sources.envand executesnode dist/index.jsfrom theworker/directory.
Step 6: Nginx Routing
Configure Nginx to proxy traffic and serve static assets directly:
location /_next/static {
alias /path/to/source/web/.next/static;
}
location / {
proxy_pass http://127.0.0.1:3000;
# ... standard proxy headers
}