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:
- Download ( http://rubyforge.org/frs/?group_id=426&release_id=5757 ) and extract Ruby ( I tried with 1.8.4 version ) source under "/ruby".
- Run the following commands.
> cd /ruby/ruby-1.8.4
> ./configure
> make
> make install
Installing RubyGems:
- Download ( http://rubyforge.org/frs/?group_id=126&release_id=5803 ) and extract RubGems 0.9.0 source under "/ruby"
- Run the following commands.
> 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:
- Download FastCGI GEM from http://rubyforge.org/projects/fcgi to "/ruby" directory
- Install this gem. This requires FastCGI Development Kit which can be downloaded from http://fastcgi.com/#TheDevKit
> 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
"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.
Posted by 192.18.43.249 on October 31, 2006 at 11:52 AM IST #
Posted by Charles Oliver Nutter on October 31, 2006 at 08:22 PM IST #
Posted by 210.5.193.150 on November 12, 2006 at 04:59 PM IST #
Posted by Seema on November 14, 2006 at 11:37 AM IST #
Posted by hans on December 11, 2006 at 05:19 PM IST #
Posted by Chris on February 01, 2007 at 03:21 PM IST #
Posted by Seema on February 01, 2007 at 05:22 PM IST #
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:
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 getbash-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:23Do you have any suggestions?
Thank you,Craig Cook
Posted by Craig A. Cook on February 03, 2007 at 02:38 AM IST #
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 11:22 AM IST #
Posted by Boris Kuzmic on March 22, 2007 at 03:07 PM IST #
Posted by Seema on March 22, 2007 at 03:29 PM IST #
Posted by Shu on April 29, 2007 at 10:06 AM IST #
Which 'cc' are you using (version and location) ?
And also check this link
Posted by Seema on April 30, 2007 at 11:18 PM IST #
Posted by Gerardo M. on May 07, 2007 at 09: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 24, 2007 at 02:15 AM 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 12:24 PM IST #