测试环境
- Debian12
- 需要安装好docker
- 解析好统计域名
项目
🔢 总内存占用:765.98 MiB
📦 总镜像大小:996.00 MiB
一键查询内存占用和镜像大小
curl -sS -O https://raw.githubusercontent.com/woniu336/open_shell/main/plausible_stats_v3.sh && chmod +x plausible_stats_v3.sh && ./plausible_stats_v3.sh
一:克隆并进入项目目录
git clone -b v3.0.1 --single-branch https://github.com/plausible/community-edition plausible-ce
cd plausible-ce
二:配置 .env
文件
创建 .env
文件并写入以下内容
提醒:把plausible.example.com
改成你的统计域名
touch .env
echo "BASE_URL=https://plausible.example.com" >> .env
echo "SECRET_KEY_BASE=$(openssl rand -base64 48)" >> .env
echo "HTTP_PORT=8000" >> .env
查看确认内容:
cat .env
输出类似如下:
BASE_URL=https://plausible.example.com
SECRET_KEY_BASE=随机生成的密钥
HTTP_PORT=8000
流量高峰通知【可选】
cd plausible-ce
nano .env
添加如下内容,以QQ邮箱为例
MAILER_EMAIL=123456@qq.com # 发信邮箱
SMTP_HOST_ADDR=smtp.qq.com
SMTP_HOST_PORT=465
SMTP_USER_NAME=123456@qq.com # 发信邮箱用户名
SMTP_USER_PWD=admin123 # 发信邮箱密码
SMTP_HOST_SSL_ENABLED=true
SMTP_RETRIES=2 # 发信重试次数
三:配置 compose.override.yml
文件
将 Docker 服务的端口绑定为本地回环地址,仅供本地反向代理使用:
提醒:如果你要开启cdn,比如cf cdn,请把127.0.0.1改成0.0.0.0
cat > compose.override.yml << EOF
services:
plausible:
ports:
- 127.0.0.1:8000:\${HTTP_PORT}
EOF
四:启动 Plausible 服务
docker compose up -d
确认服务正常运行:
curl --head http://localhost:8000
应返回:
HTTP/1.1 200 OK
...
五:配置反向代理(以 Nginx 为例)
编辑你的 Nginx 配置文件,例如 /etc/nginx/sites-available/plausible
:
server {
listen 80;
server_name plausible.example.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
启用该配置并重启 Nginx:
sudo ln -s /etc/nginx/sites-available/plausible /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx