首先检查您的错误日志。默认情况下,它位于/var/log/apache2/
。
如果您遇到client denied by server configuration
问题,请检查您的网站配置文件/etc/apache2/sites-available/your-site.conf
是否符合Phusion Passenger用户指南的规定。请注意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>
对我来说,这意味着我正在运行Rails 2.3,并使用Phusion Passenger 5.x。
显然,5.x根本无法与2.2配合使用,在2.3中需要先复制一个config.ru文件(以便Rails使用Rack作为后端)。
2.3的示例config.ru文件:
# Rack Dispatcher
# Require your environment file to bootstrap Rails
require File.dirname(__FILE__) + '/config/environment'
# Dispatch the request
run ActionController::Dispatcher.new
这让我感到非常困惑,显然意味着"Passenger没有在该虚拟主机上运行"。如果我创建了一个public/index.html文件,Apache可以很好地提供服务,因此这不是权限问题。我还看到了这个,这意味着Passenger启动正常:[Mon May 11 15:47:00.397891 2015] [autoindex:error] [pid 17490:tid 3058694976] [client 216.49.181.251:49248] AH01276: Cannot serve directory /home/x/y/railsapp/public/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive, referer: https://www.google.com/
[ 2015-05-11 18:23:53.9594 4964/b7415700 agents/Watchdog/Main.cpp:728 ]: All Phusion Passenger agents started!
基本上,使用Passenger 5.x(在发布说明中说不支持Rails 2.2,只有在Rails应用程序的根目录中创建“config.ru”文件才支持2.3。它可以与像Rails 2.3这样的旧版本的Rack一起使用,只需删除较新的Rack gem并安装1.1.6或其他版本,如果有任何vendored Rack gems,请将其删除。祝好运!
另外顺带一提,这条消息:
[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: Invalid command 'RewriteEngine',也许拼写错误或由未包含在服务器配置中的模块定义
意思是“删除您的public/.htaccess文件,通常不需要使用乘客”
我在Mac OS 10.9上使用Apache和Passenger运行Rails时,也遇到了403错误(Unix类系统)。
以下是一些提示:
Issue: Permission denied: access to / denied ( filesystem path 'path_apache_access' ) because search permissions are missing on a component of the path.
Check 'path_apache_access' by CLI: ls -ld 'path_apache_access' and use chmod +x to change the path privilege.
Also, note this: Httpd Wiki - (13) Permission Denied-.
Issue: configuration error: couldn't perform authentication. AuthType not set!.
Issue: client denied by server configuration.
Go to /etc/apache2/httpd.conf and take a look on <Directory> tag.
Check apache version by CLI: apachectl -v, if Apache < 2.4, do NOT uncomment "Require all granted".
<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>