Easy installing Passenger mod_rails on gentoo Linux

Posted on May 12, 2008

To install the great Mod_Rails on Gentoo linux it's as easy as 4 steps.

Since you are Gentoo user, i don't need to go to details. You know what you doing. ;)

1. Recompile Apache non-threaded

add this to /etc/portage/package.use
www-servers/apache -threads
and this to /etc/make.conf
APACHE2_MPMS="prefork"

2. emerge -va apache

3. gem install passenger

4. passenger-install-apache2-module

that's it. now just follow the intructions in the passenger installation process.

This is a sample vhost file for a rails app. you just throw it inside /etc/apache2/vhosts.d/

< VirtualHost *:80 >
  ServerName <%= domain_name %>
  DocumentRoot /myapp/public
  Include /etc/apache2/vhosts.d/deflate.conf
  RailsBaseURI /
  # The maximum number of Ruby on Rails application instances that may be simultaneously active. 
  # A larger number results in higher memory usage, but improved ability to handle concurrent HTTP clients. 
  # normally 2 to 10, would be nice. (1 for each 40mb ram)
  RailsMaxPoolSize 3
  # The maximum number of seconds that a Ruby on Rails application instance may be idle.
  # That is, if an application instance hasn't done anything after the given number of seconds,
  # then it will be shutdown in order to conserve memory. ( 1 hour)
  RailsPoolIdleTime 3600
  RailsEnv 'production'
  < Directory /myapp/public >
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  < / Directory >
< / VirtualHost >
My sample deflate.conf, used to gzip the content
< Location / >
	SetOutputFilter DEFLATE
	#
	# Netscape 4.x has some problems...
	BrowserMatch ^Mozilla/4 gzip-only-text/html
	#
	# Netscape 4.06-4.08 have some more problems
	BrowserMatch ^Mozilla/4\.0[678] no-gzip
	#
	# MSIE masquerades as Netscape, but it is fine
	BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
	# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
	# the above regex won't work. You can use the following
	# workaround to get the desired effect:
	BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
	# Don't compress images
	SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
	SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
	SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
	# Make sure proxies don't deliver the wrong content
	Header append Vary User-Agent env=!dont-vary
< / Location >

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{output_info}n/%{input_info}n (%{ratio_info}n%%)' deflate
CustomLog /var/log/apache2/deflate_log deflate

Rails Session, be the fastest you can be. Libmemcached

Posted on March 09, 2008

To use The new Libmemcached and memcached by Evan Weaver , drop these lines on your config/environments/production.rb

1
2
3
4
5
6
7
8
9
10
11

# See more on http://blog.evanweaver.com/files/doc/fauna/memcached
require 'memcached'
config.action_controller.session_store = :mem_cache_store
memcached_server = '127.0.0.1:11211'  
memcached_options = {
  :namespace => "my_sweet_app_#{RAILS_ENV}",
  :hash => :default
}
SESSION_CACHE = Memcached::Rails.new(memcached_server, memcached_options)
ActionController::Base.session_options[:cache] = SESSION_CACHE


memcached is up to 150x faster than memcache-client, and up to 15x faster than caffeine. See BENCHMARKS for details.

READ the docs at : http://blog.evanweaver.com/files/doc/fauna/memcached

ruby-mysql now Ruby 1.9 compatible

Posted on March 07, 2008

Tommy has just released an new mysql-ruby package.

Actually 2 of them:

mysql-ruby-2.7.5 and mysql-ruby-2.8pre2

They are Ruby 1.9 compatible

Requirements

  • MySQL 5.0.51a
  • Ruby 1.8.6, 1.9.0

here is the link http://tmtm.org/en/mysql/ruby/

Greate Job Tommy!

Cashboard is Just Awesome!

Posted on February 25, 2008

Cashboard App is just most awesome app I have been using lately…

I can’t say anything else… it’s freaking cool!!!

I got the free plan, which gives 2 projects and 2 logins. but I can’t hesitate to go for the Leather Plan, which is $12 / month

