Tuesday, April 15, 2008

View offline documentation of installed ruby gems

From command line, just run this -
$ gem server

This will start ruby documentation server on port 8088

previously it was
$ gem_server

which is now deprecated and may not work in your system

Thursday, April 3, 2008

Installing Ruby On Rails on Ubuntu with rmagick

My laptop hard disk drive (it was a fujitsu drive on an HP Pavilion nobebook pc) was gone withing just two months of purchase. Later I got the replacement but, I had to spent another to prepare rails stack again :(
Anyway, here is the recipe for Ubuntu 7.10
$ sudo apt-get install ruby irb ri rdoc ruby1.8-dev libopenssl-ruby1.8 build-essential
$ wget http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
$ tar xzvf rubygems-1.0.1.tgz
$ cd rubygems-1.0.1
$ sudo ruby setup.rb
$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
$ sudo gem update --system
$ sudo gem install rails
$ sudo gem install mongrel

I couldn't install rmagick on the first place. Because building rmagick (v2.3.0) requires ImageMagick version 3.0 or greater but current Ubuntu repository provides only v2.6 (by the time I wrote this). So, I had to install from the source. Thanks to Emmannual for this suggestion.
Remove ImageMagick, if you have already installed
sudo apt-get remove imagemagick

Now download, compile and install from the ImageMagick source
$ tar xvvzf ImageMagick.tar.gz
$ cd ImageMagick
$ ./configure –prefix=/usr
$ make
$ sudo make install
$ sudo gem install rmagick

Or alternatively, you can download binary of ImageMagick-dev from debian repo

$ sudo apt-get install libmagick9-dev
$ sudo gem install rmagick

One more step. Install all necessary gems that are required by the project you are working. Like, our current rails project uses the gem 'memcache-client'. So, I ran the following
$ sudo apt-get install memcached
$ sudo gem install memcache-client

Enable mod_rewrite in Apache under Ubuntu

'mod_rewrite' is disabled in default apache2 installation. To enable this, I followed following procedure. Thanks to Lavlu for showing me this.
At first, load mod_rewrite using Apache's mod enable command
# a2enmod rewrite

Then enable mod_rewrite from Apache2's configuration file. In default installation, there should be a 000-dafult file under /etc/apache2/sites-enabled directory. You should modify that. Just make the value 'All' (it should be 'None' by default) to AllowOverride key for '/' and '/var/www/' directory. So, the line will look like -
AllowOverride All

Now force reload Apache configuration
# sudo /etc/init.d/apache2 force-reload

Backing up mysql database and restore

This is also needed when you need to move your database elsewhere.
To backup your database -
mysqldump --user <mysql_username> --password=<mysql_password> <database> [<tablename>] > <output_filename>

To restore/initiate from the backup
mysql --user <db_username> --password=<db_password> <dbname> < <dump_file>