我在过去一小时内浏览了 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/