Rails nginx目录索引被禁止

时间:2013-08-30 11:02:38

标签: ruby-on-rails-3 nginx production-environment

你好我设置我的第一个web服务器,但是当我复制rails应用程序并运行nginx服务器时,我在浏览器中得到403错误并且error.log说目录索引是禁止的...当我创建index.html时错误解决了在rails应用程序的公共文件夹中,但为什么rails没有启动? (服务器被乘客称为)并且在rails应用程序内部捆绑安装工作。谢谢。

/opt/nginx/conf/nginx.conf

http {
    passenger_root /home/lukas/.rvm/gems/ruby-1.9.3-p448@rails3/gems/passenger-4.0.14;
    passenger_ruby /home/lukas/.rvm/wrappers/ruby-1.9.3-p448@rails3/ruby;
    include /opt/nginx/conf.d/*.conf; 
...
}

/opt/nginx/conf.d/default.conf

server {
 listen *:80;
 server_name hostname.org www.hostname.org

 passenger_enabled on;
 rails_env production;
 root /var/www/default/public;

 error_log /opt/nginx/logs/vhosts/default/error.log;
 access_log /opt/nginx/logs/vhosts/default/access.log combined;
}

文件夹权限

lukas@webserver:/var/www$ ls -al
drwxrwxr-x 13 lukas lukas 4096 Aug 30 12:26 default

im 使用

启动nginx
sudo /etc/nginx/sbin/nginx

/opt/nginx/logs/vhosts/default/error.log

2013/08/30 12:48:08 [error] 32643#0: *1 directory index of "/var/www/default/public/" is forbidden, client: xx.xx.xx.xx, server: ...

1 个答案:

答案 0 :(得分:0)

Nginx需要具有该文件的读取权限以及该文件的每个分层父目录的执行权限,以及chdir,并且有时,index指令不包含所需的目录索引。