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)
- passenger-install-apache2-module
- if error prompted to fix apache.rb
- vi /usr/lib/ruby/gems/1.8/gems/passenger-3.0.6/lib/phusion_passenger/platform_info/apache.rb
- Go to line no 277
- replace “test_exe_outdir” with “tmpexedir”
- Run again: passenger-install-apache2-module
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