ruby-on-rails - 在 Mac OSX 上的 Apache 上部署 Rails - 403 禁止错误

标签 ruby-on-rails apache

我在过去一小时内浏览了 100 多个链接,但没有任何帮助。我想做的很简单:使用 passenger 在 apache 上部署一个 rails 应用程序。我遇到的问题是 403 Forbidden 错误。我的设置:

我运行这两个命令:

sudo gem install passenger
rvmsudo passenger-install-apache2-module

然后在 etc/apache2/other 中我创建了一个名为 Passenger.conf 的文件:

LoadModule passenger_module /Users/maq/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.14/buildout/apache2/mod_passenger.so
PassengerRoot /Users/maq/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.14
PassengerDefaultRuby /Users/maq/.rvm/wrappers/ruby-2.0.0-p247/ruby

然后在 /etc/apache2/extra/httpd-vhosts.conf 中,我有:

<VirtualHost *:80>
   ServerName rails.local
   DocumentRoot /webapps/coolapp/public
   <Directory /webapps/coolapp/public/>
      AllowOverride all
      Allow from all
      Options -MultiViews
   </Directory>
</VirtualHost>

然后在我的 /etc/hosts 文件中,我添加了这个条目:

127.0.0.1 rails.local

然后,我更改了我的 webapps 目录的权限:

sudo chmod -R 755 /webapps

然后我重新启动 Apache:

sudo apachectl restart

这些都不能解决问题。当我在浏览器中访问 rails.local 时,我总是得到同样的结果:

You don't have permission to access / on this server. Apache/2.2.22 (Unix) DAV/2 Phusion_Passenger/4.0.14 mod_ssl/2.2.22 OpenSSL/0.9.8x Server at rails.local Port 80

看在上帝的份上,有人告诉我可能是什么问题。

最佳答案

Apache 将无权访问 /。您应该从 /Library/WebServer/Documents/ 为您的网站提供服务,或者——取决于 Apache 配置为在哪个组下运行(在 OS X 中默认为 wheel)——你可以尝试 sudo chown -R root:wheel/webapps

编辑

我的 httpd.conf 配置有以下用户/组:

User: [my user] # is an admin user
Group: staff

关于ruby-on-rails - 在 Mac OSX 上的 Apache 上部署 Rails - 403 禁止错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18620449/

相关文章:

ruby-on-rails - 如何将我的 Rails 3.0.0 beta 4 应用程序更新到 Rails 3.0.0 RC 并最终更新到 Rails 3?

ruby-on-rails - 编译器未能生成可执行文件。 (运行时错误)

php - 向 Safari 提供大型(图像?)文件时出现问题

php - 单击 'Refresh' 会使 phpMyAdmin 崩溃

ruby-on-rails - 您如何使用Ruby on Rails 4.1.0beta1管理 secret key 和heroku?

jquery - 具有可调整大小部分的页面布局(是否使用 Jquery、Rails 插件)

ruby-on-rails - 在 Rails 4 中发送带有远程 true 的表单

apache - .htaccess 正则表达式 URL 重定向

java - Java 中的 Docx 到 Pdf 转换器

apache - 让 SSL 在 OSX 上与 Apache/Passenger 一起工作