The Camping Server for Apache + FastCGI

  1. Install Apache 2.
  2. Install mod_fastcgi.
  3. Add to Apache's httpd.conf:
     AddHandler fastcgi-script rb                                                                                                      
     ScriptAlias / /usr/local/www/data/dispatch.rb/
    
  4. In dispatch.rb:
     #!ruby
     #!/usr/local/bin/ruby                                                                                           
     require 'rubygems'                                                                                                                
     require 'camping/fastcgi'                                                                                                         
     Camping::Models::Base.establish_connection :adapter => 'sqlite3',
       :database => "/tmp/camping.db"                                  
     Camping::FastCGI.serve("/usr/local/data/examples/")
    

Serving One File

The above setup will serve a whole directory, just like TheCampingServer. If you only want to serve one app (at the root) change the last line in dispatch.rb to point to a single file.

 #!ruby
 Camping::FastCGI.serve("/usr/local/data/examples/blog.rb")

Mounting at a Subdirectory

You can certainly use ScriptAlias to attach the Camping app to a subdirectory, rather than root. If you are using URL() and R() in your code, the paths will change accordingly.

 ScriptAlias /myapp /usr/local/www/data/dispatch.rb/