RoR on Web Server 7.0

RoR on Web Server 7.0 I just happened to try out running RoR (Ruby on Rails) on Web Server 7.0 using the FastCGI plugin. Even though setting up RoR took some time, configuring Web Server 7.0 to run RoR application turned out to be an easy task. Of course, I had to debug the Rails request handler code (request.rb file) to understand how it was handling the request URI.

Below, I have listed the steps that I followed for running RoR app on Web Server 7.0.

Machine/OS: Sun SPARC/Solaris 10

Note: Add "/usr/local/bin" directory to your PATH variable as all the following binaries get installed in this directory.

Installing Ruby:
           > cd /ruby/ruby-1.8.4
           > ./configure
           > make
           > make install


Installing RubyGems:
          > cd /ruby/rubygems-0.9.0
          > export DLN_LIBRARY_PATH=/ruby/ruby-1.8.4/.ext/sparc-solaris2.10
          > export RUBYLIB=/ruby/ruby-1.8.4/ext:/ruby/ruby-1.8.4/lib:/ruby-1.8.4:/ruby/ruby-1.8.4/.ext/sparc-solaris2.10
          > ruby setup.rb --rbconfig=/ruby/ruby-1.8.4/rbconfig.rb


Installing Rails on Ruby:
  • Set the proxy, if behind the firewall.
          > export http_proxy=http://<proxy_host>:<proxy_port>
  • Install Rails.
          > gem install rails --include-dependencies


Installing FastCGI Ruby gem:
          > cd /ruby
          > gem install fcgi -- --with-fcgi-include=/fcgi-2.4.0/include --with-fcgi-lib=/fcgi-2.4.0/libfcgi/.libs


Sample "Hello World" RoR app:
Below are the steps to getting over the first hurdle: Creating a “hello world” application in Ruby on Rails.
Assumption: You have ruby and rails already installed and working on your system.
  • Run the following commands.
          > mkdir /ruby/samples

> cd /ruby/samples
          > rails hello-world
          > cd hello-world
          > ruby script/generate controller hello
  • Create a file called index.rhtml in app/views/hello, containing “Hello !”.
  • Start the default WEBrick Web Server to test the first application.
          > ruby script/server
  • Navigate to http://localhost:3000/hello in your browser and be greeted with your friendly application: “Hello !”

Changes to sample "Hello World" RoR app:
Now let us add some 'action' to our Hello World application.
  • Go to 'controllers' directory of the sample.
          > cd /ruby/samples/hello-world/app/controllers/
  • Edit hello_controller.rb file. Add the following lines (in Red)
          class HelloController < ApplicationController
            def sayhello
               render_text "Hello ! This is a simple example"
            end
          end   
  • Restart WEBrick server
          > ruby script/server
  • Access the newly added action "sayhello" by navigating to http://localhost:3000/hello/sayhello
          Note: URI is of the form <controller>/<action>

      "Hello ! This is a simple example"  should be displayed.


Configure Web Server 7.0:
Now let us configure this application to run on Web Server 7.0 .
The configuration steps are given below.
  • Edit magnus.conf and add the following line to load the FastCGI plugin bundled with Web Server.
          Init fn="load-modules" shlib="libfastcgi.so" shlib_flags="(global|now)"
  • Edit obj.conf as follows:
          <Object name="default">
          ...
          ...
          #
          # Pass requests for "/dispatch.fcgi" to "rubyTest" object
          #
          NameTrans fn="assign-name" from="/dispatch.fcgi/\*" name="rubyTest"
                    #
                    # Prefix '/dispatch.fcgi/' to the original URI which does not already contain "/dipatch.fcgi",
                    # and resend the request.
                    #
          <If $uri !~ '\^/dispatch\\.fcgi/.\*'>
NameTrans fn="restart" uri="/dispatch.fcgi$uri"
</If>
          #          
# Set the document root to RoR sample's public directory
#         
# Note: This should be the last NameTrans directive.
#

          NameTrans fn=document-root root="/ruby/samples/hello-world/public"

