乘客总是显示“索引”

时间:2013-06-18 15:18:15

标签: ruby-on-rails apache passenger

我一直坚持这个问题一个星期。我无法通过Apache2的乘客模块运行我的Rails应用程序。我使用64位的Ubuntu 12.04和Rails 3.2.8 Ruby 1.9.3 Passenger 4.0.5。 我的Rails应用程序位于/ home / sarunint / cafe_grader / web

这是我的/ etc / apache2 / sites-available / default

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /var/www
    RailsBaseURI /grader
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>

这是我的/etc/apache2/httpd.conf

LoadModule passenger_module /home/sarunint/.rvm/gems/ruby-1.9.3-p392/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
PassengerRoot /home/sarunint/.rvm/gems/ruby-1.9.3-p392/gems/passenger-4.0.5
PassengerRuby /home/sarunint/.rvm/wrappers/ruby-1.9.3-p392/ruby

PS。如果这是一个重复的主题,请随时告诉我:)

由于

更新

我刚才注意到,当我重新启动Apache2时,我得到了这个:

sarunint@server1:~$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                 
[Tue Jun 18 23:05:56 2013] [warn] module passenger_module is already loaded, skipping
... waiting [Tue Jun 18 23:05:57 2013] [warn] module passenger_module is already loaded, skipping

更新2 在@ mohamed-abshir做了一些grep之后,我得到了以下几行:

sarunint@server1:/etc/apache2$ grep -irl "LoadModule passenger_module" .
./mods-available/passenger.load
./mods-enabled/passenger.load
./httpd.conf

感谢。

更新3

which ruby打印出来: /home/sarunint/.rvm/rubies/ruby-1.9.3-p392/bin/ruby

cat /etc/apache2/mods-enabled/passenger.load打印出来: LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so

这是你想要的文件:

<VirtualHost *:80>
        ServerName sarunint.uni.me
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        RailsBaseURI /grader
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
    <Directory /home/sarunint/cafe_grader/web/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

3 个答案:

答案 0 :(得分:0)

由于乘客2.0不遵循DocumentRoot的符号链接,因此乘客检测到它的ruby on rails应用程序是否在config.ru目录后面寻找DocumentRoot一级的方式。假设DocumentRoot/var/www/public,它将在/var/www中搜索config.ru文件。但是,如果www是另一个位置的符号链接,让我们说/var/www -> /home/ruby/my_app/public它不会跟随sym链接,因此无法找到该文件,也不会处理该请求。

要解决此问题,您可以添加到httpd.conf

PassengerResolveSymlinksInDocumentRoot on

答案 1 :(得分:-1)

如果您的网站名称为“example.com”,则在ServerAdmin网站管理员@ localhost行下,您需要:

ServerName  example.com
ServerAlias www.example.com  #not necessary

DocumentRoot应指向您的网站文件并成为:

DocumentRoot home/sarunint/cafe_grader/web/public

您的目录块应为:

<Directory /home/sarunint/cafe_grader/web/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

然后重启apache并转到您的网站网址。 我没有检查过你的Ruby指针,但基本上是在命令行上,当打印出来的那个“ruby”时,应该与你上面发布的ruby解释器相匹配。

更新

op发布了关于乘客模块再次加载的说明。 当Passenger通过rvm正常安装时,它会告诉您要运行的命令以及放置上面发布的3行代码的位置(它们通常位于conf.d / passenger.conf下)。它似乎有“Passenger模块加载两次”所以转到你的Apache目录搜索它:

 cd /etc/apache2/
grep -irl "LoadModule passenger_module" . # this searchs those words in current dir(don't remove the dot = current dir"

答案 2 :(得分:-2)

<VirtualHost *:80>

#this isn't working, it's running under drew
PassengerDefaultUser www-data

ServerAdmin youremail@mail.com
ServerName mysite.localhost.com

Options ExecCGI -MultiViews +SymLinksIfOwnerMatch

DocumentRoot /var/www/rails/ridcyDevelopment/public
RailsEnv development
#RailsBaseURI /

<Directory /var/www/rails>
  Options Indexes FollowSymLinks -MultiViews +ExecCGI
  AllowOverride all
  Allow from All
</Directory>