RoR with apache2 on SuSE

Hi,
I have an application completed that was built with RoR on windows. So
this of course was tested with the webbrick server. I now want to put
the project on our apache web server for production. I am having a very
hard time getting this accomplished. I followed some of the steps here
(because not all of them worked):
http://wiki.rubyonrails.com/rails/pages/HowtoSetupApacheWithFastCGIAndRubyBindings
And I have managed to get ruby, rails, fcgi, and mod_fcgi all installed
and working. I even have a test fcgi script that runs fine. However,
I’m just not sure how to reference the project once it is on the server.
With webbrick you just say localhost:3000/project_name. But we can’t
say http://192.168.X.X/project_name on the apache web server because
there is no index document. I can hit
http://192.168.X.X/project_name/public but when I click on about your
applications environment I get this ugly output:

#!/usr/bin/ruby # # You may specify the path to the FastCGI crash log (a
log of unhandled # exceptions which forced the FastCGI instance to exit,
great for debugging) # and the number of requests to process before
running garbage collection. # # By default, the FastCGI crash log is
RAILS_ROOT/log/fastcgi.crash.log # and the GC period is nil (turned
off). A reasonable number of requests # could range from 10-100
depending on the memory footprint of your app. # # Example: # # Default
log path, normal GC behavior. # RailsFCGIHandler.process! # # # Default
log path, 50 requests between GC. # RailsFCGIHandler.process! nil, 50 #

# Custom log path, normal GC behavior. # RailsFCGIHandler.process!

‘/var/log/myapp_fcgi_crash.log’ # require File.dirname(FILE) +
“/…/config/environment” require ‘fcgi_handler’
RailsFCGIHandler.process!

All of the tutorials that I find seem to say the same stuff, has anyone
set this up before that could help?

thanks,

Tate

Hi,

On Sep 19, 2006, at 2:24 PM, Tate H. wrote:

Peak Obsession
applications environment I get this ugly output:
Default
anyone
set this up before that could help?

thanks,

Tate

Last time I tried to set up Apache + FastCGI + Rails on SuSE, it
didn’t work out so hot. Apache 2.2 is the default Apache version, and
I couldn’t get mod_fcgi and FastCGI installed and compiled happily.
The situation may have changed, and someone who actually knows what
they are doing could probably get it to work, but I ended up using
fcgid, and that’s been fine.

If you want details about what I tried or have running now, let me know.

My advice to you – though, I haven’t done this on SuSE – is to go
with mongrel. It’s much easier to set up and works great. You’ll also
need something like pound out in front on a production site.

Scott

Yeah, if you could detail what you have and how it is working, that
would be awesome. I have fcgid running and it does work because I can
run a test script. But I would like to know how to get a ruby project
up and running with this framework. It doesn’t even have to be the one
that is already developed…I would be completely happy making a new
project and seeing it run.

thanks,

If you’ve got apache 2.2, it makes a nice load balance in front of
mongrel
and mongrel_cluster :

http://mongrel.rubyforge.org/docs/apache.html

On 9/20/06, Tate H. [email protected] wrote:


Posted via http://www.ruby-forum.com/.


Charles Brian Q.
self-promotion: www.seebq.com
highgroove studios: www.highgroove.com
slingshot rails hosting: www.slingshothosting.com

On Sep 20, 2006, at 8:20 AM, Tate H. wrote:

Yeah, if you could detail what you have and how it is working, that
would be awesome. I have fcgid running and it does work because I can
run a test script. But I would like to know how to get a ruby project
up and running with this framework. It doesn’t even have to be the
one
that is already developed…I would be completely happy making a new
project and seeing it run.

By “running with this framework,” you mean Mongrel + Apache? Take a
look here: http://mongrel.rubyforge.org/docs/apache.html. I have a
similar set-up on a BSD staging server, and I like it. Though I have
to say that fcgid has done just fine on a moderately-high traffic site.

Here’s a summary of what I’ve got in production on SuSE 10.1:

