Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails nginx错误/home/deploy/myapp/current/public/";禁止_Ruby On Rails_Nginx_Ubuntu 14.04 - Fatal编程技术网

Ruby on rails nginx错误/home/deploy/myapp/current/public/";禁止

Ruby on rails nginx错误/home/deploy/myapp/current/public/";禁止,ruby-on-rails,nginx,ubuntu-14.04,Ruby On Rails,Nginx,Ubuntu 14.04,我尝试了一个类似问题的解决方案,以及stackoverflow上的许多其他问题,但似乎没有一个能解决这个问题。即使在我配置了/etc/nginx/passenger.conf和/etc/nginx/passenger.conf时,默认的niginx“欢迎”页面仍在运行。在我配置了/etc/nginx/sites enabled/default之后,通过更改rails应用程序的默认路径,我开始收到403禁止的错误 这是错误日志。 2017/02/20 06:05:17 [error] 27311#

我尝试了一个类似问题的解决方案,以及stackoverflow上的许多其他问题,但似乎没有一个能解决这个问题。即使在我配置了/etc/nginx/passenger.conf/etc/nginx/passenger.conf时,默认的niginx“欢迎”页面仍在运行。在我配置了/etc/nginx/sites enabled/default之后,通过更改rails应用程序的默认路径,我开始收到403禁止的错误

这是错误日志。

2017/02/20 06:05:17 [error] 27311#27311: *2 directory index of "/home/deploy/Blog/current/public/" is forbidden, client: 111.93.247.206, server: mydomain.com, request: "GET / HTTP/1.1", host: "35.154.168.57"
我的nginx文件如下

/etc/nginx/nginx.conf

user deploy;
worker_processes auto;
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/javascript text/xml application/xml application/xml+rss text/javascript;

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

        # include /etc/nginx/passenger.conf;

        ##
        # Virtual Host Configs
        ##

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


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.3.1/ruby;
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
#passenger_ruby /usr/bin/passenger_free_ruby;
/etc/nginx/passenger.conf

user deploy;
worker_processes auto;
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/javascript text/xml application/xml application/xml+rss text/javascript;

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

        # include /etc/nginx/passenger.conf;

        ##
        # Virtual Host Configs
        ##

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


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.3.1/ruby;
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
#passenger_ruby /usr/bin/passenger_free_ruby;
/etc/nginx/sites enabled/default

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        server_name mydomain.com;
        passenger_enabled on;
        rails_env    production;
        root         /home/deploy/Blog/current/public;

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}
权限为:

lrwxrwxrwx 1 root root 34 Feb 20 06:00 /etc/nginx/sites-enabled/default 
-rw-r--r-- 1 root root 179 Feb 20 06:35 /etc/nginx/passenger.conf
-rw-r--r-- 1 root root 1608 Feb 20 06:34 /etc/nginx/nginx.conf
有人能告诉我我做错了什么或我没有做什么吗? 谢谢

请按照以下步骤操作:

  • 备份/主页/部署/博客/当前/公共
  • chown-R:/home/deploy/Blog/current/public
  • nginxuser
    :运行nginx的用户,可能是以下用户之一:
    nginx
    www-data
    root
    遵循以下步骤:

  • 备份/主页/部署/博客/当前/公共
  • chown-R:/home/deploy/Blog/current/public

  • nginxuser
    :运行nginx的用户,可能是以下用户之一:
    nginx
    www-data
    root
    不确定您到底缺少了什么。请与上的“我的设置”对齐

    出现您的问题是因为nginx正在尝试将
    index.html
    文件搜索到
    /home/deploy/apps/mll/current/public
    中,但该文件不存在。 为了修复此问题,您需要使用nginx添加乘客

    要遵循的说明

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
    sudo apt-get install -y apt-transport-https ca-certificates
    
    添加乘客APT存储库

    sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'
    sudo apt-get update
    
    安装乘客和nginx

    sudo apt-get install -y nginx-extras passenger
    
    现在启动nginxwebserver

    sudo service nginx start
    
    接下来,我们需要更新Nginx配置,以指向我们正在使用的Ruby版本

    sudo vim /etc/nginx/nginx.conf
    
    和添加或取消注释

    include /etc/nginx/passenger.conf;
    
    保存并关闭nginx.conf。然后打开
    /etc/nginx/passenger.conf

    sudo vim /etc/nginx/passenger.conf
    
    如果您使用的是.rbenv,那么

    passenger_ruby /home/deploy/.rbenv/shims/ruby;
    
    或者,如果您正在使用rvm,则

    passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.5.0/ruby;
    
    或者,如果您使用的是SystemRuby,那么

    passenger_ruby /usr/bin/ruby;
    
    接下来,重新启动nginx服务器

    sudo service nginx restart
    
    添加
    passenger\u启用on编码到站点启用的/centers或站点启用的/nodeapp文件中

    server {
            listen 80;
            listen [::]:80;
    
            root /home/deploy/apps/mll/current/public;
            index index.html index.htm;
    
            server_name myrailssite.com;
            passenger_enabled on;
    
            location / {
                    try_files $uri $uri/ =404;
            }
    }
    
    重新启动nginx服务器,
    sudo服务nginx Restart
    。希望它能起作用

    有关更多详细信息,请参见,
    不确定你到底错过了什么。请与上的“我的设置”对齐

    出现您的问题是因为nginx正在尝试将
    index.html
    文件搜索到
    /home/deploy/apps/mll/current/public
    中,但该文件不存在。 为了修复此问题,您需要使用nginx添加乘客

    要遵循的说明

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
    sudo apt-get install -y apt-transport-https ca-certificates
    
    添加乘客APT存储库

    sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'
    sudo apt-get update
    
    安装乘客和nginx

    sudo apt-get install -y nginx-extras passenger
    
    现在启动nginxwebserver

    sudo service nginx start
    
    接下来,我们需要更新Nginx配置,以指向我们正在使用的Ruby版本

    sudo vim /etc/nginx/nginx.conf
    
    和添加或取消注释

    include /etc/nginx/passenger.conf;
    
    保存并关闭nginx.conf。然后打开
    /etc/nginx/passenger.conf

    sudo vim /etc/nginx/passenger.conf
    
    如果您使用的是.rbenv,那么

    passenger_ruby /home/deploy/.rbenv/shims/ruby;
    
    或者,如果您正在使用rvm,则

    passenger_ruby /home/deploy/.rvm/wrappers/ruby-2.5.0/ruby;
    
    或者,如果您使用的是SystemRuby,那么

    passenger_ruby /usr/bin/ruby;
    
    接下来,重新启动nginx服务器

    sudo service nginx restart
    
    添加
    passenger\u启用on编码到站点启用的/centers或站点启用的/nodeapp文件中

    server {
            listen 80;
            listen [::]:80;
    
            root /home/deploy/apps/mll/current/public;
            index index.html index.htm;
    
            server_name myrailssite.com;
            passenger_enabled on;
    
            location / {
                    try_files $uri $uri/ =404;
            }
    }
    
    重新启动nginx服务器,
    sudo服务nginx Restart
    。希望它能起作用

    有关更多详细信息,请参见,

    我以用户的身份“部署”运行nginx。我运行了
    chown-rdeploy:deploy/home/deploy/Blog/current/public
    。还是一样的错误。403禁止请验证
    passenger.conf
    中的两个路径是否正确。两个路径
    passenger\u ruby/home/deploy/.rvm/wrappers/ruby-2.3.1/ruby
    passenger\u root/usr/lib/ruby/vendor\u ruby/phusion\u passenger/locations.ini是否正确请添加
    passenger\u ruby/home/deploy/.rvm/wrappers/ruby-2.3.1/ruby;passenger\u root/usr/lib/ruby/vendor\u ruby/phusion\u passenger/locations.ini
    添加到http块中的
    nginx.conf
    ,然后重试。我在http标记中的/etc/nginx/nginx.conf文件中添加了这些行。现在我听到一个乘客说对不起的错误,但是出了点问题。已记录该问题以供调查。请稍后再试。在浏览器上。我以“部署”用户身份运行nginx。我运行了
    chown-rdeploy:deploy/home/deploy/Blog/current/public
    。还是一样的错误。403禁止请验证
    passenger.conf
    中的两个路径是否正确。两个路径
    passenger\u ruby/home/deploy/.rvm/wrappers/ruby-2.3.1/ruby
    passenger\u root/usr/lib/ruby/vendor\u ruby/phusion\u passenger/locations.ini是否正确请添加
    passenger\u ruby/home/deploy/.rvm/wrappers/ruby-2.3.1/ruby;passenger\u root/usr/lib/ruby/vendor\u ruby/phusion\u passenger/locations.ini
    添加到http块中的
    nginx.conf
    ,然后重试。我在http标记中的/etc/nginx/nginx.conf文件中添加了这些行。现在我听到一个乘客说对不起的错误,但是出了点问题。已记录该问题以供调查。请稍后再试。在浏览器上。