Home Production does'nt work ( Rails 5 , Passenger , Nginx )
Reply: 1

Production does'nt work ( Rails 5 , Passenger , Nginx )

Yalın Semer
1#
Yalın Semer Published in 2017-11-10 20:23:10Z

I deployed my app to server. ( Rails 5 , Passenger , Nginx ) My app was working on development mode. But i changed my mode to production and it i got this error ( /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>'

After this error i switched my mode to development. And i got same error again !

my nginx file :

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;

}

Need help to solve this problem !

Aakash Gupta
2#
Aakash Gupta Reply to 2017-11-10 21:35:46Z

So, it turned out that the problem was due to incorrect file permissions for the user.

Nginx was being run as www-data user which didn't have permissions to read files of the app-directory. That is why booting of app-server was failing.

sudo chown -R www-data:www-data /home/rails/myapp

After using above command, passenger will be able to read the files of app-directory and will successfully start.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.31843 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO