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

部署Rails应用至AWS EC2时遇Phusion Passenger路径错误求助

解决Rails部署到AWS EC2时Passenger路径错误问题

你遇到的错误There are no Phusion Passenger(R)-served applications running whose paths begin with '/home/deploy/phjnew'.,说明Passenger无法定位到指定路径下的Rails应用,以下是具体排查和解决步骤:

  • 检查应用路径有效性
    登录EC2实例,执行ls -ld /home/deploy/phjnew/current确认路径存在;如果用Capistrano部署,执行ls -l /home/deploy/phjnew/current查看current软链接是否指向正确的release目录,软链接失效会导致Passenger找不到应用。

  • 确认路径权限
    确保deploy用户对/home/deploy/phjnew/current及子目录有读写权限,执行chown -R deploy:deploy /home/deploy/phjnew修复权限问题。

  • 重启Passenger和Nginx
    先执行passenger-config restart-app /home/deploy/phjnew/current手动重启应用,再重启Nginx:sudo systemctl restart nginx,让配置生效。

  • 验证生产环境资产编译
    进入应用目录,执行RAILS_ENV=production bundle exec rails assets:precompile,确保生产环境资产已编译完成,Passenger需要识别public目录下的静态文件来启动应用。

  • 检查Nginx配置合法性
    执行sudo nginx -t测试配置文件是否有语法错误,确保root指向的/home/deploy/phjnew/current/public目录存在且可访问。

你的Nginx配置如下:

server {
  listen 80;
  listen [::]:80;

  server_name _;
  root /home/deploy/phjnew/current/public;

  passenger_enabled on;
  passenger_app_env production;

  location /cable {
    passenger_app_group_name phjne_websocket;
    passenger_force_max_concurrent_requests_per_process 0;
  }

  # Allow uploads up to 100MB in size
  client_max_body_size 100m;

  location ~ ^/(assets|packs) {
    expires max;
    gzip_static on;
  }
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.22 13:50:06