使用Passenger部署Rails应用程序

4
我想使用apache和passenger将我的应用部署到本地服务器上。我安装了所有的前置条件,例如开发库和passenger gem。然后我将以下这些代码添加到了我的 /etc/apache2/httpd.conf 文件中;
PassengerRoot /home/insane-36/.rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11
PassengerRuby /home/insane-36/.rvm/wrappers/ruby-1.9.3-p125/ruby

现在,我在/etc/apache2/sites-available目录下创建了一个名为sampleapp的文件,并将以下内容放入其中:

<VirtualHost *:80>
 ServerName sampleapp
 RailsEnv development
 DocumentRoot /home/insane-36/Documents/Web/Rails/sampleapp/public
 <Directory /home/insane-36/Documents/Web/Rails/sampleapp/public>
  AllowOverride all
  Options MultiViews
  Order allow,deny
  Allow from all
 </Directory> 
</VirtualHost>

我启用了该网站并将主机名添加到/etc/hosts文件中。但是,当我现在尝试使用其ServerName浏览该网站时,它会给出权限被拒绝的错误;

Forbidden

You don't have permission to access / on this server.

Apache/2.2.20 (Ubuntu) Server at sampleapp Port 80

我不知道这里出了什么问题。我已经尝试多次编辑相同的文件,禁用网站、启用网站和重新加载 Apache。请您提供此问题及解决方案的建议。非常感谢您的帮助。

2个回答

1

这是目录权限的问题,而不是守护进程本身的问题;在DocumentRoot /home/insane-36/Documents/Web/Rails/sampleapp/public中是否有索引文件?它属于谁?Apache正在以什么身份运行?


1
我将整个Rails应用程序的权限设置为www-data,这是apache运行的虚拟用户。但是,我仍然无法正确地执行它。 - Sandeep
2
那么这怎么是答案呢?这个是如何工作的?我现在也遇到了同样的问题。谢谢。 - Igbanam

1

我知道这是一个老问题,但它仍然是谷歌搜索该错误的顶部结果。

解决方案是在

</Directory>

内添加Require all granted作为最后一行。

 <Directory /home/insane-36/Documents/Web/Rails/sampleapp/public>
  AllowOverride all
  Options MultiViews
  Order allow,deny
  Allow from all
  Require all granted
 </Directory>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接