community-edition

community-edition

Plausible Analytics自托管版 - 简洁高效的网站统计工具

Plausible Analytics社区版是一款轻量级的开源自托管网站分析工具,采用Docker快速部署,支持HTTPS和反向代理。它能帮助网站运营者追踪和分析流量数据,同时特别注重用户隐私保护。该工具提供简便的安装配置流程、完整的版本管理、升级指南以及丰富的自定义选项,可满足不同用户的个性化需求。

Plausible Community Edition自托管Docker配置升级Github开源项目
<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="./images/logo_dark.svg" width="300"> <source media="(prefers-color-scheme: light)" srcset="./images/logo_light.svg" width="300"> <img src="./images/logo_light.svg" width="300"> </picture> </p> <p align="center"> <strong>A getting started guide to self-hosting <a href="https://plausible.io/blog/community-edition">Plausible Community Edition</a></strong> </p> <!-- TODO latest version, current version, requirements -->

Contact:


<p align="center"> <a href="#install">Install</a> &bull; <a href="#upgrade">Upgrade</a> &bull; <a href="#configure">Configure</a> &bull; <a href="#integrate">Integrate</a> &bull; <a href="#faq">FAQ</a> </p>

Install

Plausible Community Edition (or CE for short) is designed to be self-hosted through Docker. You don't have to be a Docker expert to launch your own instance, but you should have a basic understanding of the command-line and networking to successfully set it up.

Requirements

The only thing you need to install Plausible CE is a server with Docker. The server must have a CPU with x86_64 or arm64 architecture and support for SSE 4.2 or equivalent NEON instructions. We recommend using a minimum of 4GB of RAM but the requirements will depend on your site traffic.

We've tested this on Digital Ocean (affiliate link) but any hosting provider works. If your server doesn't come with Docker pre-installed, you can follow their docs to install it.

To make your Plausible CE instance accessible on a (sub)domain, you also need to be able to edit your DNS. Plausible CE isn't currently designed for subfolder installations.

Quick start

To get started quickly, clone the plausible/community-edition repo. It has everything you need to boot up your own Plausible CE server.

<sub><kbd>console</kbd></sub>

$ git clone https://github.com/plausible/community-edition hosting Cloning into 'community-edition'... remote: Enumerating objects: 280, done. remote: Counting objects: 100% (146/146), done. remote: Compressing objects: 100% (74/74), done. remote: Total 280 (delta 106), reused 86 (delta 71), pack-reused 134 Receiving objects: 100% (280/280), 69.44 KiB | 7.71 MiB/s, done. Resolving deltas: 100% (136/136), done. $ ls hosting README.md clickhouse/ docker-compose.yml images/ plausible-conf.env reverse-proxy/ upgrade/

In the downloaded directory you'll find two important files:

  • docker-compose.yml — installs and orchestrates networking between your Plausible CE server, Postgres database, and Clickhouse database for stats.
  • plausible-conf.env — configures the Plausible server itself. Full configuration options are documented below.

Right now the latter looks like this:

<sub><kbd>plausible-conf.env</kbd></sub>

BASE_URL=replace-me SECRET_KEY_BASE=replace-me TOTP_VAULT_KEY=replace-me

Let's do as it asks and populate these required environment variables with our own values.

Required configuration

First we generate the secret key base and TOTP vault key using OpenSSL:

<sub><kbd>console</kbd></sub>

$ openssl rand -base64 48 GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz $ openssl rand -base64 32 dsxvbn3jxDd16az2QpsX5B8O+llxjQ2SJE2i5Bzx38I=

And then we decide on the base URL where the instance would be accessible:

<sub><kbd>plausible-conf.env</kbd></sub>

- BASE_URL=replace-me + BASE_URL=http://plausible.example.com - SECRET_KEY_BASE=replace-me + SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz - TOTP_VAULT_KEY=replace-me + TOTP_VAULT_KEY=dsxvbn3jxDd16az2QpsX5B8O+llxjQ2SJE2i5Bzx38I=

We can start our instance now but the requests would be served over HTTP. Not cool! Let's configure Caddy to enable HTTPS.

Caddy

[!TIP] For other reverse-proxy setups please see reverse-proxy docs.

<details> <summary>Don't need reverse proxy?</summary>

If you're opting out of a reverse proxy and HTTPS, you'll need to adjust the Plausible service configuration to ensure it's not limited to localhost (127.0.0.1). This change allows the service to be accessible from any network interface:

<sub><kbd>docker-compose.yml</kbd></sub>

plausible: ports: - - 127.0.0.1:8000:8000 + - 8000:8000

</details>

First we need to point DNS records for our base URL to the IP address of the instance. This is needed for Caddy to issue the TLS certificates.