...
          ...
          </Object>
          ...
          ...
                    #
                    # Object to handle the RoR application requests
                    # Here, app-path should point to dispatch.fcgi script of the RoR sample.
                    #
          <Object name="rubyTest">
          Service fn="responder-fastcgi" app-path="/ruby/samples/hello-world/public/dispatch.fcgi" 
bind-path="localhost:4334"  app-env="RAILS_ENV=production"
app-env="RUBYLIB=/usr/local/lib/ruby/1.8"
          </Object>
  • Start the Web Server and access 
          http://localhost:80/hello/sayhello
     (assuming localhost and 80 are the Web Server host and port, respectively)

   
"Hello ! This is a simple example" should be displayed on the page.
Comments:

great stuff!

Posted by guest on October 31, 2006 at 03:52 AM IST #

Hopefully soon you'll be able to use JRuby to do all this...or just deploy your Rails WAR file and be done with it :)

Posted by Charles Oliver Nutter on October 31, 2006 at 12:22 PM IST #

i have problrm yet

Posted by guest on November 12, 2006 at 08:59 AM IST #

What exactly is the issue ? Any error msgs ?

Posted by Seema on November 14, 2006 at 03:37 AM IST #

Hi , did try it on solaris 10 on x86. The last step gives te following error. # [11/Dec/2006:12:43:02] failure ( 9256): for host 127.0.0.1 trying to GET /dispatch.fcgi/hello/sayhello while trying to GET /hello/sayhello, func_exec reports: HTTP2302: Function responder-fastcgi aborted the request without setting the status code # Do you have any idea how to solve this? regards, Hans

Posted by hans on December 11, 2006 at 09:19 AM IST #

Hi How fast does it run Rails? Are there any rails benchmarks? Thanks Chris

Posted by Chris on February 01, 2007 at 07:21 AM IST #

Sorry, there are no rails benchmarks.

Posted by Seema on February 01, 2007 at 09:22 AM IST #

Dear Ms. Alevoor:

I have tried your article, "Running Ruby on Rails on Sun Java System Web Server 7.0". I get ruby installed successfully, but can't get gems to work with an outside gem source.

I am running Solaris 2.9. I installed all to my home directory as I don't have write permissions to other directories. (I used the --prefix command on the ./configure in the ruby source directory).

I get the following error at the end of the attempted install of ruby gems: hook /home/cookc/ruby/rubygems-0.9.0/./post-install.rb failed:

