繁体   English   中英

Nginx,Passenger,Ruby on Rails 4.1.6 Ubuntu 14-403禁止错误

[英]Nginx, Passenger, Ruby on Rails 4.1.6 Ubuntu 14 - 403 forbidden error

在发布此问题之前,我确实在stackoverflow上搜索了类似的问题,并且确实找到了很多问题,但是尽管遵循了其中给出的建议,但仍然遇到此错误。 我从头开始重新创建服务器3次,但仍然遇到相同的错误。

尝试访问网站时出现以下错误-

[error] 29931#0: *20 directory index of "/home/deploy/testapp/" is forbidden, 

我在使用Nginx,Passenger和Ruby on Rails(4.1.6)的Ubuntu 14.04。 我使用以下命令在家庭/部署文件夹下的服务器上创建了testapp

rails new testapp

然后我在/ etc / nginx / sites-available / testapp下创建了文件,内容如下-

server {
   listen 80 default_server;
   server_name 178.62.104.70;
   passenger_enabled on;
   #  #passenger_app_env development;
   root /home/deploy/testapp;
}

我已经使用rbenv安装了ruby,最后安装了我的nginx.conf文件的内容-

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##

 passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
# passenger_ruby /usr/bin/ruby;
passenger_ruby  /home/deploy/.rbenv/shims/ruby;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

}

更新:此命令返回了很多结果,所以我正在显示顶级信息

deploy@Test:~$ ls -lR /home/deploy/testapp/
/home/deploy/testapp/:
total 60
drwxrwxr-x 8 deploy deploy 4096 May 14 18:39 app
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 bin
drwxrwxr-x 5 deploy deploy 4096 May 14 18:39 config
-rw-rw-r-- 1 deploy deploy  154 May 14 18:39 config.ru
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 db
-rw-rw-r-- 1 deploy deploy 1338 May 14 18:41 Gemfile
-rw-rw-r-- 1 deploy deploy 2895 May 14 18:41 Gemfile.lock
drwxrwxr-x 4 deploy deploy 4096 May 14 18:39 lib
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 log
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 public
-rw-rw-r-- 1 deploy deploy  249 May 14 18:39 Rakefile
-rw-rw-r-- 1 deploy deploy  478 May 14 18:39 README.rdoc
drwxrwxr-x 8 deploy deploy 4096 May 14 18:39 test
drwxrwxr-x 3 deploy deploy 4096 May 14 18:39 tmp
drwxrwxr-x 3 deploy deploy 4096 May 14 18:39 vendor

/home/deploy/testapp/app:
total 24
drwxrwxr-x 5 deploy deploy 4096 May 14 18:39 assets
drwxrwxr-x 3 deploy deploy 4096 May 14 18:39 controllers
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 helpers
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 mailers
drwxrwxr-x 3 deploy deploy 4096 May 14 18:39 models
drwxrwxr-x 3 deploy deploy 4096 May 14 18:39 views

/home/deploy/testapp/app/assets:
total 12
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 images
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 javascripts
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 stylesheets

/home/deploy/testapp/app/assets/images:
total 0

/home/deploy/testapp/app/assets/javascripts:
total 4
-rw-rw-r-- 1 deploy deploy 664 May 14 18:39 application.js

/home/deploy/testapp/app/assets/stylesheets:
total 4
-rw-rw-r-- 1 deploy deploy 683 May 14 18:39 application.css

/home/deploy/testapp/app/controllers:
total 8
-rw-rw-r-- 1 deploy deploy  204 May 14 18:39 application_controller.rb
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 concerns

/home/deploy/testapp/app/controllers/concerns:
total 0

/home/deploy/testapp/app/helpers:
total 4
-rw-rw-r-- 1 deploy deploy 29 May 14 18:39 application_helper.rb

/home/deploy/testapp/app/mailers:
total 0

/home/deploy/testapp/app/models:
total 4
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 concerns

/home/deploy/testapp/app/models/concerns:
total 0

/home/deploy/testapp/app/views:
total 4
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 layouts

/home/deploy/testapp/app/views/layouts:
total 4
-rw-rw-r-- 1 deploy deploy 297 May 14 18:39 application.html.erb

/home/deploy/testapp/bin:
total 16
-rwxr-xr-x 1 deploy deploy 129 May 14 18:39 bundle
-rwxr-xr-x 1 deploy deploy 220 May 14 18:39 rails
-rwxr-xr-x 1 deploy deploy 164 May 14 18:39 rake
-rwxr-xr-x 1 deploy deploy 461 May 14 18:39 spring