Then we need to let Caddy know the domain name for which to issue the TLS certificate and the service to redirect the requests to.

<sub><kbd>reverse-proxy/docker-compose.caddy-gen.yml</kbd></sub>

plausible: labels: - virtual.host: "example.com" # change to your domain name + virtual.host: "plausible.example.com" virtual.port: "8000" - virtual.tls-email: "admin@example.com" # change to your email + virtual.tls-email: "admin@plausible.example.com"

Finally we need to update the base URL to use HTTPS scheme.

<sub><kbd>plausible-conf.env</kbd></sub>

- BASE_URL=http://plausible.example.com + BASE_URL=https://plausible.example.com SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz TOTP_VAULT_KEY=dsxvbn3jxDd16az2QpsX5B8O+llxjQ2SJE2i5Bzx38I=

Now we can start everything together.

Launch

<sub><kbd>console</kbd></sub>

$ docker compose -f docker-compose.yml -f reverse-proxy/docker-compose.caddy-gen.yml up -d [+] Running 19/19 ✔ plausible_db 9 layers [⣿⣿⣿⣿⣿⣿⣿] Pulled ✔ plausible_events_db 7 layers [⣿⣿⣿⣿⣿⣿⣿] Pulled ✔ plausible 7 layers [⣿⣿⣿⣿⣿⣿⣿] Pulled ✔ caddy-gen 8 layers [⣿⣿⣿⣿⣿⣿⣿⣿] Pulled [+] Running 5/5 ✔ Network hosting_default Created ✔ Container hosting-plausible_db-1 Started ✔ Container hosting-plausible_events_db-1 Started ✔ Container hosting-plausible-1 Started ✔ Container caddy-gen Started

It takes some time to start PostgreSQL and ClickHouse, create the databases, and run the migrations. After about fifteen seconds you should be able to access your instance at the base URL and see the registration screen for the admin user.

[!TIP] If something feels off, make sure to check out the logs with <kbd>docker compose logs</kbd> and start a GitHub discussion.

🎉 Happy hosting! 🚀

Next we'll go over how to upgrade the instance when a new release comes out, more things to configure, and how to integrate with Google and others!

Upgrade

Each new release contains information on how to upgrade to it from the previous version. This section outlines the general steps and explains the versioning.

Version management

Plausible CE follows semantic versioning: MAJOR.MINOR.PATCH

You can find available Plausible versions on Github packages. The default latest tag refers to the latest stable release tag. You can also pin your version:

  • <kbd>ghcr.io/plausible/community-edition:v2</kbd> pins the major version to 2 but allows minor and patch version upgrades
  • <kbd>ghcr.io/plausible/community-edition:v2.1</kbd> pins the minor version to 2.1 but allows only patch upgrades

None of the functionality is backported to older versions. If you wish to get the latest bug fixes and security updates you need to upgrade to a newer version.

New versions are published on the releases page and their changes are documented in our Changelog. Please note that database schema changes require running migrations when you're upgrading. However, we consider the schema as an internal API and therefore schema changes aren't considered a breaking change.

We recommend to pin the major version instead of using latest. Either way the general flow for upgrading between minor version would look like this:

<sub><kbd>console</kbd></sub>

$ cd hosting # or wherever you cloned this repo $ docker compose stop plausible [+] Running 1/1 ✔ Container hosting-plausible-1 Stopped $ docker compose rm plausible ? Going to remove hosting-plausible-1 Yes [+] Running 1/0 ✔ Container hosting-plausible-1 Removed $ docker compose -f docker-compose.yml -f reverse-proxy/docker-compose.caddy-gen.yml up -d [+] Running 8/8 ✔ plausible 7 layers [⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 6.4s ✔ 96526aa774ef Pull complete 0.4s ✔ 93631fa7258d Pull complete 0.6s ✔ 06afbc05374b Pull complete 1.6s ✔ 7ddeeadcce1e Pull complete 1.2s ✔ 724ddb9b523f Pull complete 2.8s ✔ 32581b0068b9 Pull complete 1.7s ✔ 4f4fb700ef54 Pull complete 2.0s [+] Running 4/4 ✔ Container hosting-plausible_events_db-1 Running 0.0s ✔ Container hosting-plausible_db-1 Running 0.0s ✔ Container hosting-plausible-1 Started 1.2s ✔ Container caddy-gen Running 0.0s $ docker images --filter=reference='ghcr.io/plausible/community-edition:*' REPOSITORY TAG IMAGE ID CREATED SIZE ghcr.io/plausible/community-edition v2.1 63f7c8708294 6 days ago 83.4MB ghcr.io/plausible/community-edition v2.1.0-rc.0 2b2735265a65 7 months ago 163MB $ docker rmi 2b2735265a65 Untagged: ghcr.io/plausible/community-edition:v2.1.0-rc.0 ...