Features I love the most:

  • Can print PDFs of time sheets and invoices
  • Send those PDFs to your Employee or company.
  • Automatic Time tracking.
  • OSX Widget for time tracking.
  • Paypment Integration. ( you can get paid right there)
  • And finally, “Basecamp Integration”

Isn’t it just sweet???

Rails Playground Rocks

Posted on December 31, 2007

I have been hosting many Rails applications in many different "SHARED" Hostings. and all I can say is that the best of them is Rails Playground...

Here are my reasons:

1. Uptime is very good.

05:38:15 up 108 days, 9:56, 7 users, load average: 0.46, 0.46, 0.45

2. Load is very Low

Load average: 0.46, 0.46, 0.45

for 2 x dual core cpus, this load is Awesome. The maximum load I have seen is like 1.9

3. Service is excellent

Every email I send I get the answer right back, with a good solution and help.

4. I asked for Git support

and I got it, they installed git right away.

5. FAST Hardware

in my rails application I get between 100 to 200 Req/sec using a single mongrel. I even get near results using FCGI !!! of course my app uses a LOT of caching, as well, using rails 2.0 edge from trunk. you might not get same results...

6. Fast connection

They have resonably fast connections... From the the other side of the world (Japan, Thailand, Malaysia) I get real good speed.

7. Free 2 mongrel Instances

I get 2 mongrel for the developer plan.

8. Free 1GB subversion repository

if i had to pay for http://svnrepository.com/ it would cost another 5 USD month.

9. All newer gems

On my machine, 76 gems installed. well updated.

SVNrepository.com is a real good choice to pay if you need more space to host many applications and more support.

So, for for the newbie and junior Programmer, RailsPlayground is definitely worth it for the "price".

Disclaimer :

IT IS JUST MY PERSONAL OPINION, for a shared Hosting I don't guarantee you will get the same service as I get. you might not get same results as I get... basically, you might not be lucky as i am. :)

NOTE:

If you have a critical application I do recommend to host on AMAZON EC2, or get your own Server Stack or Clusters.

Multi Search with Ferret, Pagination and Sorting

Posted on December 28, 2007
I had to do a search with ferret for a single model and multiples queries, plus sorting in pagination.
for example, I wanted to search for a User with name="John Smith" AND city="atlanta" AND state="ga" AND zip=100*

here is my implementation

The model code, I got it from Igvita Ferret Pagination in Rails and slightly modified.

OSX Leopard Sux big time

Posted on December 20, 2007

UPDATE: I haven’t tried 10.5.2 update. it might not Suk anymore after 10.5.2

This brand new OS, “The most advanced OS” sucks big time!!!

This OS is so damn unresponsive sometime… it hangs all the time… i hate it.

- Mail hangs, when I send email, search or read

- iTunes hangs, (becoming unresponsive)

- Safari hangs, and takes all my ram… up to 800 MB!!!

- The terminal console is lagging… and crashing. iTerm also becomes unresponsive.

- even textmate is crashing, not because of the textmate, but because of the OS.

It all happened after I installed Leopard..

TIGER WAS FINE….

I bought this DVD, 130 USD

and what I get??? this shit.

now I have to go back to tiger.

Use TIGER until apple fixes Leopard.

UPDATE:

Some Solutions:

Use Firefox or Camino,

Use Thunderbird as mail client.

Install Leopard from fresh.

I have read that people who installed from fresh. had not most of these problems.

Darwin HaCkiNtoSh.local 9.1.0 Darwin Kernel Version 9.1.0: Wed Oct 31 17:46:22 PDT 2007; root:xnu-1228.0.2~1/RELEASE_I386 i386 i386
Core 2 duo 1.83 GHZ, 3.0 GB RAM 
Leopard 10.5.1

UPDATE: I haven’t tried 10.5.2 it might not Suk anymore after 10.5.2

just download it and run it

MacOSXUpdCombo10.5.2.dmg

My first successful booting of Rails 2.0.2 on Ruby 1.9 attempt

