Rails FastCGI deployment problem

R

Robert Feldt

Some of our students have developed a Rails app on Windows (w rails
0.8.5) that we now want to deploy on a linux (gentoo) server with
apache and FastCGI and rails 0.9.5. We have followed the tutorial and
converted the app to 0.9.5 and it seems to work since we can access it
when we run it via webbrick.

We have also tried following the different (quite spread and hard to
find in one easy place IOHO ;)) advice on how to deploy on FastCGI but
it does not work. Below are some extracts from relevant config and log
files. Please help spot our mistake since we need to get this up and
running and FastCGI (and ok rails ;)) is new to us.

Thanks,

Robert

/etc/conf.d/apache2:
...
APACHE2_OPTS="-D SSL -D DAV -D DAV_FS -D SVN -D FASTCGI"
...

/etc/apache2/conf/modules.d/20_mod_fastcgi.conf:
<IfDefine FASTCGI>
<IfModule !mod_fastcgi.c>
LoadModule fastcgi_module extramodules/mod_fastcgi.so
</IfModule>

<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
</IfModule>
</IfDefine>

/etc/apache2/conf/vhosts/ourvhosts.conf:
NameVirtualHost *:80

<VirtualHost *:80>
ServerName orig.htu.se
DocumentRoot /var/www/localhost/htdocs
...
</VirtualHost>

<VirtualHost *:80>
ServerName railsapp.htu.se
DocumentRoot /home/railsapp/railsapp/public
ErrorLog /home/railsapp/railsapp/log/apache.log

<Directory /home/railsapp/railsapp/public/>
Options ExecCGI FollowSymLinks
AddHandler cgi-script .cgi
AddHandler fastcgi-script .fcgi
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

/home/railsapp/railsapp/public/.htaccess:
...
RewriteBase /dispatch.fcgi
...

Now when I try to open railsapp.htu.se I get in my browser:

"Application error (Apache)

Change this error message for exceptions thrown outside of an action
(like in Dispatcher setups or broken Ruby code) in public/500.html"

and /home/railsapp/railsapp/log/apache.log contains:

[Sun Feb 13 22:48:21 2005] [error] [client 212.109.29.132] FastCGI: comm with (d
ynamic) server "/home/score/s-core/public/dispatch.fcgi" aborted: (first read) i
dle timeout (30 sec)
[Sun Feb 13 22:48:21 2005] [error] [client 212.109.29.132] FastCGI: incomplete h
eaders (0 bytes) received from server "/home/score/s-core/public/dispatch.fcgi"
[Sun Feb 13 22:48:22 2005] [error] [client 212.109.29.132] File does not exist:
/home/score/s-core/public/favicon.ico
 
R

Robert Feldt

Oops, the path in that log file should be /home/railsapp/railsapp/...
we have been trying different names and I copied the wrong one so
don't mind that... ;)

/R
 
T

Tobias Luetke

Please have a look in /var/log/apache2/error_log. Especially after the
first request to the rails app after an apache startup.

Pasting this should help
 
R

Robert Feldt

The first lines after a restart followed by request:

[Sun Feb 13 22:43:51 2005] [notice] Digest: generating secret for digest authent
ication ...
[Sun Feb 13 22:43:51 2005] [notice] Digest: done
[Sun Feb 13 22:43:52 2005] [notice] FastCGI: process manager initialized (pid 14
728)
[Sun Feb 13 22:43:52 2005] [notice] Apache/2.0.50 (Gentoo/Linux) DAV/2
mod_fastcgi/2.4.2 mod_ssl/2.0.50 OpenSSL/0.9.7d SVN/1.1.1 configured
-- resuming normal operations
FastCGI: can't start server
"/home/railsapp/railsapp/public/dispatch.fcgi" (pid 14780), execle()
failed: No such file or directory
[Sun Feb 13 22:47:47 2005] [warn] FastCGI: (dynamic) server
"/home/railsapp/railsapp//public/dispatch.fcgi" started (pid 14780)
[Sun Feb 13 22:47:47 2005] [warn] FastCGI: (dynamic) server
"/home/railsapp/railsapp/public/dispatch.fcgi" (pid 14780) terminated
by calling exit with status '255'
FastCGI: can't start server
"/home/railsapp/railsapp//public/dispatch.fcgi" (pid 14781), execle()
failed: No such file or directory

But that file is there and is readable by the webserver...

Best,

Robert
 
N

Navindra Umanee

Robert Feldt said:
But that file is there and is readable by the webserver...

What does:

ls -al /home/railsapp/railsapp/public/dispatch.fcgi

and:

head /home/railsapp/railsapp/public/dispatch.fcgi

say?

I'm guessing that the "#!" or whatever line at the top of
/home/railsapp/railsapp/public/dispatch.fcgi is pointing to the wrong
thing.

Cheers,
Navin.
 
R

Robert Feldt

What does:

ls -al /home/railsapp/railsapp/public/dispatch.fcgi

and:

head /home/railsapp/railsapp/public/dispatch.fcgi

say?

I'm guessing that the "#!" or whatever line at the top of
/home/railsapp/railsapp/public/dispatch.fcgi is pointing to the wrong
thing.
Good guess. Thanks a lot guys, the porting from windows wasnt perfect... ;)

Now we can get down to the real testing... :)

Best,

Robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top