/home/deploy/testapp/config:
total 36
-rw-rw-r-- 1 deploy deploy  978 May 14 18:39 application.rb
-rw-rw-r-- 1 deploy deploy  170 May 14 18:39 boot.rb
-rw-rw-r-- 1 deploy deploy  552 May 14 18:39 database.yml
-rw-rw-r-- 1 deploy deploy  150 May 14 18:39 environment.rb
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 environments
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 initializers
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 locales
-rw-rw-r-- 1 deploy deploy 1601 May 14 18:39 routes.rb
-rw-rw-r-- 1 deploy deploy  964 May 14 18:39 secrets.yml

/home/deploy/testapp/config/environments:
total 12
-rw-rw-r-- 1 deploy deploy 1422 May 14 18:39 development.rb
-rw-rw-r-- 1 deploy deploy 3163 May 14 18:39 production.rb
-rw-rw-r-- 1 deploy deploy 1661 May 14 18:39 test.rb

/home/deploy/testapp/config/initializers:
total 32
-rw-rw-r-- 1 deploy deploy 377 May 14 18:39 assets.rb
-rw-rw-r-- 1 deploy deploy 404 May 14 18:39 backtrace_silencers.rb
-rw-rw-r-- 1 deploy deploy 128 May 14 18:39 cookies_serializer.rb
-rw-rw-r-- 1 deploy deploy 194 May 14 18:39 filter_parameter_logging.rb
-rw-rw-r-- 1 deploy deploy 647 May 14 18:39 inflections.rb
-rw-rw-r-- 1 deploy deploy 156 May 14 18:39 mime_types.rb
-rw-rw-r-- 1 deploy deploy 139 May 14 18:39 session_store.rb
-rw-rw-r-- 1 deploy deploy 517 May 14 18:39 wrap_parameters.rb

/home/deploy/testapp/config/locales:
total 4
-rw-rw-r-- 1 deploy deploy 634 May 14 18:39 en.yml

/home/deploy/testapp/db:
total 4
-rw-rw-r-- 1 deploy deploy 343 May 14 18:39 seeds.rb

/home/deploy/testapp/lib:
total 8
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 assets
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 tasks

/home/deploy/testapp/lib/assets:
total 0

/home/deploy/testapp/lib/tasks:
total 0

/home/deploy/testapp/log:
total 0

/home/deploy/testapp/public:
total 16
-rw-rw-r-- 1 deploy deploy 1564 May 14 18:39 404.html
-rw-rw-r-- 1 deploy deploy 1547 May 14 18:39 422.html
-rw-rw-r-- 1 deploy deploy 1477 May 14 18:39 500.html
-rw-rw-r-- 1 deploy deploy    0 May 14 18:39 favicon.ico
-rw-rw-r-- 1 deploy deploy  202 May 14 18:39 robots.txt

/home/deploy/testapp/test:
total 28
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 controllers
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 fixtures
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 helpers
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 integration
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 mailers
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 models
-rw-rw-r-- 1 deploy deploy  312 May 14 18:39 test_helper.rb

/home/deploy/testapp/test/controllers:
total 0

/home/deploy/testapp/test/fixtures:
total 0

/home/deploy/testapp/test/helpers:
total 0

/home/deploy/testapp/test/integration:
total 0

/home/deploy/testapp/test/mailers:
total 0

/home/deploy/testapp/test/models:
total 0

/home/deploy/testapp/tmp:
total 4
drwxrwxr-x 3 deploy deploy 4096 May 14 18:39 cache

/home/deploy/testapp/tmp/cache:
total 4
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 assets

/home/deploy/testapp/tmp/cache/assets:
total 0

/home/deploy/testapp/vendor:
total 4
drwxrwxr-x 4 deploy deploy 4096 May 14 18:39 assets

/home/deploy/testapp/vendor/assets:
total 8
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 javascripts
drwxrwxr-x 2 deploy deploy 4096 May 14 18:39 stylesheets

/home/deploy/testapp/vendor/assets/javascripts:
total 0

/home/deploy/testapp/vendor/assets/stylesheets:
total 0

您应该将根指向公共目录:

server {
   listen 80 default_server;
   server_name 178.62.104.70;
   passenger_enabled on;
   #  #passenger_app_env development;
   root /home/deploy/testapp/public; #NOTICE PUBLIC HERE
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM