2

I've been sticking with this problem for a week. I cannot get my Rails application running via passenger module of Apache2. I use Ubuntu 12.04 64-bit with Rails 3.2.8 Ruby 1.9.3 Passenger 4.0.5. My Rails apps is at /home/sarunint/cafe_grader/web

This is my /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>

And this is my /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. If this is a duplicated topic, feel free to tell me :)

Thanks

Update

I've just noticed that when I restart Apache2 I got this :

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

Update 2 After doing some grep's by @mohamed-abshir, I got these lines :

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

Thanks.

Update 3

which ruby prints this : /home/sarunint/.rvm/rubies/ruby-1.9.3-p392/bin/ruby

cat /etc/apache2/mods-enabled/passenger.load prints this : LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so

and this is the file you want :

<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>
Sarun Intaralawan
  • 1,092
  • 3
  • 13
  • 30
  • possible duplicate of [Ruby on Rails Server options](http://stackoverflow.com/questions/4113299/ruby-on-rails-server-options) – rcd Mar 29 '14 at 23:28

3 Answers3

0

Since passenger 2.0 it's not following symlinks for DocumentRoot, the way passenger detects if its a ruby on rails application is looking for a config.ru one level behind the DocumentRoot directory. Suppose DocumentRoot is /var/www/public, it will search in /var/www for a config.ru file. But if www is a symlink to another location, let's say /var/www -> /home/ruby/my_app/public it will not follow the sym links so wouldn't be able to find the file and will not process the request.

To fix this, you can add to the httpd.conf:

PassengerResolveSymlinksInDocumentRoot on
Arnold Roa
  • 7,335
  • 5
  • 50
  • 69
-1

If your sitename is "example.com" then under ServerAdmin webmaster@localhost line, you need:

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

DocumentRoot should point to your site files and become:

DocumentRoot home/sarunint/cafe_grader/web/public

Your Directory block should be:

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

Then restart apache and go to your site url. I haven't checked your Ruby pointers, but basically on commandline when do "which ruby" the location that gets printed out, should match your what you posted above as your ruby interpreter.

Update

The op posted a note about passenger module being loaded again. When Passenger is installed normally via rvm, it tells you what commands to run and where to put the 3 lines of code that you posted above(they normally go under conf.d/passenger.conf). It appears there is "Passenger module is loaded twice" so go to your Apache directory search for it like:

 cd /etc/apache2/
grep -irl "LoadModule passenger_module" . # this searchs those words in current dir(don't remove the dot = current dir"
Community
  • 1
  • 1
salah-1
  • 1,299
  • 11
  • 15
  • Thanks for response, but I want to run this application as a directory, the user need to go to my.domain/grader in order to access the application. – Sarun Intaralawan Jun 18 '13 at 16:04
  • That shouldn't be problem with above. In Apache language "/grader" is path. Apache has to respond to "my.domain" first then look for path in your request. The block just sets permissions and stuff for your Folder. In Rails, you have to point DocRoot -> to /yourApp/public. – salah-1 Jun 18 '13 at 17:05
  • I updated the answer. Stuff i posted earlier, makes sure Apache & points to your Rails app -so those are important. The latest note is about Passenger module working correctly -little side issue. – salah-1 Jun 19 '13 at 15:05
  • I did that, please see the result in the main post. – Sarun Intaralawan Jun 25 '13 at 05:23
  • Can you post the result of the following two commands and updated & containers: "cat /etc/apache2/mods-enabled/passenger.load" "which ruby" – salah-1 Jun 25 '13 at 15:25
  • Got that posted, see the main post again, Thanks. PS. Sorry that it took some time. – Sarun Intaralawan Jun 26 '13 at 15:09
  • Is "RailsBaseURI /grader" working for you? Both documentRoot and Directory container are not pointing to your rails app(I have posted those in first day). If its not working for you, just follow my notes on Answer to set up the basic – salah-1 Jul 04 '13 at 03:15
-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>
Natus Drew
  • 1,876
  • 1
  • 21
  • 23