因为需要把 Ghost 默认首页改成 PHP 页面,并在同一域名下运行 PHP,处理思路是:把 Ghost 改为非 80 端口,由 Nginx 监听 80 并反向代理到 Ghost(proxy_pass 到 127.0.0.1:8080);在 vhost 里用 location ~ [^/]\.php(/|$) 把 PHP 请求转到另一个 root 目录,交由 fastcgi(unix:/dev/shm/php-cgi.sock)处理;再在 URL rewrite 配置里把首页转发到指定页面(如 rewrite ^/$ /tz.php last)。
若还想通过 /blog/ 访问原 Ghost 首页,可借助 get 助手:新建 slug 为 blog 的静态页面,在后台实验室开启 PUBLIC API,把主题的 index.js 复制为 page-blog.js,并在文章循环外层加上 {{#get "posts" include="tags,author"}}…{{/get}},最后重启 Ghost 即可。