[!TIP] You can omit <kbd>-f docker-compose.yml -f reverse-proxy/docker-compose.caddy-gen.yml</kbd> if you are not using Caddy.

Changes in major versions would involve performing a data migration (e.g. v2.0.0) or some other extra step.

Configure

Plausible is configured with environment variables, by default supplied via plausible-conf.env env_file.

[!WARNING] Note that if you start a container with one set of ENV vars and then update the ENV vars and restart the container, they won't take effect due to the immutable nature of the containers. The container needs to be recreated.

Example configurations

Here's the minimal configuration file we got from the quick start:

<sub><kbd>plausible-conf.env</kbd></sub>

BASE_URL=https://plausible.example.com SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz TOTP_VAULT_KEY=dsxvbn3jxDd16az2QpsX5B8O+llxjQ2SJE2i5Bzx38I=

And here's a configuration with some extra options provided:

<sub><kbd>plausible-conf.env</kbd></sub>

BASE_URL=https://plausible.example.com SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz TOTP_VAULT_KEY=dsxvbn3jxDd16az2QpsX5B8O+llxjQ2SJE2i5Bzx38I= MAXMIND_LICENSE_KEY=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 MAXMIND_EDITION=GeoLite2-City GOOGLE_CLIENT_ID=140927866833-002gqg48rl4iku76lbkk0qhu0i0m7bia.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=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 MAILER_NAME=Plausible MAILER_EMAIL=somebody+plausible@gmail.com MAILER_ADAPTER=Bamboo.Mua SMTP_HOST_ADDR=smtp.gmail.com SMTP_HOST_PORT=587 SMTP_USER_NAME=somebody@gmail.com SMTP_USER_PWD="wnqj fkbn jcwc byxk" DISABLE_REGISTRATION=invite_only

Here're the currently supported ENV vars:

Required

BASE_URL

Configures the base URL to use in link generation, doesn't have any defaults and needs to be provided in the ENV vars

<sub><kbd>plausible-conf.env</kbd></sub>

BASE_URL=https://plausible.example.com

[!NOTE] In production systems, this should be your ingress host (CDN or proxy).


SECRET_KEY_BASE

Configures the secret used for sessions in the dashboard, doesn't have any defaults and needs to be provided in the ENV vars, can be generated with OpenSSL:

<sub><kbd>console</kbd></sub>

$ openssl rand -base64 48 GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz

<sub><kbd>plausible-conf.env</kbd></sub>

SECRET_KEY_BASE=GLVzDZW04FzuS1gMcmBRVhwgd4Gu9YmSl/k/TqfTUXti7FLBd7aflXeQDdwCj6Cz

[!WARNING] Don't use this exact value or someone would be able to sign a cookie with user_id=1 and log in as the admin!


TOTP_VAULT_KEY

Configures the secret used for encrypting TOTP secrets at rest using AES256-GCM, doesn't have any defaults and needs to be provided in the ENV vars, can be generated with OpenSSL:

<sub><kbd>console</kbd></sub>

$ openssl rand -base64

编辑推荐精选

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

Trae

Trae

字节跳动发布的AI编程神器IDE

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

openai-agents-python

openai-agents-python

OpenAI Agents SDK,助力开发者便捷使用 OpenAI 相关功能。

openai-agents-python 是 OpenAI 推出的一款强大 Python SDK,它为开发者提供了与 OpenAI 模型交互的高效工具,支持工具调用、结果处理、追踪等功能,涵盖多种应用场景,如研究助手、财务研究等,能显著提升开发效率,让开发者更轻松地利用 OpenAI 的技术优势。

Hunyuan3D-2

Hunyuan3D-2

高分辨率纹理 3D 资产生成

Hunyuan3D-2 是腾讯开发的用于 3D 资产生成的强大工具,支持从文本描述、单张图片或多视角图片生成 3D 模型,具备快速形状生成能力,可生成带纹理的高质量 3D 模型,适用于多个领域,为 3D 创作提供了高效解决方案。

3FS

3FS

一个具备存储、管理和客户端操作等多种功能的分布式文件系统相关项目。

3FS 是一个功能强大的分布式文件系统项目,涵盖了存储引擎、元数据管理、客户端工具等多个模块。它支持多种文件操作,如创建文件和目录、设置布局等,同时具备高效的事件循环、节点选择和协程池管理等特性。适用于需要大规模数据存储和管理的场景,能够提高系统的性能和可靠性,是分布式存储领域的优质解决方案。

下拉加载更多