DEPLOY A RAILS 3 APP IN RACKSPACE

Posted on June 20, 2011

0


EDIT: TO INSTALL MYSQLITE AND SQLITE3 USE THE FOLLWING:

yum install mysql-server mysql-libs mysql-devel
yum install sqlite sqlite-devel
THIS INSTALLS THE LIBRARIES
gem install sqlite3-ruby
THIS INSTALLS THE GEM

The steps to setup/deploy your rails application on a rackspace cloud server are given below. The steps given below worked for me. Along with the steps I am also putting up screenshots where I think they are necessary.

  • Login to the control panel of your account.
  • On the screen that appears after successful login, on the left habd side, click HostingàCloud Servers àAdd server

  • Then select the Operating system that you want.I selected fedora 14 and steps given below are for fedora 14.
  • Then select the type of RAM/Disk and fill in credentials like name etc.
  • Then you will see a screen like this:

 

Now you are ready to go.Now we need to setup rails on our server.You an click on console above and get started.My suggestion would be to use a ssh client like puTTy which can be downloaded from here.

  • Install the linux dependencues and required libraries:
sudo yum -y install gcc gcc-c++ make zlib zlib-devel openssl openssl-devel git expect pcre pcre-devel readline-devel mysql mysql-devel libxml2 libxml2-devel libxslt libxslt-devel
  • To install ruby 1.9.2 use the following snippet:
  1. wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-preview3.tar.gz
  2. tar -xvf ruby-1.9.2-preview3.tar.gz
  3. cd ruby-1.9.2-preview3
  4. ./configure
  5. make
  6. sudomakeinstall
  7. cd ..
  • Done.This will install ruby 1.9.2 in your system(server).To check type the following at the terminal:

 ruby -v

 

  • To install rubygems use the following (I installed version 1.3.7 and then updated it)
    • The latest version can be downloaded from  This link
  1.  wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
  2. tar -xvf rubygems-1.3.7.tgz
  3. cd rubygems-1.3.7
  4. sudo ruby setup.rb
  5. cd ..

  This should install rubygems to the system. To update it, use  

gem update –system

 

  • To install rails use the simple command
 gem install rails

this will install rails 3 in your system.

  • Create a directory  and make a blank rails application:
  1. mkdir  my_sample_rails_apps
  2. cd my_sample_rails_apps
  3. rails new test1

 

  • This will create a blank rails app.Now we can transfer an exisiting rails app using githhub.

To use github,we must have an account there.

  • In the new system, create a ssh key using:
ssh-keygen -t rsa -C youraddress@email.com

 The full tutorial to generate a key and transfer your application to git hub remote repository can be found at :  github tutorial for ssh keys

  • Now we can copy our project from github to our server using:
git clone git@github.com:your_username/your_project.git

now the whole project is in a directory called ‘your_project’(replace it with the name of your project)

  • Go in that directory using cd and then type :
 rails server

AND THE MAGIC BEGINS

 

I WILL BE COVERING   HOW TO MIGRATE DATABSES AS GITHUB DOES NOT MIGRATE DATABSES IN THE  NEXT POST.(COMING SOON)

Advertisements
Posted in: Rails app