You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS Ubuntu20.04部署Ghost后网站出现404错误无法访问

问题求助:Ghost站点显示Nginx 404错误,Ghost状态正常

基础信息

  • 网站URL:http://www.vincentyuan.us/
  • Ghost版本:5.54.0
  • 部署方式:Ghost CLI安装
  • 使用浏览器:Chrome
  • 问题现象:Ghost状态无报错,但网站访问返回404错误,页面底部标注nginx/1.18.0 (Ubuntu)

已完成操作:创建AWS弹性IP,在Route53配置托管区域,在NameCheap域名服务商处修改对应域名服务器,等待DNS传播后问题仍存在。

配置文件信息

config.production.json内容:

{
  "url": "https://vincentyuan.us",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "my_host",
      "user": "my_user",
      "password": "password",
      "database": "my_database",
      "ssl": "Amazon RDS"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/www/sitename/content"
  }
}

Ghost Doctor检测日志

✔ Checking system Node.js version - found v16.20.1
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking system compatibility
+ sudo systemctl is-active ghost_vincentyuan-us
Instance is currently running
ℹ Validating config [skipped]
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✖ Checking memory availability
✔ Checking binary dependencies
✔ Checking free space
✔ Checking systemd unit file
✔ Checking systemd node version - found v16.20.1
One or more errors occurred.

1) SystemError

Message: You are recommended to have at least 150 MB of memory available for smooth operation. It looks like you have ~111.0390625 MB available.

Debug Information:
    OS: Ubuntu, v20.04.6 LTS
    Node Version: v16.20.1
    Ghost Version: 5.54.0
    Ghost-CLI Version: 1.24.2
    Environment: production
    Command: 'ghost doctor'

Try running ghost doctor to check your system for known issues.

Nginx状态信息

ubuntu@ip-172-31-41-64:/var/www/sitename/current$ service nginx status
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-07-09 03:06:19 UTC; 13h ago
       Docs: man:nginx(8)
   Main PID: 545 (nginx)
      Tasks: 2 (limit: 1141)
     Memory: 3.0M
     CGroup: /system.slice/nginx.service
             ├─545 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             └─546 nginx: worker process

Jul 09 03:06:19 ip-172-31-41-64 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 09 03:06:19 ip-172-31-41-64 systemd[1]: Started A high performance web server and a reverse proxy server.

SSL设置结果

执行ghost set up ssl命令返回:

Love open source? We’re hiring JavaScript Engineers to work on Ghost full-time.
https://careers.ghost.org



SSL has already been set up, skipping
ℹ Setting up SSL [skipped]

排查方案

1. 检查Nginx配置文件

Nginx返回404说明请求未正确转发到Ghost服务,检查Ghost生成的Nginx配置(通常在/etc/nginx/sites-available/或/etc/nginx/sites-enabled/下,文件名对应域名):

  • 确认server_name包含www.vincentyuan.us和vincentyuan.us
  • 确认反向代理配置指向http://127.0.0.1:2368,无路径错误
  • 检查SSL配置是否匹配:Ghost配置中url为https,但访问用http,可能存在跳转或配置不匹配

2. 验证DNS解析

执行以下命令确认域名解析到正确的弹性IP:

nslookup www.vincentyuan.us
ping www.vincentyuan.us

若解析结果不是你的AWS弹性IP,说明DNS配置未生效,检查NameCheap的域名服务器设置是否和Route53托管区域的NS记录完全一致。

3. 检查端口连通性

在服务器上执行curl http://127.0.0.1:2368,确认Ghost服务能正常返回内容:

  • 返回正常:问题出在Nginx转发
  • 返回异常:即使ghost doctor显示运行,内存不足也可能导致服务异常

4. 解决内存不足问题

Ghost Doctor提示仅约111MB可用内存,这会影响服务运行,可通过以下方式解决:

  • 升级服务器配置至至少1GB内存(Ghost官方推荐)
  • 关闭不必要的服务释放内存
  • 配置swap分区缓解压力:
    sudo fallocate -l 1G /swapfile
    sudo chmod 600 /swapfile
    sudo mkswap /swapfile
    sudo swapon /swapfile
    

5. 重启服务确保配置生效

sudo systemctl restart nginx
ghost restart

内容的提问来源于stack exchange,提问作者Vincent Yuan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 22:20:38