[英]ruby on rails nginx with passenger can't find views
I'm putting together my first ROR app on NginX and Passenger. 我正在将我的第一个ROR应用放在NginX和Passenger上。 I'm following tutorials all over the web and I'm getting the following errors when I try to go to my home page.
我正在网上浏览所有教程,尝试转到主页时遇到以下错误。
I created a controller home_controller.rb using the command line. 我使用命令行创建了一个控制器home_controller.rb。 I also created the views at the command line which made a default ERB file.
我还在命令行中创建了默认ERB文件的视图。
The nginx service is running and I start passenger manually via "passenger start". Nginx服务正在运行,我通过“乘客启动”手动启动乘客。 I can see passenger accepting the incoming HTTP requests as in the following errors.
我可以看到乘客接受传入的HTTP请求,如以下错误所示。 What's strange though is that it's looking in the public folder of my ruby app for home/index.
不过奇怪的是,它正在我的ruby应用程序的公用文件夹中查找home / index。 I used "rails generate [controller/view] foo" which writes files outside of public.
我使用了“ rails generate [controller / view] foo”,它在公共场所之外写入文件。
My nginx config is configured to point to the public folder of my ROR project. 我的nginx配置配置为指向我的ROR项目的公用文件夹。
I'm using ROR 2.0.0, Phusion Passenger 4.0.29, and nginx 1.1.19. 我正在使用ROR 2.0.0,Phusion Passenger 4.0.29和nginx 1.1.19。
Am I missing something in Passenger to tell it where the controllers/views/etc. 我是否在旅客中遗漏了一些东西来告诉它控制器/视图/等的位置。 are?
是?
mj j
2013/12/13 15:20:12 [error] 18305#0: *4 "/usr/development/sandbox/app/public/index.html"
is not found (2: No such file or directory), client: 127.0.0.1, server: _, request: "HEAD /
HTTP/1.1", host: "0.0.0.0"
2013/12/13 15:20:13 [error] 18305#0: *5 "/usr/development/sandbox/app/public/index.html"
is not found (2: No such file or directory), client: 127.0.0.1, server: _, request: "GET
HTTP/1.1", host: "localhost:3000"
2013/12/13 15:20:18 [error] 18305#0: *5 open()
"/usr/development/sandbox/app/public/home/index" failed (2: No such file or directory),
client: 127.0.0.1, server: _, request: "GET /home/index HTTP/1.1", host: "localhost:3000"
2013/12/13 15:27:11 [error] 18305#0: *13 open()
"/usr/development/sandbox/app/public/home/index" failed (2: No such file or directory),
client: 127.0.0.1, server: _, request: "GET /home/index HTTP/1.1", host: "localhost:3000"
edit 0 - if I use "rails server", everything seems to work fine /edit 0 编辑0-如果我使用“ rails服务器”,一切似乎都正常/ edit 0
You are using Phusion Passenger in the wrong way. 您以错误的方式使用了Phusion Passenger。
Phusion Passenger provides 3 modes : a standalone mode (one that runs as a standalone web server), an Nginx integration mode, and an Apache integration mode. Phusion Passenger提供3种模式 :独立模式(一种作为独立Web服务器运行),Nginx集成模式和Apache集成模式。 By running
passenger start
, you are using its standalone mode. 通过运行
passenger start
,您正在使用其独立模式。
You also have Nginx running. 您还可以运行Nginx。 And from your logs, it looks like you are accessing Nginx.
从您的日志中,您似乎正在访问Nginx。 But that doesn't do anything.
但这无济于事。 Passenger is running standalone and is not running inside Nginx.
乘客独立运行,不在Nginx内部运行。
In a diagram: 在图中:
Nginx <--------------------- [Your request]
(Not integrated with Passenger,
so doesn't know what to do with
your request)
Passenger Standalone
(waiting for your request,
but you never sent one
to it)
So here's how it looks like if you use rails server
: 因此,这就是使用
rails server
时的样子:
Nginx
(not receiving any
requests from you)
rails server <--------------- [Your request]
What you actually want is to access Passenger Standalone, which -- just like rails server
would -- listens on port 3000. In fact, Passenger Standalone told you during startup that it's listening on port 3000. 您真正想要的是访问Passenger Standalone,就像
rails server
一样,它监听3000端口。实际上,Passenger Standalone在启动过程中告诉您它监听的是3000端口。
Nginx
(not receiving any
requests from you;
so you may as well
disable it)
Passenger Standalone <--------------- [Your request]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.