macOS 安装配置 Ghost 5

环境检查

环境依赖

检查 Node.js

检查当前安装的 Node.js 版本:

node -v
v20.19.0

检查当前安装的 pnpm 版本:

pnpm -v
10.12.1

安装 Ghost

安装 Ghost CLI

使用包管理工具全局安装 Ghost-CLI:

# pnpm
pnpm add -g ghost-cli@latest

# Yarn
yarn global add ghost-cli@latest

# npm
npm install -g ghost-cli@latest

查看当前安装的 Ghost-CLI 版本:

ghost -v
Ghost-CLI version: 1.27.0

安装 Ghost

使用终端工具进入要安装 Ghost 的目录中:

cd <path>

在当前目录安装 Ghost:

# 安装最新版
ghost install local

# 指定版本号安装
ghost install <version> --local

此命令下安装的 Ghost 为development 模式,且使用 SQLite3 数据库。

等待安装完成后,检查当前安装的 Ghost 版本:

ghost -v
Ghost-CLI version: 1.27.0
Ghost version: 5.118.1

安装完成后,会自动启动 Ghost,使用浏览器访问 http://localhost:2368/ghost/ ,根据提示注册管理员账号。

配置 Ghost

开发环境下 Ghost 的配置位于config.development.json 文件中:

vim config.development.json

隐私配置

添加隐私配置:

"privacy": {
  "useUpdateCheck": false,
  "useGravatar": false,
  "useRpcPing": false,
  "useStructuredData": false
}
  • useUpdateCheck:自动版本更新检查和匿名统计数据收集,默认开启。
  • useGravatar:自动下载用户邮箱对应的 Gravatar 头像,默认开启。
  • useRpcPing:自动在发布文章后通知搜索引擎,默认开启。
  • useStructuredData:自动生成适用于某些社交网站的结构化数据,默认开启。

安全配置

添加安全配置:

"security": {
  "staffDeviceVerification": false
}
  • staffDeviceVerification:在新设备登录 Ghost 管理后台时发送邮件验证码,默认开启。

搜索配置

Ghost 使用 JsDeliver CDN 来加载用于本地搜索的 sodo-search 资源文件。

如果主题没有集成本地搜索功能,可以去掉加载的 sodo-search 的 JS 文件:

"sodoSearch": {
  "url": false
}

如果集成了,可以将文件放到主题的 assets 目录里面,添加以下配置:

"sodoSearch": {
  "url": "/assets/sodo-search/sodo-xxx.js",
  "styles": "/assets/sodo-search/sodo-xxx.css"
}

Ghost 升级后该配置需要重新添加到到配置文件。

重新启动

修改 Ghost 配置后,需要重启 Ghost:

ghost restart

管理 Ghost

查看 Ghost

查看已安装的 Ghost 列表:

ghost ls

启动 Ghost

启动当前目录下安装的 Ghost:

ghost start

任意目录下指定 name 启动 Ghost:

ghost start <name>

关闭 Ghost

关闭当前目录下安装的 Ghost:

ghost stop

任意目录下指定 name 关闭 Ghost:

ghost stop <name>

重启 Ghost

重启当前目录下安装的 Ghost:

ghost restart

任意目录下指定 name 重启 Ghost:

ghost restart <name>

参考文献