Ashwini
Ashwini

Reputation: 2497

How to configure nginx with passenger with rails application

I have followed this tutorial https://www.digitalocean.com/community/articles/how-to-install-rails-and-nginx-with-passenger-on-ubuntu

I have installed passenger with nginx on my virtual machine and trying to access the site.

In the root I have specified path as root /var/rails_apps/public/; which give me Welcome to Nginx page,

server{
                    listen 80;
                    server_name localhost;
                    root /var/rails_apps/public/;
                    passenger_enabled on;

            }

As my root page of my site is in the /var/rails_apps/app/views/home/index.html.erb so I changed the path to root /var/rails_apps/app/views/home/;

server{
                listen 80;
                server_name localhost;
                root /var/rails_apps/app/views/home/;
                passenger_enabled on;

        }

but still for both root I am getting Welcome to Nginx page.

My request URL is like this -> /#{IpAddressOfVirtualMachine}:80/

When I specified different port for listening eg 1027 then it gives me error Unable to connect Please explain how I can get my site running using nginx and passenger, is there any other setting required?

Upvotes: 3

Views: 6300

Answers (3)

Ashwini
Ashwini

Reputation: 2497

I am able run my site just did following changes.

Install nginx init script

nginx init script by Jason Giedymin helps us to administer web server easily.

$ cd
$ git clone git://github.com/jnstq/rails-nginx-passenger-ubuntu.git
$ sudo mv rails-nginx-passenger-ubuntu/nginx/nginx /etc/init.d/nginx
$ sudo chown root:root /etc/init.d/nginx

After that rails g controller pages home

And point root to public folder root /var/rails_apps/helloworld/public;

then access my virtual machine through http #{IpAddressOfVirtualMachine}:1027/pages/home

port 80 was busy so I used different which is port 1027

And it works !!!

you can refer this blog for more information http://ershadk.com/blog/2012/04/05/set-up-rails-3-2-2-with-passenger-rvm-and-ngnix/

Upvotes: 5

Mohammad AbuShady
Mohammad AbuShady

Reputation: 42899

You need to change the server name in the nginx config to the same IP you are connecting to, and yes keep the root in the public folder, that's how rails work.

server_name 123.456.789.000; # replace with your IP

Instead of localhost, then restart nginx.

Upvotes: 1

Santhosh
Santhosh

Reputation: 29174

Change the root back to public folder, and open the URL without the port number

Upvotes: 2

Related Questions