Ruby on Rails (version 3) is super easy get running on Praxis/Gentoo.

Installing RoR

So, first we have to set our RUBY_TARGETS, we're using 1.9 only.

    RUBY_TARGETS="-jruby (-ree18) -ruby18 ruby19"
~ # emerge -av =dev-ruby/rails-3.1.3

[ebuild  NS   ~] dev-ruby/arel-2.2.3:2.1 [3.0.2-r1:3.0] USE="-doc {-test}" RUBY_TARGETS="-jruby (-ree18) -ruby18 ruby19" 45 kB
[ebuild  N    ~] dev-ruby/memcache-client-1.8.5  USE="-doc {-test}" RUBY_TARGETS="-jruby (-ree18) -ruby18 ruby19" 31 kB
[ebuild  NS   ~] dev-ruby/builder-3.0.4:3 [3.1.4:3.1] USE="-doc {-test}" RUBY_TARGETS="-jruby (-ree18) -ruby18 ruby19" 0 kB
[ebuild  NS    ] dev-ruby/rack-1.3.9:1.3 [1.4.1:1.4] USE="-doc {-test}" RUBY_TARGETS="-jruby (-ree18) -ruby18 ruby19" 430 kB
[ebuild  N    ~] dev-ruby/rack-mount-0.8.3:0.8  USE="{-test}" RUBY_TARGETS="-jruby (-ree18) -ruby18 ruby19" 34 kB
[ebuild  N    ~] dev-ruby/activesupport-3.1.3:3.1  USE="{-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 3,554 kB
[ebuild  N    ~] dev-ruby/mail-2.4.4:2.4  USE="{-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 0 kB
[ebuild  N    ~] dev-ruby/sprockets-2.0.4:2.0  USE="{-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 132 kB
[ebuild  N    ~] dev-ruby/activemodel-3.1.3:3.1  USE="{-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 0 kB
[ebuild  N    ~] dev-ruby/actionpack-3.1.3:3.1  USE="-doc {-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 0 kB
[ebuild  N    ~] dev-ruby/activeresource-3.1.3:3.1  USE="-doc {-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 0 kB
[ebuild  N    ~] dev-ruby/activerecord-3.1.3:3.1  USE="-mysql postgres sqlite3 {-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 0 kB
[ebuild  N    ~] dev-ruby/railties-3.1.3:3.1  USE="-doc {-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 0 kB
[ebuild  N    ~] dev-ruby/actionmailer-3.1.3:3.1  USE="{-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 0 kB
[ebuild  N    ~] dev-ruby/rails-3.1.3:3.1  USE="{-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 4 kB

Adding MongoDB Support

~ # ACCEPT_KEYWORDS="~amd64" emerge -av dev-ruby/mongo dev-ruby/mongoid

[ebuild  N     ] dev-ruby/bson-1.6.2  USE="-doc {-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 15,123 kB
[ebuild  N     ] dev-ruby/mongo-1.6.2  USE="-doc {-test}" RUBY_TARGETS="(-ree18) -ruby18 ruby19" 0 kB
[ebuild  N     ] dev-ruby/mongoid-2.4.10  USE="-doc {-test}" RUBY_TARGETS="-ruby18 ruby19" 356 kB

See also MongoDB howto.

Configuring Ruby & Rails

eselect ruby ruby19
eselect rails rails

Now, create a new Rails project.

~ . rails new example.com --skip-active-record

Update application.rb.

gem 'mongo_mapper'
gem 'bson_ext'

Using Nginx

Simply point Nginx site configuration to the back-end runners.

upstream app {
    server 127.0.0.1:3000;
    server 127.0.0.1:3001;
    server 127.0.0.1:3002;
}
server {
    listen   80;
    server_name .example.com;

    root       /var/www/app.example.com/webroot;
    index      index.html;

    access_log /var/www/app.example.com/log/access.log;
    error_log  /var/www/app.example.com/log/error.log;

    location / {
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
        proxy_redirect    off;
        try_files /system/maintenance.html $uri $uri/index.html $uri.html @ruby;
    }

    location @ruby {
        proxy_pass http://app;
    }
}

Using Apache

See the documentation on using Passenger.

Using Lighttpd

Uing Lightttpd w/RoR is not supported in Praxis but that should not stop you.

See Also