apache2 2.2.0
apache2-devel 2.2.0
apache2-prefork 2.2.0
libapr1 1.2.2
libapr1-devel 1.2.2
ruby 1.8.4
FastCGI 2.4.0
FastCGI-devel 2.4.0
apache2-mod_fcgid 1.07
Ruby fcgi 0.8.7
(ruby-fcgi 0.8.6 SuSE packages not installed)

/etc/sysconfig/apache2
APACHE_MODULES: fcgid

/etc/conf.d/mod_fcgid.conf

DefaultInitEnv RAILS_ENV production
SocketPath /tmp/fcgidsock
AddHandler fcgid-script .fcgi
IdleTimeOut 3600
ProcessLifeTime 7200
MaxProcessCount 8
DefaultMaxClassProcessCount 3
IPCConnectTimeout 20
IPCCommTimeout 300

/etc/vhosts.d/obra.conf

DocumentRoot /srv/www/rails/obra/current/public
ErrorLog /srv/www/rails/obra/current/log/server.log
UseCanonicalName On
<Directory “/srv/www/rails/obra”>
Options ExecCGI FollowSymLinks
AllowOverride All
Allow from all
Order allow,deny

This is what I had before with Apache 2.0 and SuSE 10.0:
/etc/conf.d/mod_fastcgi.conf

FastCgiIpcDir /tmp/fcgi_ipc/
FastCgiServer /srv/www/rails/obra/current/public/dispatch.fcgi -
initial-env RAILS_ENV=production -processes 6 -idle-timeout 60

BTW, thinking about your original post, does ‘RAILS_ROOT/log/
fastcgi.crash.log’ exist, and is it writable by your Apache user?

Scott

Thanks for all of the help guys…I’ll try those links out.

Scott, that is roughly how I have my SuSE server set up. I’m just a
little confused at how to access a new RoR project. Lets say my server
ip is 192.168.1.80
and I create a new project called test with “rails test”

Do I use http://192.168.1.80/test/ as the url?

There is no index document in there by default. Rails does have one at:
http://192.168.1.80/test/public/

But that is just a welcome page.

thanks again,

I’ve had really good luck with the instructions outlined here:

http://blog.codahale.com/2006/06/19/time-for-a-grown-up-server-rails-mongrel-apache-capistrano-and-you/

I did not do the Capistrano setup piece, and I used proxy-pass
directives in httpd.conf instead of the various rewrite rules, but it’s
speedy and flexible.

c.

Put a symbolic link in your apache documents folder to
<rails_dir>/test/public. For instance (assuming file locations),

cd /usr/local/apache2/htdocs
ln -s /var/rails/test/public ./test

Now you can access your rails application at http://192.168.1.80/test/
(assuming all other stuff being set up appropriately).

You’ll need to remove/rename the index document in the rails public
folder.

c.

Tate H. wrote:

Thanks for all of the help guys…I’ll try those links out.

Scott, that is roughly how I have my SuSE server set up. I’m just a
little confused at how to access a new RoR project. Lets say my server
ip is 192.168.1.80
and I create a new project called test with “rails test”

Do I use http://192.168.1.80/test/ as the url?

There is no index document in there by default. Rails does have one at:
http://192.168.1.80/test/public/

But that is just a welcome page.

thanks again,

Thanks guys,
I got it going with mongrel behind my apache server.

thanks for all of the help!

On Sep 21, 2006, at 5:06 AM, Tate H. wrote:

There is no index document in there by default. Rails does have one
at:
http://192.168.1.80/test/public/

But that is just a welcome page.

thanks again,

The Apache virtual host entry + Rails’ routes.rb determine the URL.
RAILS_ROOT/public is the root for static content. In your example,
http://192.168.1.80 will return the default public/index.html page.

With my example config:

DocumentRoot /srv/www/rails/obra/current/public
<Directory “/srv/www/rails/obra”>


routes.rb:
map.connect “/schedule/:year/:action”, :controller => “schedule”

So, http://app.obra.org/schedule/2006/list gets you to my
ScheduleController’s list method. If you want to handle requests like
http://app.obra.org, see the comments in routes.rb. If you want to
set up different Rails projects in their own directories (e.g.,
http://www.obra.org/test_project/), you’ll need to set up Locations
in your Apache config.

Scott