Showing posts with label EC2. Show all posts
Showing posts with label EC2. Show all posts

Tuesday, June 5, 2012

Install apache & passenger for rails on amazon linux

First we need to have apache and curl-dev installed  using root..
sudo -s
yum install httpd httpd-devel
yum install libcurl-devel
exit

# now install passenger , if you have problems with gemfiles , fix them first. (check bundle )
gem install passenger
passenger-install-apache2-module

if all goes good you should get instructions like this :
---------------------------------------------------------------
Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/local/rvm/gems/ruby-1.9.3-head@smifr/gems/passenger-3.0.12/ext/apache2/mod_passenger.so
   PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-head@smifr/gems/passenger-3.0.12
   PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.3-head@smifr/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!


<VirtualHost *:80>
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public  
      <Directory /somewhere/public>
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      </Directory>
   </VirtualHost>

And that's it! You may also want to check the Users Guide for security and
optimization tips, troubleshooting and other useful information:

  /usr/local/rvm/gems/ruby-1.9.3-head@smifr/gems/passenger-3.0.12/doc/Users guide Apache.html

Enjoy Phusion Passenger, a product of Phusion (www.phusion.nl) :-)
http://www.modrails.com/
------------------------------
follow the instractions and update the httpd.conf file , to find it use the command :
apachectl -V

then restart apache using

apachectl -k restart

# After configuring httpd.conf the restart has an error, you need to provide more rights I did:
passenger-config --root
#Returns path_to_root
chcon -R -h -t httpd_sys_content_t /path_to_root


403 error :
You should set permissions for the rails app , so apache can access these files
I am runing:
chmod 755 /home/ec2-user/ -R

If still not working ..
in file: /etc/sysconfig/selinux
change to SELinux=enforced to SELinux=disabled






Monday, June 4, 2012

EC2 linux rvm ruby rails install steps

Steps to install ec2 amazon linux with rails


An old ruby version is required, currently it is intalled by default (v1.8.7), if not, install it using "yum install ruby" .

Steps

sudo -s
yum install -y git gcc-c++ autoconf automake make patch
yum install -y bzip2 readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel iconv-devel

curl -L get.rvm.io | bash -s stable

gpasswd -a ec2-user rvm
source /etc/profile.d/rvm.sh
yum install -y bison
run the follwing to see that things are OK:
rvm requirements 


## for problems with rvm and kernel header file:
vi /etc/yum.conf
change the line to comment : #exclude=kernel*
yum install kernel-headers  
======

Install ruby

rvm install 1.9.3-head


## create a new gemset and set the ruby and gemset to be default by rvm

rvm gemset create mygemset

rvm use 1.9.3-head@mygemset --default

# ruby is ready with rvm , now install rails (without documentation)

gem install rails -v 3.2.2 --no-rdoc --no-ri


next steps:
- install database 
- install passanger with apache