# Can't set up rails: dispatch.cgi failed

**URL:** <https://www.ruby-forum.com/t/cant-set-up-rails-dispatch-cgi-failed/101069>\
**Category:** Ruby\
**Created:** [August 3, 2006, 12:14pm UTC](https://www.ruby-forum.com/t/cant-set-up-rails-dispatch-cgi-failed/101069 "2006-08-03T12:14:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 3, 2006, 12:14pm UTC](https://www.ruby-forum.com/t/cant-set-up-rails-dispatch-cgi-failed/101069/1 "2006-08-03T12:14:11Z")

</div>

Hi,

I’m trying to setup RoR on OpenBSD 3.9 with Ruby 1.8.4 and Apache 1.3.  
I’ve setup Rails to run as a Virtual Host, and I can view the “Welcome  
Aboard” page. When I try to access http:///category/ though, I  
get an “Application error…Rails application failed to start properly”  
message. Apache.log has this error:

[error] (2)No such file or directory: exec of /todo/public/dispatch.cgi  
failed  
[error] [client 192.168.2.128] Premature end of script headers:  
/todo/public/dispatch.cgi

The rewrite log has a string of actions ending with:  
192.168.2.128 - - [01/Aug/2006:18:06:21 -0700]  
[todo/sid#8931257c][rid#86bbd034/initial] (4) RewriteCond:  
input=’/todo/public/images/rails.png’ pattern=’!-f’ =\> not-matched  
192.168.2.128 - - [01/Aug/2006:18:06:21 -0700]  
[todo/sid#8931257c][rid#86bbd034/initial] (1) [per-dir /todo/public/]  
pass through /todo/public/images/rails.png

I have the right path to ruby in .htaccess, have 755 permissions in my  
public directory, and have edited .htaccess to route through  
dispatch.cgi.

Can anyone help?

I’ve pasted my dispatch.cgi and .htaccess files below.

Thanks in advance,  
Josiah

## .htaccess

AddHandler fastcgi-script .fcgi  
AddHandler cgi-script .cgi  
Options +FollowSymLinks +ExecCGI

RewriteEngine On

RewriteRule ^$ index.html [QSA]  
RewriteRule ^([^.]+)$ $1.html [QSA]  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteRule ^(.\*)$ dispatch.cgi [QSA,L]

ErrorDocument 500 “

## Application error
Rails application failed  
to start p  
roperly”
## dispatch.cgi

#!/usr/local/bin/ruby

require File.dirname( **FILE** ) + “/…/config/environment” unless  
defined?(RAILS\_ROOT)

require “dispatcher”  
#require  
“/usr/local/lib/ruby/gems/1.8/gems/actionwebservice-1.1.4/lib/action\_web\_service/dispatcher”

ADDITIONAL\_LOAD\_PATHS.reverse.each { |dir| $:.unshift(dir) if  
File.directory?(dir) } if defined?(Apache::RubyRun)  
Dispatcher.dispatch

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 3, 2006, 12:32pm UTC](https://www.ruby-forum.com/t/cant-set-up-rails-dispatch-cgi-failed/101069/2 "2006-08-03T12:32:18Z")

</div>

On 8/2/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [error] [client 192.168.2.128] Premature end of script headers:  
> /todo/public/dispatch.cgi
> 
> The rewrite log has a string of actions ending with:  
> 192.168.2.128 - - [01/Aug/2006:18:06:21 -0700]  
> [todo/sid#8931257c][rid#86bbd034/initial] (4) RewriteCond:  
> input=‘/todo/public/images/rails.png’ pattern=‘!-f’ =\> not-matched  
> 192.168.2.128 - - [01/Aug/2006:18:06:21 -0700]  
> [todo/sid#8931257c][rid#86bbd034/initial] (1) [per-dir /todo/public/]  
> pass through /todo/public/images/rails.png

these lines relate to the welcome aboard page.

Try asking in rails forum, perhaps they’ll know better (even though  
there is much overlap between these two, I suppose)

> **[Community](https://rubyonrails.org/community)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

J.
