升级Ghost 4.0

按照官方文档升级,一切顺利,没有任何报错,开心。打开网站,提示:

We'll be right back.
We're busy updating our site to give you the best experience, and will be back soon.

啊……,后悔偷懒没有备份网站目录,更糟糕的是,前不久还把云主机的磁盘备份给取消了。本来计划开始写博客的,现在只好埋头排查。头昏脑涨地修了几个小时,不得要领。

第二天看到这个帖子,才发现是由于Systemd服务配置中,Ghost的版本不对导致的。修复步骤如下:

1、找到Ghost的真正位置,我有用tj/n做Node版本管理:

readlink -f `which ghost`

# /usr/local/lib/node_modules/ghost-cli/bin/ghost

2、找到Ghost的Systemd服务配置文件,如:

sudo systemctl status ghost_muyexi-im

# ● ghost_muyexi-im.service - Ghost systemd service for blog: muyexi-im
#    Loaded: loaded (/var/www/ghost/system/files/ghost_muyexi-im.service; enabled; # vendor preset: enabled)
#    Active: active (running) since Wed 2021-04-07 17:43:01 CST; 1 weeks 0 days ago
#      Docs: https://docs.ghost.org

3、修改配置中Ghost文件的地址:

[Unit]
Description=Ghost systemd service for blog: muyexi-im
Documentation=https://docs.ghost.org

[Service]
Type=simple
WorkingDirectory=/var/www/ghost
User=1000
Environment="NODE_ENV=production"
#ExecStart=/usr/bin/nodejs /usr/bin/ghost run
ExecStart=/usr/local/bin/node /usr/local/lib/node_modules/ghost-cli/bin/ghost run
Restart=always

[Install]
WantedBy=multi-user.target

重新启动Ghost,网站就可以正常访问了。