订阅通讯
加入我们的资讯列表
订阅我们的通讯,获取最新资讯和更新通知。
以下是基于宝塔面板部署Plausible的详细步骤,结合了多篇技术文档的实践指南:
stats.yourdomain.com
),解析到服务器IP。/www/wwwroot/stats
)。cd /www/wwwroot/stats
git clone -b v2.1.4 --single-branch https://github.com/plausible/community-edition plausible-ce
进入生成的 plausible-ce
目录。
.env
文件BASE_URL=https://stats.yourdomain.com
SECRET_KEY_BASE=生成的48位Base64密钥(可通过`openssl rand -base64 48`生成)
HTTP_PORT=8090
需替换为实际域名和生成的密钥。
compose.override.yml
文件services:
plausible:
ports:
- 127.0.0.1:8090:${HTTP_PORT}
确保端口与 .env
中的 HTTP_PORT
一致。
docker compose up -d
等待容器构建完成,通过 docker ps
检查运行状态。
curl --head http://localhost:8090
若返回 HTTP/1.1 200 OK
或 302
状态码,则服务正常。
location / {
proxy_pass http://127.0.0.1:8090;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
https://stats.yourdomain.com
访问,首次登录需设置管理员账号。.env
中添加 disable_registration=true
)以增强安全性。/var/log/plausible
)。8090
端口未被占用,或修改 .env
和 compose.override.yml
中的端口号。/js/script.js
)。通过以上步骤,即可在宝塔面板上完成Plausible的私有化部署,实现轻量、隐私友好的网站流量统计。