Topic: deploying rails app linux apache2 cgi

I'm trying to deploy my rails app on Linux running Apache 2. I am able to run the app locally on my Windows machine with Apache 2 w/ no problems. The httpd.conf and .htaccess files on the Linux server are identical to the files on my Window machine (except for path)

relevant portion of Linux Apache httpd.conf

<VirtualHost *:80>
    ServerName jbdevrails.depot.com
    DocumentRoot /home/software/jammmer/rails/dashboard/public
    ErrorLog /home/software/jammer/rails/dashboard/log/server.log
   
    <Directory /home/software/jammer/rails/dashboard/public>
              Options ExecCGI FollowSymlinks
              AllowOverride All
              Allow from all
              Order allow,deny
    </Directory>
</VirtualHost>

I am able to run Webrick on the Linux server and I'm able to access the app, no problems. However, when I try to access the app through the Linux Apache 2 server, I get an error when I try to access http://jbdevrails.depot.com/dashboard/orders/open : 10.1.4.80 - - [10/Jan/2007:11:46:17 -0500] "GET /dashboard/orders/open HTTP/1.1" 500 68

I'm not sure why this is happening. I tried running the app with FastCGI, but didn't get that to work, so I switched everything back to using regular cgi. With the FastCGI, when I try to open the same page, the dispatch.fcgi file is displayed. Now I have removed all reference to fcgi and I am using regular cgi.

Thanks for any help!

Jammer

Last edited by Jammer1982 (2007-01-10 13:22:31)

Re: deploying rails app linux apache2 cgi

Check your #! lines in dispatch.cgi and dispatch.rb. That might be the problem. Running under CGI is a recipe for poor performance, BTW.

Re: deploying rails app linux apache2 cgi

Both dispatch.cgi and dispatch.rb look like the following:

#!/usr/local/bin/ruby

require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)

# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired
require "dispatcher"

ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) } if defined?(Apache::RubyRun)
Dispatcher.dispatch


and ruby exists at the location /usr/local/bin/ruby.

I understand cgi has poor performance, but I would like to have the server configured with cgi for the time being, while I tweak out the problems with fastcgi. In the end, when I release to users, I want to be running the app with fastcgi.

Re: deploying rails app linux apache2 cgi

I checked the server.log file from in my rails application log folder. Saw the following:

[Wed Jan 10 14:53:21 2007] [error] [client 10.1.4.80] /usr/local/lib/ruby/site_ruby/1.8/oci8.rb:49:in `create': ERROR (OCIError)
[Wed Jan 10 14:53:21 2007] [error] [client 10.1.4.80] \tfrom /usr/local/lib/ruby/site_ruby/1.8/oci8.rb:49
[Wed Jan 10 14:53:21 2007] [error] [client 10.1.4.80] \tfrom /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
[Wed Jan 10 14:53:21 2007] [error] [client 10.1.4.80] \tfrom /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
--
[Wed Jan 10 14:53:21 2007] [error] [client 10.1.4.80] \tfrom /home/software/jammer/rails/dashboard/public/../config/environment.rb:11:in `require'
[Wed Jan 10 14:53:21 2007] [error] [client 10.1.4.80] \tfrom /home/software/jammer/rails/dashboard/public/../config/environment.rb:11
[Wed Jan 10 14:53:21 2007] [error] [client 10.1.4.80] \tfrom /home/software/jammer/rails/dashboard/public/dispatch.cgi:3:in `require'
[Wed Jan 10 14:53:21 2007] [error] [client 10.1.4.80] \tfrom /home/software/jammer/rails/dashboard/public/dispatch.cgi:3
[Wed Jan 10 14:53:21 2007] [error] [client 10.1.4.80] Premature end of script headers: dispatch.cgi

I am able to make an Oralce connection and get back data using the steps described here: http://www.oracle.com/technology/pub/ar … q.html#3-2 So I'm not sure why create is causing a problem.

Anyone have any ideas?

Re: deploying rails app linux apache2 cgi

The problem was that the Apache user was not seeing the ORACLE_HOME directory. Fixed this by adding

SetEnv ORACLE_HOME /opt/oracle/9iR2

in the httpd.conf file.