Sinatra on Nginx configuration - what's wrong?

2019-03-27 08:40发布

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?

2条回答
三岁会撩人
2楼-- · 2019-03-27 09:39

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.

查看更多
Luminary・发光体
3楼-- · 2019-03-27 09:47

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

查看更多
登录 后发表回答