如何使用rails应用程序配置带有乘客的nginx

Ash*_*ini 3 ruby ruby-on-rails passenger nginx ruby-on-rails-3.1

我已按照本教程https://www.digitalocean.com/community/articles/how-to-install-rails-and-nginx-with-passenger-on-ubuntu

我已经在我的虚拟机上安装了带有nginx的乘客并尝试访问该站点.

在根目录中我指定了路径root /var/rails_apps/public/;,给我欢迎来到Nginx页面,

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

            }
Run Code Online (Sandbox Code Playgroud)

由于我的网站的根页位于,/var/rails_apps/app/views/home/index.html.erb 所以我改变了路径root /var/rails_apps/app/views/home/;

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

        }
Run Code Online (Sandbox Code Playgroud)

但仍然为两个根我得到Welcome to Nginx页面.

我的请求URL是这样的 - > /#{IpAddressOfVirtualMachine}:80 /

当我指定不同的端口用于监听,例如1027然后它给我错误Unable to connect 请解释我如何使用nginx和乘客运行我的网站,是否还需要其他设置?

Ash*_*ini 5

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
Run Code Online (Sandbox Code Playgroud)

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 !!!
Run Code Online (Sandbox Code Playgroud)

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/