Posted on December 18, 2007

This is my first Successful attempt to "boot" Rails 2.0.2 on Ruby 1.0 Revision 14284 and using webrick

I haven't gone any further like adding models and controllers... that's up to you to try... sorry. do it at your own risk.

Faster Rails auto_complete with memcached

Posted on December 17, 2007

Auto_complete by default uses full text search to the database.

That can be very slow if you your database is big...

so, let use memcached instead.

Encrypt folders in Mac OSX with encfs

Posted on December 17, 2007

OSX already include the File Vault functionality that allows you to encrypt your whole Home Folder. Thou the storage overhead is so small, the time to encrypt it the first time is very very long. if you have Videos, and big files, it takes even longer.

What if I don't want to encrypt my big folders like Movies, Music, Pictures, Pdfs?

Make your Rails app faster with memcached. Part 1

Posted on December 13, 2007

. Make your Rails app faster with memcached. Part 1

In this article I describe how to make your application increase considerably in performance

Required Applications:

    1. cache_fu (plugin)

./script/plugin discover ./script/plugin install cache_fu

    1. memcache_client

gem install memcache_client

    1. memcached

(http://www.danga.com/memcached)

Upload daily mysql dumps from EC2 to S3 bucket

Posted on December 07, 2007
here is how I upload a daily mysql dump to S3 bucket

Capistrano 2.1 and Ultrasphinx

Posted on December 07, 2007
Here is my capistrano configuration to use with ultrasphinx. Sphinx on gentoo. The default.base is very important. When you run rake ultrasphinx:configure, the new configuration file will be base on this default config file.

Upload and Download Gentoo portage to S3

Posted on December 07, 2007
Often I have to load and unload EC2 ami. As well I keep gentoo portage in /mnt/ since it's quite big (550MB) so I have a ruby code to update the portage, make a tar file and upload it

nahhhh, i'm lazy... install all the gems...

Posted on December 07, 2007
Works for rubygems-0.9.5 since it autodetect architecture and wont ask my architecture. I really hate that asking question for win32? or ruby? or jruby. obvious aint't win32!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32


#!/opt/local/bin/ruby
# runs as sudo
# sudo ruby my_gems.rb

@gems = ["acts_as_ferret", "amazon-ec2", "amazon-ecs", "amazon-hacks", 
"aws-s3", "builder", "capistrano", "ccsv", "chronic", "coderay", "color-tools", 
"daemons", "dnssd", "dsl_accessor", "ec2onrails", "fastercsv", "fastthread", 
"fcgi", "ferret", "gem_plugin", "has_many_polymorphs", "highline", "hoe", 
"hpricot", "libxml-ruby",  "mem_cache_fragment_store", "memcache-client", 
"mime-types", "mini_magick", "mocha", "money", "mongrel", "more_money", 
"needle", "net-amazon-s3", "net-sftp", "net-ssh", "payment", "pdf-writer", "rails", 
"rake", "rcov", "RedCloth", "redgreen", "rmagick", "ruby-openid", "ruby-yadis", 
"rubyforge", "rubygems-update", "RubyInline", "rubynode", "s3-ruby", "s33r", 
"select_with_include", "simple-rss", "socket_accept_filter", "socket_sendfile", 
"sources", "sqlite3-ruby", "syntax", "termios", "test-spec", "transactin-simple", 
"tzinfo", "ultrasphix", "wirble", "xml-simple", "yahoofinance", "ZenTest"]


@gems.each do  |happy|
    puts "installing #{happy} gem..."
    begin 
      io = IO.popen("gem install #{happy}")
    rescue
      puts "Sorry, gem #{happy} not installed :("
    end
    puts "Installed #{happy} gem. :)"
    # if you use ruby with threads, uncomment this next line
    # sleep 60
end

UPDATE: sorry if it crashed anyone machine :) if you compile Ruby with Threads. I forgot to say that we should add a sleep in there to have a break between each gem install, and not spawn all gems to each gem install thread.... :) ma bad.