Forum: Ruby on Rails Apache/FastCGI still in development mode?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ryan W. (Guest)
on 2006-04-11 03:17
I'm running rails on RedHat ES3 managed by Plesk with Apache/FastCGI.
I've followed the directions here:

http://wiki.rubyonrails.com/rails/pages/HowtoInsta...

And got everything working, but my application refuses to run in
Production mode. It runs in development mode despite the fact that I've
set:

FastCgiServer /home/httpd/vhosts/USER/httpdocs/rails/dispatch.fcgi
-idle-timeout 120 -initial-env RAILS_ENV=production -processes 4

in fastcgi.conf and switched the .htaccess file over to:

RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

What else could possibly be forcing it over to development mode?
Ryan W. (Guest)
on 2006-04-11 20:11
I'm still not finding a solution on this issue. I have confirmed that
the application is indeed running in development mode by putting <%=
debug(RAILS_ENV) %> in one of my views. Also, none of my images are
loading. If I try to access them directly, I get a routing error.
Looking at the development log (production log is of course empty), I'm
getting routing errors on anything in the public directory (javascript
libs, stylesheets, images, etc.). This leads me to believe that the
public directory is not being recognized, which would also mean that the
.htaccess file with the dispatch.fcgi rule is being ignored. I've
checked owner and permissions on /public and everything in it and all
seems right. I don't see how the application would work at all without
finding the .htaccess. And, based on the fast response, the app
certainly seems to be using fastCGI. Is there a way to verify this with
an ENV variable or something?

FWIW, I also created a test application on the server and it too will
not run in production mode. Definitely seems to be a configuration issue
with FastCGI somewhere, but I can't figure out what.

Any suggestions would be greatly appreciated.

RedHat el3
Plesk 7.5.4
Ruby 1.8.4
Rails 1.1.2 (and tried 1.1.1 from vendor freeze)
Wes G. (Guest)
on 2006-04-11 20:16
Are you sure that your fastcgi.conf file is being included by the main
Apache httpd.conf file?

Wes

Ryan W. wrote:
> I'm still not finding a solution on this issue. I have confirmed that
> the application is indeed running in development mode by putting <%=
> debug(RAILS_ENV) %> in one of my views. Also, none of my images are
> loading. If I try to access them directly, I get a routing error.
> Looking at the development log (production log is of course empty), I'm
> getting routing errors on anything in the public directory (javascript
> libs, stylesheets, images, etc.). This leads me to believe that the
> public directory is not being recognized, which would also mean that the
> .htaccess file with the dispatch.fcgi rule is being ignored. I've
> checked owner and permissions on /public and everything in it and all
> seems right. I don't see how the application would work at all without
> finding the .htaccess. And, based on the fast response, the app
> certainly seems to be using fastCGI. Is there a way to verify this with
> an ENV variable or something?
>
> FWIW, I also created a test application on the server and it too will
> not run in production mode. Definitely seems to be a configuration issue
> with FastCGI somewhere, but I can't figure out what.
>
> Any suggestions would be greatly appreciated.
>
> RedHat el3
> Plesk 7.5.4
> Ruby 1.8.4
> Rails 1.1.2 (and tried 1.1.1 from vendor freeze)
Ryan W. (Guest)
on 2006-04-11 21:25
Wes G. wrote:
> Are you sure that your fastcgi.conf file is being included by the main
> Apache httpd.conf file?

Well, it certainly *seems* to be. I don't see how the app was running at
all otherwise. That's what I've been trying to confirm. Oddly, I was
able to get the simple test app running in production mode finally
(after a few server and apache restarts), but the main app now will no
longer respond at all. The browser simply spins with a "Waiting for
www.mydomain.com" message. And the issue isn't with the domain itself,
since .html is being served from other directories.

Frustrating.
Ryan W. (Guest)
on 2006-04-11 22:04
Okay, we have confirmed with our host that FastCGI is indeed working. My
host checked for syntax errors with "httpd -t". They also created a
Redirect to ensure that it was working. So, that's not the issue.

