Ruby on Rails Application Deployment with Passenger on Fedora

Installation:

  • Install apache development libraries
    • yum -y install httpd-devel
  • Install Passenger (Ruby on Rails Server used for Deployment)
    • gem install passenger
  • Install passenger-apache module (Passenger binding with Apache)

Configure virtual host for your RoR apps on apache server

  • cd /var/www/html
  • ln -s ~/myapp/public myapp
  • edit /etc/httpd/conf/httpd.conf
    • LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-3.0.6/ext/apache2/mod_passenger.so
    • PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-3.0.6
    • PassengerRuby /usr/bin/ruby
    • <VirtualHost *:80>
    •       RailsBaseURI /myapp
    •       <Directory /var/www/html/myapp>
    •            Options -MultiViews
    •            Options FollowSymLinks
    •       </Directory>
    • </VirtualHost>

Modify apache configuration on the proxy server

  • edit /etc/httpd/conf/httpd.conf
  • add following lines
    • <VirtualHost *:80>
    •       ProxyPass /myapp http://myhost/myapp
    •       ProxyPassReverse /myapp http://myhost/myapp
    • </VirtualHost>

Some quick tips

  • Use rails helper tags instead of direct html tags (e.g. ‘image_tag’ in place of ‘img src’, ‘link_to’ or ‘url_for’ in place of ‘a href’, etc)
  • Use javascript_include_tag and javascript_include_tag when stylesheet, images, javascripts are not loading.
  • Make sure public directory of ‘myapp’ has necessary permissions for apache user
  • If you are dealing with SELinux enabled server, you might want to take care of SELinux permissions for passenger as well (though SELinux enabled, permissive mode runs without any error! Hint!!!)
  • sub-URI has to be same for the host machine as well as proxy, when you are doning proxypass and reverse.
  • when you get “NameError: uninitialized constant ActiveSupport::Dependencies::Mutex ” error for Rails 2.3.x versions add line: require ‘thread’ to script/sever file
  • Helpful documentation: http://www.modrails.com/documentation/Users guide Apache.html

Feedback, expert comments welcome!

Thank You!
Ankit

3 Comments

  1. Sandeep says:

    why passenger instead of WEBrick ?

  2. Ankit Patel says:

    because webrick is not suitable because of it’s stability for production purpose.

  3. Vinod Kumar says:

    Hi

    I am using fedora 20.

    Writing below code in /etc/httpd/conf/httpd.conf is not starting the application.

    LoadModule passenger_module /usr/local/share/gems/gems/passenger-4.0.41/buildout/apache2/mod_passenger.so
    PassengerRoot /usr/local/share/gems/gems/passenger-4.0.41
    PassengerDefaultRuby /usr/bin/ruby

    RailsBaseURI /sampletestapp
    ProxyPass /sampletestapp http://127.0.0.1:3000
    ProxyPassReverse /sampletestapp http://127.0.0.1:3000

    Options -MultiViews
    Options FollowSymLinks

    In the browser If I give the url as “sampletestapp.com” its showing error as “Firefox can’t find the server at http://www.sampletestapp.com“.

    Please give your valuable suggessions.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

question razz sad evil exclaim smile redface biggrin surprised eek confused cool lol mad twisted rolleyes wink idea arrow neutral cry mrgreen

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

%d bloggers like this: