RSS

Category Archives: Ruby/Rails

Installing Ruby 1.8.5 on Ubuntu

Great how-to is located at http://www.rubywizards.com/viewtopic.php?pid=19 Here’s the copy of it:

* Bring up the terminal, login as system root, and create temporary directory to store downloaded files.
[~/] su
[~/] mkdir local
[~/] cd local

* Download official source distribution. This will create a file named ruby-1.8.5.tar.gz in your local directory.
[~/local] wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5.tar.gz

* Extract all the files from downloaded archive. This will create local/ruby-1.8.5 subdirectory that stores extracted files.
[~/local] tar xvfz ruby-1.8.5.tar.gz

* Install GNU C++ compiler you’ll need to build Ruby from source.
[~/local] apt-get install build-essential

* Run configure utility to determine your system configuration.
[~/local] cd ruby-1.8.5
[~/local/ruby-1.8.5] ./configure

* Run make command to compile and build Ruby.
[~/local/ruby-1.8.5] make

* Test newly built Ruby executable by running regression test suite. Upon successfull completion you’ll see a message like: “Finished in 44.904424 seconds. 1440 tests, 13585 assertions, 0 failures, 0 errors.”
[~/local/ruby-1.8.5] make test-all

* Install Ruby onto your system. This will move Ruby executable and utilities to /usr/local/bin and standard Ruby libraries to /usr/local/lib/ruby.
[~/local/ruby-1.8.5] make install

* Install Ruby documentation. This will compile Ruby documentation in format required for ri command.
[~/local/ruby-1.8.5] make install-doc

At this point the installation of Ruby 1.8.5 is complete. If you had previous version of Ruby installed in /usr/local/bin, you should take two extra steps:

* Make sure /usr/local/bin comes before /usr/bin in your $PATH:
[~/local/ruby-1.8.5] echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games

* Logout from your current terminal session and login again to reload hashed value of ruby:
[~/local/ruby-1.8.5] which ruby
/usr/local/bin/ruby
[~/local/ruby-1.8.5] ruby -v
ruby 1.8.5 (2006-08-25) [i686-linux]

Mike Dvorkin, Ruby Wizards Admin
http://www.rubywizards.com

Advertisements
 
Leave a comment

Posted by on February 10, 2007 in Linux, Ruby/Rails, Ubuntu

 

Ruby tricks

A short little method that helps find methods up the class latter:

class Object
  def my_methods
    self.class.ancestors.each {|anc|
      puts "#{anc}:"
      p anc.instance_methods(false)
      puts
    }
  end
end
5.times.my_methods

It was copied from Stupid easy Ruby tricks

 
1 Comment

Posted by on October 11, 2006 in Ruby/Rails

 

lighttpd configuration files for multiple rails apps

lighttpd 1.4.8 supports multiple rails aps via ‘strip-request-uri’. Lighty guys wrote about it here.

‘strip-request-uri’ strips URI’s from returning html, which is great if you’re proxying your application through another server. In my case I run apache as a primary server. All my Ruby on rails applications are on lighttpd running on the same server, but higher port, 8888.

One of the domains on the primary server, metak.com, runs my ajaxed dictionary application. For usability purposes I want this domain to operate in “/”, but my true location on lighty server is “/lat/recnik/”. ‘strip-request-uri’ does exactly what’s needed to fix this. Not just that it allows you to have multiple apps, but it gets rid of this “/lat/recnik/” path from resulting html.

Another way of getting multiple apps to work was brought up in the comments of lighty’s post. It works by adding code in rails environment.rb file:
ActionController::AbstractRequest.relative_url_root = “/lat/recnik”

This sure works, but the resulting html includes absolute uri’s “/lat/recnik/….”, so when you access it through the proxy it points to “/lat/recnik” directory which doesn’t exist on the primary server.

This method sure works better if you’re running lighty as a primary server 🙂
Finally, here’s my config file:

# lighttpd configuration file
#
# use a it as base for lighttpd 1.0.0 and above
#
# $Id: lighttpd.conf,v 1.7 2004/11/03 22:26:05 weigon Exp $

############ Options you really have to take care of ####################

## modules to load
server.modules              = ("mod_rewrite", "mod_alias", "mod_access", "mod_status", "mod_fastcgi", "mod_accesslog" )

## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root        = "/www/site/"

## where to send error-messages to
server.errorlog             = "/www/log/error.log"

# files to check for if .../ is requested
index-file.names            = ( "index.html", "index.htm", "default.htm" )

# mimetype mapping
mimetype.assign             = (
".pdf"          =>      "application/pdf",
[.... lots of boring lines here. Copy them from your original config file! ]
".tar.bz2"      =>      "application/x-bzip-compressed-tar"
)

## be nice and keep it at lighttpd
server.tag                 = "lighttpd | SerbianCafe"

#### accesslog module
accesslog.filename          = "/www/log/access.log"

## deny access the file-extensions
url.access-deny             = ( "~", ".inc" )

$HTTP["url"] =~ ".pdf$" {
server.range-requests = "disable"
}

# which extensions should not be handle via static-file transfer
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

######### Options that are good to be but not neccesary to be changed #######
## bind to port (default: 80)
# Use high ports unless you want to run the web server as root
server.port                = 8888

## bind to localhost (default: all interfaces)
#server.bind                = "serbiancafe.com"

## to help the rc.scripts
server.pid-file            = "/www/run/lighttpd.pid"

#### status module
status.status-url          = "/server-status"

$HTTP["url"] =~ "^/lat/recnik/" {
server.document-root = "/www/site/lat/recnik/public/"
alias.url = ( "/lat/recnik/" => "/www/site/lat/recnik/public/" )
server.error-handler-404 = "/lat/recnik/dispatch.fcgi"
fastcgi.server = ( "/lat/recnik/dispatch.fcgi" =>
(( "socket" => "/www/tmp/recnik.socket" ,
"bin-path" =>  "/www/site/lat/recnik/public/dispatch.fcgi",
"bin-environment" => ( "RAILS_ENV" => "development" ),
"strip-request-uri" => "/lat/recnik"
)))
}

$HTTP["url"] =~ "^/typo/" {
server.document-root = "/www/railsapps/typo/public/"
alias.url = ( "/typo/" => "/www/railsapps/typo/public/" )
server.error-handler-404 = "/typo/dispatch.fcgi"
fastcgi.server = ( "/typo/dispatch.fcgi" =>
(( "socket" => "/www/tmp/typo.socket" ,
"bin-path" =>  "/www/railsapps/typo/public/dispatch.fcgi",
"bin-environment" => ( "RAILS_ENV" => "development" ),
"strip-request-uri" => "/typo"
)))
}

### only root can use these options
#
# chroot() to directory (default: no chroot() )
#server.chroot              = "/"

## change uid to  (default: don't care)
server.username            = "wwwrun"

## change uid to  (default: don't care)
server.groupname           = "wwwrun"

#### compress module
#compress.cache-dir         = "/tmp/lighttpd/cache/compress/"
#compress.filetype          = ("text/plain", "text/html")
 
5 Comments

Posted by on December 5, 2005 in Lighttpd, Ruby/Rails

 
 
%d bloggers like this: