本地运行 DJM CMS 的最短路径

用 MySQL 8 和发布包在 10 分钟内跑起一个可登录的本地站点。

本地运行只需要三样东西:Linux 或 macOS 环境、MySQL 8.0+、以及对应架构的发布包。下面以 Linux amd64 为例。

1. 准备数据库

CREATE DATABASE djm_cms_web CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'djm'@'localhost' IDENTIFIED BY 'change-me';
GRANT ALL PRIVILEGES ON djm_cms_web.* TO 'djm'@'localhost';
FLUSH PRIVILEGES;

2. 解压发布包

mkdir -p ~/djm-cms
cd ~/djm-cms
unzip djm-cms_1.0.153_linux_amd64_update.zip
ls releases/1.0.153

3. 准备配置

把 releases/1.0.153 作为当前版本,建立 shared/configs/app.yaml,至少修改数据库与监听地址:

app:
  environment: production
server:
  addr: "127.0.0.1:23180"
database:
  host: 127.0.0.1
  port: 3306
  name: djm_cms_web
  user: djm
  password: ""

数据库密码建议通过环境变量提供:

printf 'export DJM_CONFIG=%s/shared/configs/app.yaml\nexport DJM_DB_PASSWORD=%s\n' "$PWD" 'change-me' > shared/configs/runtime.env
chmod 600 shared/configs/runtime.env

4. 执行安装

source shared/configs/runtime.env
./current/bin/cms install \
  -site-name "DJM CMS" \
  -site-domain localhost \
  -admin-path /admin \
  -admin-user admin \
  -admin-password-file /tmp/admin-password.txt

管理员密码文件权限必须是 0600,否则安装命令会拒绝执行。

5. 启动并验证

./current/bin/cms serve

另开一个终端检查健康状态:

curl -fsS http://127.0.0.1:23180/health/live
curl -fsS http://127.0.0.1:23180/health/ready

浏览器访问 http://127.0.0.1:23180/ 可以看到站点首页,访问后台入口登录。health/ready 返回非 200 时,优先检查数据库连接与迁移状态,可以执行 ./current/bin/cms doctor 获取体检报告。

讨论

发表评论