我将我的应用部署到服务器。 (Rails 5,Passenger,Nginx) 我的应用正在开发模式。 但我把我的模式改为生产,我得到了这个错误(/var/log/nginx/error.log):
[ E 2017-11-10 20:11:03.9343 21613/Tb age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/rails/myapp: An error occurred while starting up predloader
Error ID: ca909334
Error details saved to: /tmp/passenger-error-iGQLnf.html
Message from application: cannot load such file -- /home/rails/myapp/config/environment (LoadError)
config.ru:3:in `require_relative'
config.ru:3:in `block in <main>'
/usr/local/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
/usr/local/lib/ruby/gems/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `eval'
/usr/share/passenger/helper-scripts/rack-preloader.rb:110:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:156:in `<module:App>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
/usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `<main>'
在此错误之后,我将模式切换为开发。我又得到了同样的错误!
我的nginx文件:
server {
listen 80;
server_name myapp.com www.myapp.com;
access_log off;
return 301 https://www.myapp.com$request_uri;
}
server {
listen 443 ssl;
ssl on;
ssl_certificate /etc/nginx/ssl/myapp.com/ssl-bundle.crt;
ssl_certificate_key /etc/nginx/ssl/myapp.key;
server_name myapp.com www.myapp.com;
passenger_enabled on;
rails_env production;
root /home/rails/myapp/public;
index index.html index.htm;
}
需要帮助来解决这个问题!
答案 0 :(得分:1)
因此,事实证明问题是由于用户的文件权限不正确。
Nginx作为www-data用户运行,该用户无权读取app-directory的文件。 这就是app-server启动失败的原因。
sudo chown -R www-data:www-data /home/rails/myapp
使用上述命令后,乘客将能够读取app-directory的文件并成功启动。