Sunday, February 12, 2012

Installing Rails 3.1.1, ruby 1.9.3, apache2, Passenger and Mysql on Ubuntu 11.10

To install Rails 3.1 on  fresh Ubuntu 11.10 I followed the following steps.


Note:
Currently I am running Ubuntu on a Virtual Machine (VMware Player )


Step 1: Install  libYAML from source
cd /usr/src
sudo wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
sudo tar xvzf yaml-0.1.4.tar.gz
cd yaml-0.1.4
sudo ./configure --prefix=/usr/local
sudo make 
sudo make install


Step 2: Install  required libraries
 sudo apt-get install libxml2-dev libxslt-dev libzlib1g zlib1g-dev build-essential openssl libssl-dev libmysqlclient16-dev


Step:3 Install ruby  from source file
cd /usr/src
sudo wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p0.tar.gz
sudo tar xvzf ruby-1.9.3-p0.tar.gz
cd ruby-1.9.3-p0
sudo ./configure --prefix=/usr/local --enable-shared --disable-install-doc --with-opt-dir=/usr/local/lib
sudo make
sudo make install


Step:4 Test proper ruby is installed
sudo ruby -v
The above command should display some thing as follows
ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]


Step 5: Install ruby gem
cd /usr/src 
sudo wget http://rubyforge.org/frs/download.php/75475/rubygems-1.8.11.tgz
sudo tar xvzf rubygems-1.8.11.tgz
cd rubygems-1.8.11
sudo ruby setup.rb


Step 6: Install Mysql server and Mysql client
sudo apt-get install mysql-server-5.1 mysql-client-5.1

Step 7: Install rails
sudo gem install rails


Step 8: Install apache2
sudo apt-get install apache2


Step 9: Install passenger
cd /usr/src 
sudo wget http://rubyforge.org/frs/download.php/75337/passenger-3.0.9.tar.gz
sudo tar xvzf  passenger-3.0.9.tar.gz
cd passenger-3.0.9
sudo ./bin/passenger-install-apache2-module  
Follow the instruction provided by the installer and restart the apache


Step 10: Install Node.js 
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs-dev


Step 11: Install readline library 
sudo apt-get install libreadline6-dev
cd /usr/src/ruby-1.9.3-p0/ext/readline
sudo ruby extconf.rb
sudo make
sudo make install


Step 12: Testing rails application
 a. create a new rails project. My project directory is /var/projects
     cd /var/projects
   sudo rails new demo --database=mysql
 b. create mysql database
     sudo mysql -u root -p 
     It prompts mysql password and provide the one which you provide at the time of
      installing Mysql server
     mysql> create database demo_developement;
  mysql> exit


c. Install  vim editor (optional) if  you are fond of vim
    sudo apt-get install vim vim-rails


 d. Update database.yml file
     cd /var/projects/demo
      Open database.yml and update 'password' attribute by using following command
      sudo vim config/database.yml


 e. Update apache configuration file and  update the virtual host entry shown below and restart
    sudo vim /etc/apache2/sites-enabled/000-default


  <VirtualHost *:80>
      ServerName localhost
      DocumentRoot /var/projects/demo/public
      RailsEnv development
      <Directory /var/projects/demo/public>
         AllowOverride all
         Options -MultiViews
      </Directory>
   </VirtualHost>
  sudo /etc/init.d/apache2 restart
f. Create log files
  sudo touch /var/projects/demo/log/development.log

Note:
1. You may get permission denied error something like
    "Permission denied - /var/projects/demo/tmp/cache/assets/CF0"
    To resolve this just give read and write permission for this folder. You can use the following command for   
     development environment
    sudo chmod 777 /var/projects/demo/tmp/cache/assets

2. To view apache log files you can use the following command
  sudo tail -f /var/log/apache2/error.log -n 100
     where "-n 100" denotes last 100 lines of error.log file

3. For installing Rails using RVM follow this blog


Reference:

No comments:

Post a Comment