Regardless, even a simple test app for whatever reason will not see
anything in /public. The index.html produces a 404 and I tried to
directly call the rails.png that installs by default with the same
result. It's public is recursively permissioned 777 and chowned
correctly. Just for a laugh, I even modified the 404.html which it IS
showing me and the changes were indeed output. I'm at a total loss.
Maybe I should bump this to a new post at this point.
Steve K. (Guest)
on 2006-04-11 22:29
Since this looks like an Apache configuration error, please post more
than two lines of the relevant parts of your Apache conf files. The
section regarding configuration of your fcgi module and the entire
virtualhost block for your app would be a good place to start.

Also, are you deploying a simple copy of your application's diorectory
tree or are you deploying with Capistrano?

Ryan W. wrote:
> Okay, we have confirmed with our host that FastCGI is indeed working. My
> host checked for syntax errors with "httpd -t". They also created a
> Redirect to ensure that it was working. So, that's not the issue.
>
> Regardless, even a simple test app for whatever reason will not see
> anything in /public. The index.html produces a 404 and I tried to
> directly call the rails.png that installs by default with the same
> result. It's public is recursively permissioned 777 and chowned
> correctly. Just for a laugh, I even modified the 404.html which it IS
> showing me and the changes were indeed output. I'm at a total loss.
> Maybe I should bump this to a new post at this point.
Nuno (Guest)
on 2006-04-11 22:44
Have you checked access rights for you DBMS in production mode ? Is
database.yml correctly configured ?
Ryan W. (Guest)
on 2006-04-11 23:25
Steve K. wrote:
> Since this looks like an Apache configuration error, please post more
> than two lines of the relevant parts of your Apache conf files. The
> section regarding configuration of your fcgi module and the entire
> virtualhost block for your app would be a good place to start.

This is a Plesk managed system, so it complete controls the vhost blocks
and there's no changing them. The FastCGI config is included via a conf
file in /etc/httpd/conf.d/fastcgi.conf:

User apache
Group apache
LoadModule fastcgi_module /usr/lib/httpd/modules/mod_fastcgi.so

<IfModule mod_fastcgi.c>
    FastCgiWrapper on
    FastCgiConfig -idle-timeout 900
    FastCgiIpcDir /tmp/fastcgi_ipc/
    AddHandler fastcgi-script .fcgi .rb
    FastCgiServer
/home/httpd/vhosts/my1stdomain.com/httpdocs/rails/dispatch.fcgi
-idle-timeout 120 -initial-env RAILS_ENV=production -processes 4
    FastCgiServer
/home/httpd/vhosts/my2nddomain.com/httpdocs/myapp/dispatch.fcgi
-idle-timeout 120 -initial-env RAILS_ENV=production -processes 4
</IfModule>

in the httpd error_log I'm getting TONS of these:

[Tue Apr 11 13:59:19 2006] [warn] FastCGI: server
"/home/httpd/vhosts/mydomain.com/httpdocs/rails/dispatch.fcgi" has
failed to remain running for 30 seconds given 3 attempts, its restart
interval has been backed off to 600 seconds

for either of the apps.
then, in the suexec_log:

[2006-04-11 15:09:19]: uid: (apache/apache) gid: (apache/apache) cmd:
dispatch.fcgi
[2006-04-11 15:09:19]: crit: cannot run as forbidden uid
(48/dispatch.fcgi)


The test app at my1stdomain.com/rails/ at least responds, though nothing
in public is accessible. The actual app that I'm trying to deploy at
my2nddomain.com/myapp/ won't even respond.

The test app was created live on the server. The main app that I'm
trying to deploy was a copy of the directory tree which was tarred,
unpacked, chowned and chmoded appropriately. The directories reside
behind the webroot with a symbolic link in the webroot pointing back at
../myapp/public and are also chowned and chmoded appropriately.
Ryan W. (Guest)
on 2006-04-11 23:26
Nuno wrote:
> Have you checked access rights for you DBMS in production mode ? Is
> database.yml correctly configured ?

Yes. They are correct. Even if they weren't though, Rails would throw me
errors saying such. This isn't responding at all.
Ryan W. (Guest)
on 2006-04-12 02:50
From my hosting provider:

It appears that the script is attempting to be executed as either
apache48 or root

[2006-04-11 17:28:30]: uid: (root/root) gid: (0/0) cmd: dispatch.fcgi
[2006-04-11 17:28:30]: crit: cannot run as forbidden uid
(0/dispatch.fcgi)


SUExec does not allow this, the script must be executed as the
user/group that owns that domain.

I'm not sure where this is configured in ruby on rails but you should
check to be sure that it's execing as the user that owns the file.

