Can we get a little more info? Config files, error logs, things you’ve
tried so far, etc…
Sure. Sorry. There’s another LONG thread where I went though all that
stuff which I should have referenced. But to avoid confusion (I’ve
figured out many of those issues since), I’ll start clean.
I’m running on RedHat ES3 with Plesk 7.5.4 server management
Apache2 is installed at /usr/sbin/httpd
Ruby is at 1.8.4
Rails at 1.1.2
mod_fastcgi-2.4.2
Since I’m using Plesk to manage my hosting service, it has this nasty
habit of wanting to control things (like it was asked to do… go
figure). So, anything you write into httpd.conf gets overwritten on
reboot. You get around this by including additional .conf files in
/etc/httpd/conf.d/. So, I added the following fastcgi.conf:
User apache
Group apache
LoadModule fastcgi_module /usr/lib/httpd/modules/mod_fastcgi.so
FastCgiWrapper on
FastCgiConfig -idle-timeout 900
FastCgiIpcDir /tmp/fastcgi_ipc/
AddHandler fastcgi-script .fcgi .rb
FastCgiServer
/home/httpd/vhosts/mydomain.com/httpdocs/myapp/dispatch.fcgi
-idle-timeout 120 -initial-env RAILS_ENV=production -processes 4
The User and Group bit ends up being repeated in the httpd.conf, but it
is necessary since Redhat loads anything in conf.d before the user and
group declarations. Next, I make sure CGI is enabled for the domain in
Plesk settings (if not, suexec will try to run the script as apache or
root which results in an application that doesn’t respond. Spent HOURS
on that one!)
Okay, so I upload myapp (which is set to rake freeze_gems at 1.1.1 btw)
to the domain root (behind the www root). Chown -R to the correct domain
user:group and chmod everything 755. I create a symbolic link named
‘myapp’ in the web root pointed to …/myapp/public and make sure owner
is correct and it is chmod 777 as well. Then I go into
myapp/public/.htaccess and make sure the dispatch.fcgi is uncommented
and .cgi version is commented out. Next, I move over to myapp/config/ to
change environment.rb to production mode. Then double check my
database.yml settings to make sure they point at the MySQL databases.
All good stuff right?
We’ll cool, I can log into myapp! But wait! I have no images. That’s
odd. And double-wait! My javascript isn’t loading!! Oh no… all those
AJAX actions… DEAD! And stylesheets? What are those??
From that point, I start looking into logs. Oh heck… the apache
error_log has literally hundreds of these:
[Wed Apr 12 14:08:23 2006] [warn] FastCGI: server
“/home/httpd/vhosts/mydomain.com/httpdocs/myapp/dispatch.fcgi” has
failed to remain running for 30 seconds given 3 attempts, its restart
interval has been backed off to 600 seconds
And likewise, suexec_log:
[2006-04-12 14:08:23]: uid: (apache/apache) gid: (apache/apache) cmd:
dispatch.fcgi
[2006-04-12 14:08:23]: crit: cannot run as forbidden uid
(48/dispatch.fcgi)
Hmmm… odd that some of the app runs despite this. Only public is being
hosed (well, and my logs!).
Did a little more looking around and saw someone suggest to add the
following to /vendor/rails/railties/lib/fcgi_handler.rb:
require ‘rubygems’
require_gem ‘fcgi’
since I did indeed install the gems version.
killed any ruby processes, cleaned out /tmp/fastcgi_ipc/, deleted any
cookies for the domain and did apachectl -k graceful
Went to the site, logged in, still no joy on public dir access.
Greeeeat.
So, I’m at a complete loss. The only other thing I was about to try in
desperation to use mod_fcgid instead of mod_fastcgi. I don’t really see
how that would change anything with /public, but I’ll try anything at
this point.
Thanks for your time! Sorry so long!
Ryan