You don't have write permissions into the /home/user/lib/ruby/gems/1.8 directory.
There is no "/home/user" on the machine, nor can I find such a reference in any of the .rb files. Why is it trying to install into that directory? Some gem commands seem to work (at least they don't give any errors), but I can't get a remote listing. I get
bash-2.05$ gem list --remote

\*\*\* REMOTE GEMS \*\*\*
/home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- sources (LoadError)
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:462:in `sources'
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:472:in `source_index_hash'
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/remote_installer.rb:452:in `search'
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/gem_commands.rb:685:in `execute'
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/gem_commands.rb:765:in `execute'
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/command.rb:69:in `invoke'
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/cmd_manager.rb:117:in `process_args'
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/cmd_manager.rb:88:in `run'
        from /home/cookc/ruby/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:29:in `run'
        from /home/cookc/ruby/bin/gem:23

Do you have any suggestions?

Thank you,
Craig Cook

Posted by Craig A. Cook on February 02, 2007 at 06:38 PM IST #

Hi Craig Cook,

Your comment did not appear on the blog page. Hence I have posted your question along with my response.

Craig's comment :
I get the following error at the end of the attempted install of ruby gems: hook
/home/cookc/ruby/rubygems-0.9.0/./post-install.rb failed:
You don't have write permissions into the /home/user/lib/ruby/gems/1.8 directory.

There is no "/home/user" on the machine, nor can I find such a reference in any of the .rb files. Why is it trying to install into that directory? Some gem commands seem to work (at least they don't give any errors), but I can't get a remote listing.

Response:
Try following the steps listed at http://rubyforge.org/pipermail/rubygems-developers/2006-November/002210.html
Let me know if this solves the issue.

Posted by Seema on February 06, 2007 at 03:22 AM IST #

Hello! I have a problem installing fcgi 2.4.0 on Solaris 10 x86. I've tried installing SUN Studio - with compilers but I can't install it. What Solaris packages do I need to have? Thanks.

Posted by Boris Kuzmic on March 22, 2007 at 08:07 AM IST #

What exactly is the error ?

Posted by Seema on March 22, 2007 at 08:29 AM IST #

Dear Seema: I have read your webpage regarding setting up RoR. I have installed a Sun Solaris for Developer Express edition recently and now I am trying also install the RoR on it. I encountered some problem and I appreciate it very much if you could help me out. The problem I have is following: cd ruby-1.8.6 ./configure make "I then got the following message: make: Warning: Illegal dependency list for target `.DEFAULT' cc -g -DRUBY_EXPORT -I. -I. -c ./missing/isinf.c "./missing/isinf.c", line 32: syntax error before or at: __builtin_isinf "./missing/isinf.c", line 33: warning: old-style declaration or incorrect type for: n "./missing/isinf.c", line 33: syntax error before or at: double "./missing/isinf.c", line 33: identifier redeclared: n current : double previous: int : "./missing/isinf.c", line 32 "./missing/isinf.c", line 35: syntax error before or at: return cc: acomp failed for ./missing/isinf.c \*\*\* Error code 2 make: Fatal error: Command failed for target `isinf.o' bash-3.00# " Thanks a lot in advance. Sincerely Shuya

Posted by Shu on April 29, 2007 at 03:06 AM IST #

Hi Shuya,

Which 'cc' are you using (version and location) ?
And also check this link

Posted by Seema on April 30, 2007 at 04:18 PM IST #

Hi Seema When i try to MAKE or GMAKE ruby in my Solaris 10 Developer Edition got this error: cc -g -DRUBY_EXPORT -I. -I. -c ./missing/isinf.c "./missing/isinf.c", line 32: syntax error before or at: __builtin_isinf "./missing/isinf.c", line 33: warning: old-style declaration or incorrect type for: n "./missing/isinf.c", line 33: syntax error before or at: double "./missing/isinf.c", line 33: identifier redeclared: n current : double previous: int : "./missing/isinf.c", line 32 "./missing/isinf.c", line 35: syntax error before or at: return cc: acomp failed for ./missing/isinf.c gmake: \*\*\* [ isinf.o] Error 2

Posted by Gerardo M. on May 07, 2007 at 02:27 AM IST #

Hey Seema, I'm trying to follow this to get RoR working and am running into the follow error from the Ruby FastCGI handler :

[23/Aug/2007:16:32:08 :: 26479] starting
[23/Aug/2007:16:32:08 :: 26479] Dispatcher failed to catch: private method `split' called for nil:NilClass (NoMethodError)
/usr/local/lib/ruby/1.8/cgi.rb:898:in `parse'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/cgi_ext/raw_post_data_fix.rb:45:in `initialize_query'
/usr/local/lib/ruby/1.8/cgi.rb:2275:in `initialize'
(eval):16:in `initialize'
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:612:in `new'
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:612:in `each_cgi'
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each'
/usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each_cgi'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:141:in `process_each_request!'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:55:in `process!'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/fcgi_handler.rb:25:in `process!'
/www/dweeb/ruby/hello-world/public/dispatch.fcgi:24
almost killed by this error

It almost looks like the 'hello/sayhello' isn't being passed to the fastcgi.rb. Is there a way to make the FastCGI NSAPI verbose log to the Fastcgistub.log file?

Posted by steve on August 23, 2007 at 07:15 PM IST #

Currently FastCGI plugin doesn't have a good logging support. So, changing the log level to verbose may not help.

Would it be possible for you to post or mail the obj.conf settings ?
Did you try running your application using the default WEBrick server ? If it worked, let me know the URL used.

Posted by Seema on August 24, 2007 at 05:24 AM IST #

Post a Comment:
Comments are closed for this entry.
About

seemaa

Search

Categories
Archives
« April 2015
SunMonTueWedThuFriSat
   
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
  
       
Today