Thursday, March 15, 2012

Installing Ruby on Rails in a FreeBSD Server


At First you have to Install ruby

# pkg_add -r -v rubyusing the following command

For Checking what version of Ruby installed
# ruby –version

* (‘#’ denotes running command as root; ‘>’ denotes running command as non privileged user).
Gems isn’t installed as default, so the next task is putting that in. A simple

“make search name=gems”

shows the gem port in /usr/ports/devel/ruby-gems.

Following the standard “make install clean” actions it will put the latest version on your machine.
#gem –version

Now you’re good to go with putting on the specific gems to get Rails apps running. We begin of course with rails itself.

# gem install  rails

This gives you a collection of gems that comprise the rails framework, and the Ruby documentation pages as well. For Installing gems you required, you can follow the below syntax.

# gem install mysql

# gem install authlogic

Rake is the Rails functionality that sets up your database schema and needs to be present for the application configuration stage.Getting that installed is done by:
# gem install rake

You Can see the list of gems installed using the command

# gem listNow we can install Apache2.2

# pkg_add -r -v apache22

Install Passenger

# pkg_add -r -v rubygem-passenger

Add lines created by running the above commands to LoadModule passenger with apache
# nano /usr/local/etc/apache2/httpd.conf
add the following lines in the httd.conf file:


LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/apache2/
PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.2
PassengerRuby /usr/local/bin/ruby18


*change the pasenger version as per your..

Restart apache after making changes to the configuration file for any reason, you will need to restart the server:
# /usr/local/sbin/apachectl restart


You can start the server by typing:
/usr/local/sbin/apachectl start


You can stop the server at any time by typing:
/usr/local/sbin/apachectl stop


To restart Apache without aborting current connections, run:
# /usr/local/sbin/apachectl graceful.



Now you can create and run  your ROR application ...

If You have n't installed the MySQL, then refer my next article on how to do that....

Happy COding....

1 comment:

  1. Installing Ruby 1.9.3 or 2.0.0 and Rails 3.2 on FreeBSD:
    http://www.rubybb.com/bsdonrails.pdf
    Hope it will help some people :)

    ReplyDelete