GhostScript upgrade for Amazon Ec2-linx

1) SSH into instance

2) Now as root user

  • sudo su
  • sudo make install
  • make soinstall && install -v -m644 base/*.h /usr/include/ghostscript && ln -v -s ghostscript /usr/include/ps
  • ln -sfv ../ghostscript/9.14/doc /usr/share/doc/ghostscript-9.14
  • wget
  • tar -xvzf ghostscript-fonts-std-8.11.tar.gz
  • tar -xvf ghostscript-fonts-std-8.11.tar.gz -C /usr/share/ghostscript –no-same-owner && fc-cache -v /usr/share/ghostscript/fonts/

3) Now check ghostscript version

  • Ghostscript
  • gs –v

Please let me know if anyone need more information on this.

Manage multiple SSH keys

SSH keys are a very efficient way to make secure connections over the internet, for a large variety of things.

Many things use SSH keys regularly, for example using Git on GitHub requires you to register a key to use when accessing repositories.
Most of the time, however, their help guides only explain how to create a single key and use it with their service. If you use multiple services that use SSH, you could use the same key for all of them but that would be less secure and would mean having to change your key on each one if you have to change it at any point.

The obvious thing to do is to create multiple keys. This is a quick little tutorial on how to create and manage multiple SSH keys using a Linux terminal. If anyone knows the Windows equivalent, please let me know and I’ll add it to this post.

Creating Keys

Let’s start with the basics, the most important thing to be able to do here is to create a key.

Simply open up a new terminal and do the following:
cd ~/.ssh
If you get a response saying the directory does not exist run mkdir ~/.ssh and then repeat.
You will be prompted for an output file, just leave it blank and press enter.
You will now be prompted for a passphrase, and then to repeat the passphrase. Do not forget this passphrase, it’s the “lock” for the key.
Once the key has been created you need to add it to the key manager, using ssh-add id_rsa and enter the passphrase you just used.

Script started on Tue 24 Apr 2012 14:15:45 BST
joe@beast:~$ cd ~/.ssh
joe@beast:~/.ssh$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/joe/.ssh/id_rsa): [Press Enter] 
Enter passphrase (empty for no passphrase): [Enter A Passphrase] 
Enter same passphrase again: [Repeat Passphrase] 
Your identification has been saved in /home/joe/.ssh/id_rsa.
Your public key has been saved in /home/joe/.ssh/
The key fingerprint is:
c0:73:11:d7:6e:bc:09:0e:89:62:30:38:e8:e3:fc:17 joe@beast
The key's randomart image is:
+--[ RSA 2048]----+
|..      o...     |
|+ o  .   o  .    |
|.. o  +... o     |
| o  o .+o . +    |
|o .. .  So o o   |
| o   E    . o    |
|  .   .          |
|   . .           |
|    .            |
Script done on Tue 24 Apr 2012 14:16:13 BST

joe@beast:~/.ssh$ ssh-add id_rsa
Enter passphrase for id_rsa: 
Identity added: id_rsa (id_rsa)
[joe@goblin ~]$ cd .ssh
[joe@goblin .ssh]$ ls -l
total 16
-rw-r--r--. 1 joe joe  407 May  4 22:07 config
drwx------. 2 joe joe 4096 Apr 24 13:27 fedoraproject
drwx------. 2 joe joe 4096 Apr 24 13:20 git
-rw-r--r--. 1 joe joe 2061 May  4 22:06 known_hosts
[joe@goblin .ssh]$ cd git
[joe@goblin git]$ ls -l
total 8
-rw-------. 1 joe joe 1766 Jan  5  2012 id_rsa
-rw-r--r--. 1 joe joe  403 Jan  5  2012
[joe@goblin git]$

So in each of the subfolders you will have id_rsa and

Pointing to the Key

The only problem now, is that when ssh searches for a key, it won’t be able to find the one it’s looking for. You need to correctly edit your config file that should be located in your ~/.ssh/ folder. If it isn’t already there, just create a new file.

Mine looks like the following:

	User git
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/git/id_rsa
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/fedoraproject/id_rsa
	PreferredAuthentications publickey
	IdentityFile ~/.ssh/fedoraproject/id_rsa

It’s fairly self-explanatory what each part of the file is, you could even just use mine as a template.

Install and configure LibreOffice-4 Amazon Ec2 Instance (Amazon Linux)

  1. Login into Ec2 instance via SSH.
  2. Upgrade Amazon Linux.a) > sudo yum updateb) Reboot instance
  3. Login into Ec2 instance via SSH.
  4. Download LibreOffice (Select package depends on OS Architecture)> sudo wget LibreOffice
  5. Extract source from tar file.> sudo tar -xvzf LibreOffice_4.0.4_Linux_x86-64_rpm.tar.gz
  6. Enter into extracted directory then RPMS folder> cd LibreOffice_4.0.4.2_Linux_x86-64_rpm> cd RPMS
  7. Now need to install all rpms except one, you can remove that.> rm -rf libobasis4.0-gnome-integration-
  8. Now you can able to convert document.> /opt/libreoffice4.0/program/soffice.bin –headless –convert-to pdf test.rtf
  9. If you are getting any dependencies while document conversation please fulfill dependency.
  1. All packages almost available for all Linux flavors from two sources.



11) In my case there was dependencies for dbus-glib-0 while document conversation.

> sudo wget


> sudo rpm -Uvh

Able to perform document convent process headless after successful installation of LibreOffice.

Feel free to contact if anyone need help !

Setup multistage deployment with Capistrano Passenger and SVN with Staging Development Production environments

When application needs to be set on different environment like staging and development question comes  how to manage cap deploy ?

Here are easy steps which will guide to setup and manage with SVN and Capistrano

Setup multistage deployment with Capistrano
1)    Install capistrano and capistrano multistage
2)    Capify your project
3)    Prepare the deploy / directory
4)    Create the deployment recipes

For my project i have created development and production environment. Name your stages whatever you want. but, never name one of your stages stage — it’s a reserved word. We Can name it “staging”.

1) Install capistrano and capistrano multistage

gem install capistrano –no-ri –no-rdoc
gem install capistrano-ext –no-ri –no-rdoc

2) Capify your project

capify you project with following command in project root folder

capify .

3) Prepare the deploy / directory

mkdir config/deploy
touch config/deploy/development.rb
touch config/deploy/production.rb

4) Create the deployment recipes

require ‘capistrano/ext/multistage’

set :stages, %w(development production)
set :default_stage, “development”
set :application, “application”

set :user, “username”
set :password, “password”

set :repository, “https://domain/svn/project/trunk”
set :scm, :subversion
set :scm_username, “repository_username”
set :scm_username, “repository_password”
set :deploy_via, :export

# deploy using “ssh-add”, then “cap deploy”
ssh_options[:forward_agent] = true
set :ssh_options, {:forward_agent => true}
set :use_sudo, false

# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end

task :install_configs
#perform specify operations like set path or other stuff here

task :restart, :roles => :app, :except => { :no_release => true } do
run “#{try_sudo} touch #{File.join(current_path,’tmp’,’restart.txt’)}”

after(‘deploy:update_code’, “deploy:cleanup”, ‘deploy:install_configs’)


Now it’s turn to set both files which we have created in config/deploy 1) development.rb  2) production.rb

Set your development.rb

server “”, :app, :web, :db, :primary => true
set :deploy_to, “/var/www/” #path where you want to deploy application on server
set :db_config, “database-development.yml”

namespace :perform do
task :install_configs
#perform specify operations like set path or other stuff here

after(“deploy”, “perform:install_configs”)

Set your production.rb

server “”, :app, :web, :db, :primary => true
set :deploy_to, “/var/www/” #path where you want to deploy application on server
set :db_config, “database-production.yml”

namespace :perform do
task :install_configs
#perform specify operations like set path or other stuff here

after(“deploy”, “perform:install_configs”)


Great, you are ready to deploy with both environments

When you deploy recipe with cap deploy it will start deploying default environment whatever is set, if you want to deploy specific for environment please run command cap “environment” deploy in our case cap production deploy .

All set with multistage Capistrano deployment with minimal configuration.Lot more for rails 3 and RVM configuration.

Experience with RhoMobile Framework (Cross Platform mobile application development using Ruby !)

Since last three months i been working with RhoMobile (Cross platform mobile development using Ruby).

As i came across it’s totally new domain for me, you need to understanding mobile device environment and behavior .

Major part while developing application with RhoMobile.

1) Ruby

2) Services for different functionality

3) Jqmobile / Jquery

4) Rhodes SDK

5) Cross platform SDKs (iPhone, Android, BB)

More details and installing guide for different platform available

Configure Mongodb with mViewer GUI interface in Ubuntu

Now a days mongodb is largely used, how to configure in ubuntu.

Follow steps :

1) add this line to your /etc/apt/sources.list
deb dist 10gen

2) sudo apt-key adv –keyserver –recv 7F0CEB10

3) sudo apt-get update

4) sudo apt-get install mongodb-10gen

You are ready with mongodb , to check status service mongodb status.

Now install mViewer the Mongodb GUI interface.

1) Download mViewer from

2) Now go to scripts folder and run

3) Visit your localhost on 8080 port with no username and password if you have not set any(

Now you are done with mongodb GUI interface.

Happy coding !

Setup Ubuntu machine for Ruby on Rails with RVM-Mysql-Git-Curl-Java-Sublime Text 2 or Scite

Configure brand new Ubuntu machine for Rails

Step 1 – Install RVM

Prerequisite for RVM sudo apt-get install curl git-core

Run command in terminal bash -s stable < <(curl -s )

After installation update .bashrc is require

command >nano ~/.bashrc

Replace [ -z "$PS1" ] && return with if [[ -n "$PS1" ]]; then

Also add following line of code at end of file

if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi


Run bash -l in terminal.

Now rvm notes you can see rvm is working !

Install following packages before installing ruby via RVM

sudo apt-get install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf

After that rvm list known will display know ruby package choose your favorite !

Install using e.g rvm install 1.9.2

RVM Up and Running !!!!!!

Step 2 – Install Mysql

apt-get install mysql-server

Step 3 – Install GIT and Curl

Already installed as prerequisite.

Step 4 – Install Java

Can install Java using two methods

1st Method

sudo apt-cache search jdk
sudo apt-get install sun-java6-jdk sun-java6-jre

and set export JAVA_HOME=”/usr/lib/jvm/java-6-sun-″ in your .bashrc file

2nd Method (Live installation)

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-jdk

System is ready with java, can check version with java –version in terminal

Step 5 – Install Sublime Text 2

Add Sublime Text 2 PPA using the following command

sudo add-apt-repository ppa:webupd8team/sublime-text-2

After run these commands in terminal
sudo apt-get update
sudo apt-get install sublime-text-2-beta

Step 6 – Install Scite

Run following command in terminal

sudo apt-get install scite

After this installations you are ready to enjoy rails ……

Cross server files/direcories transfer with net/scp in ruby on rails

Some times while dealing with load balanced server we require to manage assets across servers, need to transfer data between load balanced
servers, workout with some gems and plugins finally found solution.

Following code snipts gives you brief on process.

require 'net/scp'
Net::SCP.start(@host, @host_user, :password => @password) do |scp|
scp.upload! source, dest, :recursive => true

stay connected ! RoR rules ……