0

几天来,我一直在尝试让 Rails 应用程序在 Bluehost 上的乘客下运行,但没有运气。转到我希望它运行的子域,我只得到一个包含 cgi-bin 和公共子目录的目录列表。不执行 rails 应用程序。

httpd.conf 包括:

LoadModule passenger_module /usr/local/rvm/gems/ruby-2.2.1/gems/passenger-5.0.6/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/local/rvm/gems/ruby-2.2.1/gems/passenger-5.0.6
  PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.2.1/wrappers/ruby
</IfModule>

<VirtualHost 162.144.138.43:80>
  ServerName secure.xxxxx.com
  ServerAlias www.secure.xxxxx.com
  DocumentRoot /home/diamoou1/public_html/securefinance
  ServerAdmin webmaster@secure.xxxxx.com
  UseCanonicalName Off
  CustomLog /usr/local/apache/domlogs/secure.xxxxx.com combined
  CustomLog /usr/local/apache/domlogs/secure.xxxxx.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
  ## User diamoou1 # Needed for Cpanel::ApacheConf
  UserDir enabled diamoou1
  <IfModule mod_suphp.c>
    suPHP_UserGroup diamoou1 diamoou1
  </IfModule>
  <IfModule !mod_disable_suexec.c>
    <IfModule !mod_ruid2.c>
        SuexecUserGroup diamoou1 diamoou1
    </IfModule>
  </IfModule>
  <IfModule mod_ruid2.c>
      RUidGid diamoou1 diamoou1
  </IfModule>
  ScriptAlias /cgi-bin/ /home/diamoou1/public_html/securefinance/cgi-bin/

  <Directory /home/diamoou1/public_html/securefinance>
    Options -MultiViews
    AllowOverride All
  </Directory>

</VirtualHost>

在 /home/diamoou1/public_html/securefinance/public 我有 .htaccess 文件:

<IfModule mod_passenger.c>
  Allow from all
  Order Deny,Allow
  Options +FollowSymLinks -SymLinksIfOwnerMatch -MultiViews
  PassengerResolveSymlinksInDocumentRoot on
  #Set this to whatever environment you'll be running in
  RailsEnv production
  RackBaseURI /
  SetEnv GEM_HOME /home/diamoou1/ruby/gems
</IfModule>

暂时在 .htaccess 文件中放置一个坏行会在日志中产生预期的错误,因此显然 apache 正在读取 .htaccess 文件。

我怀疑问题可能出在 RackBaseURI 中。我以root身份安装了Passenger。RackBaseURI 解析为 /root 并且有一个 /root/public_html 目录,尽管 apache 正在提供 /home/diamoou1/public_html/securefinance 目录(rails 应用程序实际所在的位置)。我不知道如何更改该变量,否则这就是问题所在。PassengerBaseURI 是一样的。

我该怎么做才能解决这个问题??????

4

1 回答 1

0

这可能会对您有所帮助:https ://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#_tutorial_example_writing_and_deploying_a_hello_world_rack_application

这是 Phusion Passenger 提供的示例配置:

<VirtualHost *:80>
    ServerName www.rackexample.com
    DocumentRoot /webapps/rack_example/public
    <Directory /webapps/rack_example/public>
        Allow from all
        Options -MultiViews
        # Uncomment this if you're on Apache >= 2.4:
        #Require all granted
    </Directory>
</VirtualHost>

DocumentRoot 和 Directory 应该指向您的 rails 应用程序的公共文件夹,而不是根目录。

你应该改变:

...
DocumentRoot /home/diamoou1/public_html/securefinance
...
<Directory /home/diamoou1/public_html/securefinance>
...

至 :

...
DocumentRoot /home/diamoou1/public_html/securefinance/public
...
<Directory /home/diamoou1/public_html/securefinance/public>
...
于 2015-04-22T13:15:41.007 回答