Sinatra on Nginx configuration - what's wrong?

让人想犯罪 __ 提交于 2019-12-04 20:08:26

问题


I followed this tutorial more or less... I installed the passenger gem, executed passenger-install-ginx-module, sucessfully installed nginx and inserted this into the config:

server {
  listen 80;
  server_name localhost;
  root /home/admin/sintest/public;   # <--- be sure to point to 'public'!
  passenger_enabled on;
}

In /home/admin/sintest I have: an empty public folder, the config.ru:

require 'sinatra'

set :env,  :production
disable :run

require './app.rb'    #the app itself

run Sinatra::Application

and a test sinatra app.rb:

require 'sinatra'

get '/' do
  "hello world!"
end

Now when I run nginx and open up http://localhost what I get is: 403 Forbidden

What am I doing wrong? Have I missed something?


回答1:


Make sure that the user nginx is running as (in most cases 'nobody' or 'www-data') has permission to read the contents of your home directory /home/admin.

Also you can look into the nginx logs and read exactly what the error was.




回答2:


I had the same error until I added passenger_root and passenger_ruby directives in the http block.



来源:https://stackoverflow.com/questions/3710797/sinatra-on-nginx-configuration-whats-wrong

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!