---

Anyone?
Al E. (Guest)
on 2006-04-12 20:11
Ryan W. wrote:
> From my hosting provider:
>
> It appears that the script is attempting to be executed as either
> apache48 or root
>
> [2006-04-11 17:28:30]: uid: (root/root) gid: (0/0) cmd: dispatch.fcgi
> [2006-04-11 17:28:30]: crit: cannot run as forbidden uid
> (0/dispatch.fcgi)
>
>
> SUExec does not allow this, the script must be executed as the
> user/group that owns that domain.
>
> I'm not sure where this is configured in ruby on rails but you should
> check to be sure that it's execing as the user that owns the file.
>
> ---
>
> Anyone?

uh, chown -R your_user.your_group your_app_dir

Doesn't seem likely, but it's the only thing that came to mind.

Here's what suexec is supposed to be checking:

http://httpd.apache.org/docs/1.3/suexec.html

--Al Evans
Ryan W. (Guest)
on 2006-04-12 20:46
> uh, chown -R your_user.your_group your_app_dir
>
> Doesn't seem likely, but it's the only thing that came to mind.
>
> Here's what suexec is supposed to be checking:
>
> http://httpd.apache.org/docs/1.3/suexec.html

Thanks Al. Actually, I had tired that (several times). Most of the
suexec issues were with regard to not having CGI enabled on the domain
in the Plesk manager. That said, I still have no access to the public
directory, and FastCGI is spawning all kinds of orphaned processes. I'm
going to try switching to mod_fcgid and see if that helps. Otherwise, I
think I'll be begging the guys at http://www.railsmachine.com to go
ahead and launch their hosting service!
Steve K. (Guest)
on 2006-04-12 22:40
Plessk, huh? apache48, huh?

1. Is this a non-VPS shared hosting account? If so, in all likelihood
stuff is going to run only under *your* user and group(s).

2. Where did User and Group "apache" come from? Are they a user and
group you use, or that you created? Can you create a file and chown it
to "apache"?

3. Do you do suexecs to users and groups you specify in any non-rails
apps you have on this host? If so, are those the user and group you get
on files that those apps write to, say, your temp dir?

Ryan W. wrote:
> Steve K. wrote:
>> Since this looks like an Apache configuration error, please post more
>> than two lines of the relevant parts of your Apache conf files. The
>> section regarding configuration of your fcgi module and the entire
>> virtualhost block for your app would be a good place to start.
>
> This is a Plesk managed system, so it complete controls the vhost blocks
> and there's no changing them. The FastCGI config is included via a conf
> file in /etc/httpd/conf.d/fastcgi.conf:
>
> User apache
> Group apache
> LoadModule fastcgi_module /usr/lib/httpd/modules/mod_fastcgi.so
...:: snip ::
Ryan W. (Guest)
on 2006-04-12 23:01
> 1. Is this a non-VPS shared hosting account? If so, in all likelihood
> stuff is going to run only under *your* user and group(s).

This is a dedicated server. We simply use Plesk to allow our hosting
clients to manage their virtual hosting accounts. So, I have complete
access to the server config within reason (thing that won't adversly
effect Plesk!).

> 2. Where did User and Group "apache" come from? Are they a user and
> group you use, or that you created? Can you create a file and chown it
> to "apache"?

Literally... here:

http://wiki.rubyonrails.com/rails/pages/HowtoInsta...

The frustrating thing being that others have obviously had this working.
There was also supposedly a detailed three-part guide on setting this up
at http://www.soapboxconfessional.com, but the guy has since killed his
server.

> 3. Do you do suexecs to users and groups you specify in any non-rails
> apps you have on this host? If so, are those the user and group you get
> on files that those apps write to, say, your temp dir?

Yes, they are all apache:apache as well... without issue.
Ryan W. (Guest)
on 2006-04-12 23:05
And there is now a new thread that clarifies what's going on with this a
little better here:

http://www.ruby-forum.com/topic/61866

Please take a look... I would really appreciate it.
Ryan W. (Guest)
on 2006-04-13 22:06
I gave up on FastCGI. Went with SCGI instead, which is GREAT!

Here's my addition to the wiki:

http://wiki.rubyonrails.org/rails/pages/RailsWithSCGIonPlesk
This topic is locked and can not be replied to.