Hi,
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):
Peak Obsession
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
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
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
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
<IfModule mod_fcgid.c>
DefaultInitEnv RAILS_ENV production
SocketPath /tmp/fcgidsock
AddHandler fcgid-script .fcgi
IdleTimeOut 3600
ProcessLifeTime 7200
MaxProcessCount 8
DefaultMaxClassProcessCount 3
IPCConnectTimeout 20
IPCCommTimeout 300
</IfModule>
/etc/vhosts.d/obra.conf
<VirtualHost app.obra.org:80>
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
</Directory>
</VirtualHost>
This is what I had before with Apache 2.0 and SuSE 10.0:
/etc/conf.d/mod_fastcgi.conf
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
FastCgiServer /srv/www/rails/obra/current/public/dispatch.fcgi -initial-env RAILS_ENV=production -processes 6 -idle-timeout 60
</IfModule>
BTW, thinking about your original post, does 'RAILS_ROOT/log/fastcgi.crash.log' exist, and is it writable by your Apache user?
Scott
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:
<VirtualHost app.obra.org:80>
DocumentRoot /srv/www/rails/obra/current/public
<Directory "/srv/www/rails/obra">
...
</Directory>
</VirtualHost>
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