abachuk
By:
abachuk

Can't launch Rails app with Nginx and passenger

September 12, 2013 9.4k views
Installed nginx, passenger 4.0.17, node, rails 4 and ruby 2, git and all gems. nginx config: ``` server { listen 80; server_name 162.243.1.111; root /home/abachuk/myapp/public; passenger_enabled on; rails_env production; } ``` ```sudo netstat -plutn | grep :80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1828/nginx ``` what else is missing?
11 Answers
Make sure /home/abachuk/myapp/public is viewable to the public.

What's the output of ls -l /home/abachuk/myapp/public?
the output is. Made public folder (chmod -R 755) 'public'
drwxr-xr-x 9 abachuk abachuk 4096 Sep 11 11:36 app
drwxr-xr-x 2 abachuk abachuk 4096 Sep 11 11:36 bin
drwxr-xr-x 5 abachuk abachuk 4096 Sep 11 11:36 config
-rwxr-xr-x 1 abachuk abachuk 161 Sep 11 11:36 config.ru
drwxr-xr-x 3 abachuk abachuk 4096 Sep 12 02:11 db
-rwxr-xr-x 1 abachuk abachuk 1474 Sep 12 02:41 Gemfile
-rwxr-xr-x 1 abachuk abachuk 4622 Sep 12 02:53 Gemfile.lock
drwxr-xr-x 4 abachuk abachuk 4096 Sep 11 11:36 lib
drwxr-xr-x 2 abachuk abachuk 4096 Sep 11 11:36 log
drwxr-xr-x 3 abachuk abachuk 4096 Sep 11 11:36 public
-rwxr-xr-x 1 abachuk abachuk 256 Sep 11 11:36 Rakefile
-rwxr-xr-x 1 abachuk abachuk 24 Sep 11 11:36 README.md
-rwxr-xr-x 1 abachuk abachuk 478 Sep 11 11:36 README.rdoc
drwxr-xr-x 8 abachuk abachuk 4096 Sep 11 11:36 test
drwxr-xr-x 6 abachuk abachuk 4096 Sep 11 11:36 tmp
drwxr-xr-x 3 abachuk abachuk 4096 Sep 11 11:37 vendor
Shouldn't owner:group be www-data:www-data; instead of abachuk:abachuk?
changed. Now I have. Restarted nginx and still see 403 forbidden.
drwxr-xr-x 9 www-data www-data 4096 Sep 11 11:36 app
drwxr-xr-x 2 www-data www-data 4096 Sep 11 11:36 bin
drwxr-xr-x 5 www-data www-data 4096 Sep 11 11:36 config
-rwxr-xr-x 1 www-data www-data 161 Sep 11 11:36 config.ru
drwxr-xr-x 3 www-data www-data 4096 Sep 12 02:11 db
-rwxr-xr-x 1 www-data www-data 1474 Sep 12 02:41 Gemfile
-rwxr-xr-x 1 www-data www-data 4622 Sep 12 02:53 Gemfile.lock
drwxr-xr-x 4 www-data www-data 4096 Sep 11 11:36 lib
drwxr-xr-x 2 www-data www-data 4096 Sep 11 11:36 log
drwxr-xr-x 3 www-data www-data 4096 Sep 11 11:36 public
-rwxr-xr-x 1 www-data www-data 256 Sep 11 11:36 Rakefile
-rwxr-xr-x 1 www-data www-data 24 Sep 11 11:36 README.md
-rwxr-xr-x 1 www-data www-data 478 Sep 11 11:36 README.rdoc
drwxr-xr-x 8 www-data www-data 4096 Sep 11 11:36 test
drwxr-xr-x 6 www-data www-data 4096 Sep 11 11:36 tmp
drwxr-xr-x 3 www-data www-data 4096 Sep 11 11:37 vendor
In nginx.conf, have you uncommented the lines?:

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

If not, do so & restart Nginx.
Also, what's the contents of /etc/nginx/sites-enabled?
nginx.config - I have
passenger_root /home/abachuk/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.17;
passenger_ruby /home/abachuk/.rvm/wrappers/ruby-2.0.0-p247/ruby;

/etc/nginx/sites-enabled - empty
by Etel Sverdlov
This tutorial explains how to install Ruby, how to install any required dependancies, how to install Ruby Gems, how to install Rails, how to install Phusion Passenger, and how to use Passenger to install nginx. Passenger is an app server that allows you to deploy your rails application in production. This tutorial describes how to run Rails with nginx using passenger.
yes. I also tried to launch with one click install. Rails 3 works fine. But rails 4 doesn't work anywhere. Not sure why. I guess I missed something. I created 3 droplets and tried to launch the app in 3 different ways. Unicorn, passenger, apache. Nothing works. I would appreciate any help. Thanks.
Do you have any symbolic links in /home/abachuk/myapp/public?
I was able to make it work. Here are details for those who have same issues
http://alexbachuk.com/launch-rails-4-application-with-passenger-and-nginx/
Have another answer? Share your knowledge.