我在apache中使用乘客获取403错误

时间:2013-08-07 14:27:57

标签: ruby-on-rails apache passenger vhosts

我已经安装了所需的工具,并按照几个教程试图让乘客做出回应。

我可以访问公共文件夹中的静态文件(public / 500.html或422.hml)。昨天我通过vhost进入,发现一些乘客错误。但是一段时间后托管重新启动了服务,从那以后我再也无法访问rails应用程序了。

link

link

link

这些是我用来配置服务器的一些链接。我也读到这可能是一个许可问题;我已经检查过了,但我不确定它没问题。

4 个答案:

答案 0 :(得分:17)

首先检查您的错误日志。默认情况下,它位于/var/log/apache2/

如果您遇到client denied by server configuration问题,请在/etc/apache2/sites-available/your-site.conf检查您的网站配置文件。它必须符合Phusion Passenger User Guide。看看Require all granted

<Directory "/home/user/folder">
    Require all granted 
    Options FollowSymLinks
    # This relaxes Apache security settings.
    AllowOverride None
    # MultiViews must be turned off.
    Order allow,deny
    Allow from all
</Directory>

答案 1 :(得分:5)

对我来说这意味着我正在运行rails 2.3并使用Phusion Passenger 5.x

显然5.x根本不适用于2.2,并且2.3要求你先在config.ru文件中复制(这样rails会在后端使用rack)。

示例config.ru文件为2.3:

# Rack Dispatcher

# Require your environment file to bootstrap Rails
require File.dirname(__FILE__) + '/config/environment'

# Dispatch the request
run ActionController::Dispatcher.new

我无法弄清楚为什么没有咒语似乎有效,就像Passenger无视我的rails应用程序。

在我的/var/log/apache2/error.log文件中,我有这个:

  

[Mon May 11 15:47:00.397891 2015] [autoindex:error] [pid 17490:tid 3058694976] [client 216.49.181.251:49248] AH01276:无法提供目录/ home / x / y / railsapp / public / :找不到匹配的DirectoryIndex(index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm),以及Options指令禁止的服务器生成的目录索引,引用:https://www.google.com/ < / p>

令我感到困惑的是一个显然意味着“乘客没有在虚拟主机上运行”。

如果我创建了一个public / index.html文件,那么apache可以正常运行,因此它不是权限问题。

我也看到了这一点,这意味着乘客正好开始了:

  

[2015-05-11 18:23:53.9594 4964 / b7415700 agent / Watchdog / Main.cpp:728]:所有Phusion Passenger代理商已经开始了!

另见https://www.phusionpassenger.com/documentation/Users%20guide%20Apache%204.0.html#_i_get_a_403_forbidden_error

所以基本上使用乘客5.x(在发行说明中它表示不支持rails 2.2,只有在 root 中创建“config.ru”文件时才支持2.3你的rails应用程序。它适用于旧版本的机架,如rails 2.3所需,只需删除你的新机架宝石并安装1.1.6或者不支持,删除已售卖的机架宝石(如果有的话).GL!

另外作为旁注,这条消息:

  

[Mon May 11 18:25:10.235574 2015] [core:alert] [pid 5263:tid 3017780032] [client 127.0.0.1:56737] /home/rdp/dev/prod_flds/public/.htaccess:命令无效'RewriteEngine',可能由服务器配置中未包含的模块拼写错误或定义

意味着“删除您的公共/ .htaccess文件,通常不需要乘客”

答案 2 :(得分:2)

在我的Mac OS 10.9(一个类Unix系统)上,我在apache中使用passenger for rails也遇到403错误。 这里有一些提示:

  1. 您可以查看apache日志目录并查看发生的情况。 目录: / var / log / apache2 / error_log
  2. 问题:权限被拒绝:访问/拒绝(文件系统路径'path_apache_access'),因为路径组件上缺少搜索权限

    通过CLI检查'path_apache_access':ls -ld'path_apache_access'并使用chmod + x更改路径权限。

    另请注意:Httpd Wiki - (13) Permission Denied-

  3. 问题:配置错误:无法执行身份验证。 AuthType未设置!

    问题:客户端被服务器配置拒绝

    转到/etc/apache2/httpd.conf并查看&lt; Directory&gt;标签

    通过CLI检查apache版本: apachectl -v ,如果Apache&lt; 2.4,不要取消注释“要求全部授予”。

    <Directory "rails_app_directory/public">
          # This relaxes Apache security settings.
          AllowOverride all
          # MultiViews must be turned off.
          Options -MultiViews
          # Uncomment this if you're on Apache >= 2.4:
          # Require all granted
          Options FollowSymLinks
          Order allow,deny
          Allow from all
    </Directory>
    

答案 3 :(得分:1)

答案是乘客给了我403,因为我必须在apache配置上将环境变量“RackEnv”设置为“开发”(在我的情况下)。