Ruby on Rails 3 Production Deployment

Create a user

Create the ror user 

sudo useradd -d /home/ror -g apache -s /bin/bash -m ror

Change the user starting Apache

  1. Start Apache as ror
    sudo vi /etc/httpd/conf/httpd.conf
    

    Change user to ror

    User ror
    
  2. Restart Apache
  3. sudo service httpd restart
    

Install Passenger on EC2 Amazon Linux

  1. Install Passenger Sofware Dependency
    • GNU C++ compiler:
    • Curl development headers with SSL support
    • Zlib development headers*
    • Apache 2 development headers:
    • Apache Portable Runtime (APR) development headers:
    • Apache Portable Runtime Utility (APU) development headers:
      sudo yum install libcurl-devel.x86_64
      sudo yum install zlib-devel.x86_64
      sudo yum install gcc gcc-c++ autoconf automake
      sudo yum install httpd-devel.x86_64
      
  2. Install Passenger
    sudo gem install passenger
    
  3. Install Apache 2 Plugin module for Ruby on Rails
    sudo passenger-install-apache2-module
    
    1. When asked to change Apache configuration
      sudo vi /etc/httpd/conf.d/passenger.conf
      
      LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.5/ext/apache2/mod_passenger.so
      PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-3.0.5
      PassengerRuby /usr/bin/ruby
      
    2. Restart Apache
      sudo service httpd restart
      

Add Virtual Host configuration

exit
sudo vi /etc/httpd/conf.d
   <VirtualHost *:80>
      ServerName www.company.com
      DocumentRoot /home/ror/app1/public   # <-- be sure to point to 'public'!
      <Directory /home/ror/app1/public>
         AllowOverride all              # <-- relax Apache security settings
         Options -MultiViews            # <-- MultiViews must be turned off
      </Directory>
   </VirtualHost>