
Deploy PostHog on Your Own Server
🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
📊 Analytics🛠️ Developer Tools
想更快部署 PostHog到服务器?试试 Senate,一条命令完成部署,自动配置 HTTPS 和监控。
什么是 PostHog?
Enter your PostHog Configuration parameters and click on next. The process will take a just a few minutes to finish. **Note**: This One Click App deploys a **total of 16 different apps** and it requires at least 8GB of RAM with a a Quad-Core CPU.
自托管 PostHog
按照以下步骤在您的服务器上部署。
1
安装 Docker
如果服务器上已安装 Docker,可跳过此步骤。
curl -fsSL https://get.docker.com | sh
2
配置
自定义以下设置。大多数情况下使用默认值即可。
General
3
部署
复制配置并在服务器上运行。
services:
posthog-clickhouse:
volumes:
- clickhouse-data:/var/lib/clickhouse
posthog-db:
image: postgres:12-alpine
environment:
POSTGRES_DB: posthog
POSTGRES_PASSWORD: f3a62678ff9e
POSTGRES_USER: posthog
volumes:
- posthog-postgres-data:/var/lib/postgresql/data
posthog-elasticsearch:
image: elasticsearch:7.16.2
environment:
ES_JAVA_OPTS: -Xms256m -Xmx256m
cluster.routing.allocation.disk.threshold_enabled: "true"
cluster.routing.allocation.disk.watermark.flood_stage: 128mb
cluster.routing.allocation.disk.watermark.high: 256mb
cluster.routing.allocation.disk.watermark.low: 512mb
discovery.type: single-node
xpack.security.enabled: "false"
volumes:
- posthog-elasticsearch:/var/lib/elasticsearch/data
posthog-kafka:
image: ghcr.io/posthog/kafka-container:v2.8.2
environment:
ALLOW_PLAINTEXT_LISTENER: "true"
KAFKA_BROKER_ID: "1001"
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://posthog-kafka:9092
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092
KAFKA_CFG_RESERVED_BROKER_MAX_ID: "1001"
KAFKA_CFG_ZOOKEEPER_CONNECT: posthog-zookeeper:2181
volumes:
- posthog-kafka-data:/bitnami/kafka
depends_on:
- posthog-zookeeper
posthog-objectstorage:
image: minio/minio:RELEASE.2022-06-25T15-50-16Z
environment:
MINIO_ROOT_PASSWORD: 2ea7389b6f45986e05ad83c
MINIO_ROOT_USER: object_storage_root_user
volumes:
- posthog-objectstorage:/data
ports:
- 19000:19000
- 19001:19001
posthog-plugin:
image: posthog/posthog:e2f4b4a8b46667f75ad9bdacf4a487a5dd2d5dbf
environment:
CDP_REDIS_HOST: posthog-redis7
CDP_REDIS_PORT: "6379"
CLICKHOUSE_HOST: posthog-clickhouse
CLICKHOUSE_SECURE: "false"
DATABASE_URL: postgres://posthog:f3a62678ff9e@posthog-db:5432/posthog
DISABLE_SECURE_SSL_REDIRECT: "true"
KAFKA_HOSTS: posthog-kafka:9092
OBJECT_STORAGE_ACCESS_KEY_ID: object_storage_root_user
OBJECT_STORAGE_ENABLED: "true"
OBJECT_STORAGE_ENDPOINT: http://posthog-objectstorage:19000
OBJECT_STORAGE_SECRET_ACCESS_KEY: 2ea7389b6f45986e05ad83c
REDIS_URL: redis://posthog-redis:6379/
SECRET_KEY: e14e988dcdfbc710130a73c
SITE_URL: http://posthog-web.your-domain.com
depends_on:
- posthog-db
- posthog-redis
- posthog-clickhouse
- posthog-kafka
- posthog-objectstorage
posthog-redis:
image: redis:6.2.7-alpine
posthog-redis7:
image: redis:7.2-alpine
posthog-temporal:
image: temporalio/auto-setup:1.20.0
environment:
DB: postgresql
DB_PORT: "5432"
ENABLE_ES: "false"
ES_SEEDS: posthog-elasticsearch
ES_VERSION: v7
POSTGRES_PWD: f3a62678ff9e
POSTGRES_SEEDS: posthog-db
POSTGRES_USER: posthog
ports:
- 7233:7233
depends_on:
- posthog-elasticsearch
- posthog-db
posthog-temporal-admin-tools:
image: temporalio/admin-tools:1.20.0
environment:
TEMPORAL_CLI_ADDRESS: posthog-temporal:7233
depends_on:
- posthog-temporal
posthog-temporal-django-worker:
image: posthog/posthog:e2f4b4a8b46667f75ad9bdacf4a487a5dd2d5dbf
environment:
CLICKHOUSE_HOST: posthog-clickhouse
CLICKHOUSE_SECURE: "false"
DATABASE_URL: postgres://posthog:f3a62678ff9e@posthog-db:5432/posthog
DISABLE_SECURE_SSL_REDIRECT: "true"
IS_BEHIND_PROXY: "true"
KAFKA_HOSTS: posthog-kafka:9092
REDIS_URL: redis://posthog-redis:6379/
SECRET_KEY: e14e988dcdfbc710130a73c
SITE_URL: http://posthog-web.your-domain.com
TEMPORAL_HOST: posthog-temporal
TRUST_ALL_PROXIES: "false"
depends_on:
- posthog-db
- posthog-redis
- posthog-clickhouse
- posthog-kafka
- posthog-objectstorage
- posthog-temporal
posthog-temporal-ui:
image: temporalio/ui:2.10.3
environment:
TEMPORAL_ADDRESS: posthog-temporal:7233
TEMPORAL_CORS_ORIGINS: http://localhost:3000
ports:
- 8081:8080
depends_on:
- posthog-temporal
- posthog-db
posthog-web:
image: posthog/posthog:e2f4b4a8b46667f75ad9bdacf4a487a5dd2d5dbf
environment:
CLICKHOUSE_HOST: posthog-clickhouse
CLICKHOUSE_SECURE: "false"
DATABASE_URL: postgres://posthog:f3a62678ff9e@posthog-db:5432/posthog
DISABLE_SECURE_SSL_REDIRECT: "true"
IS_BEHIND_PROXY: "true"
KAFKA_HOSTS: posthog-kafka:9092
OBJECT_STORAGE_ACCESS_KEY_ID: object_storage_root_user
OBJECT_STORAGE_ENABLED: "true"
OBJECT_STORAGE_ENDPOINT: http://posthog-objectstorage:19000
OBJECT_STORAGE_SECRET_ACCESS_KEY: 2ea7389b6f45986e05ad83c
REDIS_URL: redis://posthog-redis:6379/
SECRET_KEY: e14e988dcdfbc710130a73c
SITE_URL: http://posthog-web.your-domain.com
TRUST_ALL_PROXIES: "false"
depends_on:
- posthog-db
- posthog-redis
- posthog-clickhouse
- posthog-kafka
posthog-worker:
image: posthog/posthog:e2f4b4a8b46667f75ad9bdacf4a487a5dd2d5dbf
environment:
CLICKHOUSE_HOST: posthog-clickhouse
CLICKHOUSE_SECURE: "false"
DATABASE_URL: postgres://posthog:f3a62678ff9e@posthog-db:5432/posthog
DISABLE_SECURE_SSL_REDIRECT: "true"
IS_BEHIND_PROXY: "true"
KAFKA_HOSTS: posthog-kafka:9092
OBJECT_STORAGE_ACCESS_KEY_ID: object_storage_root_user
OBJECT_STORAGE_ENABLED: "true"
OBJECT_STORAGE_ENDPOINT: http://posthog-objectstorage:19000
OBJECT_STORAGE_SECRET_ACCESS_KEY: 2ea7389b6f45986e05ad83c
REDIS_URL: redis://posthog-redis:6379/
SECRET_KEY: e14e988dcdfbc710130a73c
SITE_URL: http://posthog-web.your-domain.com
TRUST_ALL_PROXIES: "false"
posthog-zookeeper:
image: zookeeper:3.7.0
volumes:
- posthog-zookeeper-datalog:/datalog
- posthog-zookeeper-data:/data
- posthog-zookeeper-logs:/logs
volumes:
clickhouse-data: {}
posthog-postgres-data: {}
posthog-elasticsearch: {}
posthog-kafka-data: {}
posthog-objectstorage: {}
posthog-zookeeper-datalog: {}
posthog-zookeeper-data: {}
posthog-zookeeper-logs: {}
然后运行:
docker compose up -d
4
访问
启动后,访问您的应用: http://localhost:80
为什么要自托管 PostHog?
完全数据所有权
数据保存在您的服务器上,无第三方访问。
无月费
只需支付服务器费用,无按席位或用量收费。
完全控制
按您的需求自定义、备份和扩展。
隐私与合规
满足 GDPR、HIPAA 或内部安全要求。
技术细节
想更快部署?
尝试 Senate!Senate 帮您处理 Docker、HTTPS、更新和监控。一条命令部署 300+ 应用。
在任意 Linux 服务器上安装:
sh -c "$(curl -sSL https://get.senate.sh)"