Finally - Setting up Rails!

Posted by Pat Thu, 25 Aug 2005 04:43:00 GMT

Getting started with Rails on FreeBSD

As I said in my Intro to FLPR, I think Rails was made to be on FreeBSD. It just works so well, and as you’ll see installation is a snap. Right now we’re going to install RubyGems, and then install a few of the gems you’ll need to run Rails. Some we’ll install from gems, stome we’ll install from ports. Enough talk.

Installing RubyGems

This is a snap. Just install the port.
# cd /usr/ports/devel/ruby-gems && make install clean
Boom. Gems is installed.
# gem --version
0.8.11
Now we’ll install Rails. This is simple, because you just follow the basic Rails installation, using gem. Say yes to all the dependencies.
# gem install rails
Now we’re going to install a couple things from ports. The two important ones are the postgresql adapter, and the ruby fcgi module. The adapter is used to let your Rails apps connect to a Postgres database, and the fcgi module is to use fastcgi with lighttpd. I’ll also show how to install iconv, in case you’re using something that requires it (Salted Hash Login Generator, for example)

note: I had previously showed how to install the ruby-postgres adapter through ports. Now you should install the postgres adapter as a gem .

# cd /usr/ports/www/ruby-fcgi/ && make install clean
# cd /usr/ports/converters/ruby-iconv/ && make install clean
Now install whatever gems you want. I’ve got all the rails ones, builder, localization_generator, rails_product, RedCloth, rubygems-update, salted_login_generator, shipping, and site_generator). Check out RubyForge for a bunch of different gems you can install.

Get a Rails app going

Just to see that we got Rails installed, let’s start up a Rails app. We’re just going to create a new app and start the included Webrick server to see that it runs.
$ rails myapp
$ ./myapp/script/server
Then check out your server’s IP address at port 3000, and you should see the “Congratulations, you’ve put Ruby on Rails!” page.

That’s all we’re going to do as far as setting up Rails. Time to move on to lighttpd and finish up the qua…diad?

Posted in  | Tags  | 4 comments

Comments

  1. John Röthlisberger said about 1 hour later:

    Hi Pat,

    Great series of posts. I’ve been following (as you’ve been posting) and I’ve run into a couple of questions:

    - What is the need for recompiling the kernel? I’ve skipped this part as I don’t need PF.

    - I am getting gem 0.8.6 instead of 0.8.11. Any ideas why? Fress 5.4 install, and I’ve followed everything you’ve posted so far, except for the kernel bit.

    Cheers,

    —John

  2. Pat said about 3 hours later:

    Hey John,

    The reason for upgrading the kernel and userland is for security.

    When you first install FreeBSD, you get kernel version 5.4-RELEASE. Since then, the FreeBSD Security Team has patched a number of holes they found (don’t worry though, FreeBSD is not riddled with vulnerabilities). You can find more info at the FreeBSD Security Page. The latest secure build is 5.4-RELEASE-p6. Once you upgrade to the latest version, you only need to upgrade whenever a new security advisory is announced. You can find out about these by signing up to the (very low-volume) FreeBSD-security-notifications@FreeBSD.org mailing list.

    I think you got the old gem because of a typo in my ports updating post…in the section on installing portsnap, I incorrectly wrote one of the commands as “portsnap update”. That works fine – after you’ve got the ports tree installed the first time. The first time around though, it should be “portsnap fetch && portsnap extract”. Try doing that, then “portupgrade -a” to upgrade all your ports.

    Pat

  3. Jonathan said about 4 hours later:

    Have you seen

    /usr/ports/www/rubygem-rails ?

    This will install rails (+ all the action/active gems) and rake. Further the is a port for typo (/usr/ports/www/typo). Currently its version is 1.6.8 as the ports tree is frozen.

    After the freeze I will update the port to 2.5.5

  4. Pat said about 14 hours later:

    Hey Jonathon,

    Yeah, I saw there was a rails port. To be honest, I’m not sure exactly what it does because I find it quite easy to just install Rails via gem. In general, if I can get it from gems instead of ports, I will. The exception is when I need something lower-level that I want to be native, instead of written in Ruby (as is the case with the Postgres adapter), then I’ll install from ports.

    Great to hear that typo’s a port as well. I think I noticed it a while ago but dismissed it because it was an old version. Thanks for bringing it to my attention.

    Pat

(leave url/email »)

   Preview comment