Topic: Apache 2 + Passenger + RoR3 + newbie

Hi everybody big_smile

I want to set up in production mode a web site in ruby on rails on a personal server.
This one has to integrate a set of php website; I'll explain:

I currently have this configuration:

/var/www => Website in php (accessible via "my_ip")
/var/www/blog => Website in php (accessiblee via "my_ip/blog")
/var/www/others => Website in php (accessiblee via "my_ip/others")
...

I want to integrate and use my WebSite in RoR like that :

/var/www/tracker => Sous-site/script en RoR (accesible via "my_ip/tracker")

So I put the code for my Ruby on Rails in the tracker folder and change my conf apache like this:

FILE apache2.conf in /etc/apache2/

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-\3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-p125/ruby

file : default in /etc/apache2/site-available/

<VirtualHost *:80>
        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
        <Directory /var/www/others/>
   #...
        </Directory>

#<============HERE IS WHAT I ADD=============>
#<=======================================>
     RailsBaseURI /tracker
     <Directory /var/www/tracker/>
        AllowOverride all
        Options -MultiViews
     </Directory>
#<=======================================>
</VirtualHost>

I got the following error:
Passenger Error

In fact he was trying to get to the config/environment.rb file using this path:
/var/www/config/environment.rb
instead of this path:
/var/www/tracker/config/environment.rb

Where did i do a mistake and how can I solve this problem?

Thanks

Last edited by yoshyn (2012-04-01 09:33:10)

Re: Apache 2 + Passenger + RoR3 + newbie

There should be only ONE Document root per virtual server,  here is an example of a correct setup for passenger enabled apache RoR site

<VirtualHost *:80>
  SuexecUserGroup "#1000" "#1000"
  ServerName bigskynativeart.com
  ServerAlias www.bigskynativeart.com
  DirectoryIndex index.html dispatch.fcgi
  DocumentRoot /home/jill/bsna/public
  CustomLog /home/jill/logs/access_log combined
  ScriptAlias /cgi-bin/ /home/jill/cgi-bin/
  ScriptAlias /fcgi-bin/ /home/jill/fcgi-bin/
  <Directory /home/jill/bsna/public>
    Options -Indexes IncludesNOEXEC FollowSymLinks -MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
  <Directory /home/jill/cgi-bin>
    Order allow,deny
    Allow from all
  </Directory>
  <Directory /home/jill/fcgi-bin>
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Apache 2 + Passenger + RoR3 + newbie

My apologize but i did not understand your answer.
My only one apache configuration file for the sites availables is "default" (on my first message).

And in this file, i have only one virtualHost with only one DocumentRoot witch is "/var/www"
(In fact, all my websites in php are simply drop in a folder, there's no several virtual host for them).

Do i have to create a virtual host only for RoR?

Thanks for your answer smile

Re: Apache 2 + Passenger + RoR3 + newbie

No,  you only have to create a virtual host if you want more than one website served up by Apache,  if your RoR site is the ONLY site to be served by Apache/Passenger,  you don't need to create a virtual host.

It looked like you ADDED the code you posted,  but it sounds like you REPLACED the previous code with what you commented at the bottom.

I think you'd need to post your httpd.conf to see what the problem is,  but you're not configured correctly because Passenger can't find config/environment.rb

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Apache 2 + Passenger + RoR3 + newbie

I think I understand what is going on,  you have several PHP based sites,  and you want to deploy a RoR site that is aware of the PHP sites,  and ALL of these sites will be deployed on a single Apache/Passenger configuration,  is that correct?

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Apache 2 + Passenger + RoR3 + newbie

Sorry if what i write can be misinterpreted, english is not my native language.

I already posted the end of my httpd.conf (well, on my server it's a file name apache2.conf).
The 3 lignes i posted above are the only one i added in, the rest is by default.

Concerning the configuration of my VirtualHost, here it is:

<VirtualHost *:80>
        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /var/www/>
    #Some apache directive for a presentation website
        </Directory>

  <Directory /var/www/blog/>
    #Some apache directive for my blog in php (like wordpress)
  </Directory>

  <Directory /var/www/proxy/>
    #Some apache directive for a little proxy script in php
  </Directory>

  <Directory /var/www/share/>
    #Some apache directive for an upload system in 
  </Directory>

#<============HERE IS WHAT I ADD=============>
#<==== To support a tracker when people go on my_ip/tracker =========>
     RailsBaseURI /tracker
     <Directory /var/www/tracker/>
        AllowOverride all
        Options -MultiViews
     </Directory>
</VirtualHost>
BradHodges wrote:

I think I understand what is going on,  you have several PHP based sites,  and you want to deploy a RoR site that is aware of the PHP sites,  and ALL of these sites will be deployed on a single Apache/Passenger configuration,  is that correct?

Exactly. In fact, i already have some websites in php (and it works fine) and i want to add a website in a subdirectory in rails.

Re: Apache 2 + Passenger + RoR3 + newbie

OK,  then be aware that when you deploy a Rails site and another site on apache,  they will have no knowledge of each other at the apache level,  as far as apache is concerned,  they are just two  stand alone websites.  In that case you will need at least TWO virtual hosts in the Apache config.

I've never deployed a php site,  so I don't know how that is done,  it sounds like there is some method to deploy multiple PHP sites as ONE Apache website.  If that's the case,  then you'll still need TWO virtual hosts,  one to deploy the Rails site,  one to deploy the multiple PHP sites.  But again , I'm not sure.

What I think you need to do is FIRST get the rails site deployed as a virtual host,  that's what I posted.  In my httpd.conf where I deploy multiple RoR websites,  the last line is:

Include etc/httpd/virtualhosts/*.conf

There is only ONE file in that directory,  and in that file there are multiple versions of what I posted earlier,  one after the other,  the only difference between each is the url of the website and the location of the rails root directory.   I think you need to do something similar,  you need to take all the website specific stuff in your apache2.conf,  and converting into a VirtualHost definition,  you don't have to seperate it into a seperate file and include it,  you just need to end up with your apache2.conf file looking something like

LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-p125/gems/passenger-\3.0.11/ext/apache2/mod_passenger.so
...  a bunch of other stuff
<VirtualHost *:80>
  # the definition of the rails site, like I posted earlier
</VirtualHost>
<VirtualHost *:80>
  # the definition of one (or more???) of your php site(s)
</VirtualHost>

The knowledge that the rails site has of your OTHER PHP sites will exist ONLY in the rails site,  Apache will know nothing about it!

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Apache 2 + Passenger + RoR3 + newbie

I was sick several weeks and I forgot to answer ...

I solved my problem.

In fact I tried to configure the apache folder where I set my app sources while it was sufficient to:
1) Make the symbolic link
2) Set RailsBaseURI / MyApp
3) Especially do not do anything else!


Thanks for your help.