# Fcgi to run cgi scripts

**URL:** <https://www.ruby-forum.com/t/fcgi-to-run-cgi-scripts/53472>\
**Category:** Rails\
**Created:** [February 6, 2006, 11:30pm UTC](https://www.ruby-forum.com/t/fcgi-to-run-cgi-scripts/53472 "2006-02-06T23:30:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ezran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b9bd4f/32.png) [@ezran](https://www.ruby-forum.com/u/ezran)\
**Post date:** [February 6, 2006, 11:30pm UTC](https://www.ruby-forum.com/t/fcgi-to-run-cgi-scripts/53472/1 "2006-02-06T23:30:16Z")

</div>

Dear experts,

I have rail site that is running lighttpd and fcgi. I want the default  
domain to serve the rails application, and I also want to have a  
virtualhost (bugs.mysite) to resolve to a bugzilla instance.

Bugzilla is basically Perl application called through CGI.

I tried to find pointers on how to set fcgi to run both rails dispatcher  
and other cgi scripts in a different virtualhost, and I didn’t find  
anything. Would anyone be so kind to show me where to go, or tell me how  
to configure fcgi?

Thanks a lot.

Ezra

Here is my current config file:

server.document-root = “/opt/webspace/mysite/public”

server.port = 80  
server.username = “apache”  
server.groupname = “apache”  
server.modules = (“mod\_rewrite”,“mod\_redirect”,“mod\_fastcgi”, “mod\_cgi”)

fastcgi.server = (".fcgi" =\>  
( “railsapp” =\>  
( “min-procs” =\> 1,  
“max-procs” =\> 5,  
“socket” =\> “/tmp/ruby-railsapp.fastcgi”,  
“bin-path” =\> “/opt/webspace/mysite/public/dispatch.fcgi”  
)  
)  
)

server.indexfiles = ( “index.html”, “index.cgi” )  
server.error-handler-404 = “/dispatch.fcgi”

mimetype.assign = (  
“.html” =\> “text/html”,  
“.txt” =\> “text/plain”,  
“.jpg” =\> “image/jpeg”,  
“.png” =\> “image/png”  
)

index-file.names = ( “index.html”, “index.cgi” )

$HTTP[“host”] == “bugs.mysite” {  
server.document-root = “/opt/webspace/bugzilla-2.20/”  
accesslog.filename = “/Users/USER/Sites/rails/log/access.log”

}

---

<div class="post-metadata">

**Author:** ![ezran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b9bd4f/32.png) [@ezran](https://www.ruby-forum.com/u/ezran)\
**Post date:** [February 7, 2006, 12:00am UTC](https://www.ruby-forum.com/t/fcgi-to-run-cgi-scripts/53472/2 "2006-02-07T00:00:35Z")

</div>

On Feb 6, 2006, at 2:29 PM, Ezra Nugroho wrote:

> dispatcher  
> and other cgi scripts in a different virtualhost, and I didn’t find  
> anything. Would anyone be so kind to show me where to go, or tell  
> me how  
> to configure fcgi?
> 
> Thanks a lot.
> 
> Ezra

Ezra-

```
Try this config on for size. I don't think it will work the way you

```

are doing things. I have left out the mime-types, just add those in  
at the bottom. Here are the options for the mod\_cgi module:

file-extensions that are handled by a CGI program

e.g.:

cgi.assign = ( “.pl” =\> “/usr/bin/perl”,  
“.cgi” =\> “/usr/bin/perl” )  
Examples

To setup a executable which doesn’t need the help of a external  
program you just don’t specify a handler for the extension.

cgi.assign = ( “.sh” =\> “” )  
If the file has no extension keep in mind that lighttpd matches not  
the extension itself but the right part of the URL:

cgi.assign = ( “/testfile” =\> “” )

#########begin lighttpd.conf###############

server.modules = (  
“mod\_rewrite”,  
“mod\_redirect”,  
“mod\_access”,  
“mod\_fastcgi”,  
“mod\_cgi”  
“mod\_compress”,  
“mod\_accesslog” )

server.document-root = “/var/www”  
server.bind = “0.0.0.0”  
server.port = 80  
server.pid-file = “/tmp/main\_lighttpd.pid”  
server.tag = “lighttpd”  
accesslog.filename = “/var/log/lighttpd.access.log”  
server.errorlog = “/var/log/lighttpd.error.log”  
server.indexfiles = ( “index.html”, “index.htm”,  
“default.htm” )  
url.access-deny = ( “~”, “.inc” )

$HTTP[“host”] =~ “(^|www.)example.com” {  
server.document-root = “/home/ezra/railsapp/public/”  
server.error-handler-404 = “/dispatch.fcgi”  
server.indexfiles = ( “dispatch.fcgi”)  
server.errorlog = “/home/ezra/railsapp/log/error.typo1.log”  
fastcgi.server = ( “.fcgi” =\>  
( “localhost” =\>  
( “socket” =\> “/tmp/railsapp.socket”,  
“min-procs” =\> 2,  
“max-procs” =\> 2,  
“bin-path” =\> “/home/ezra/railsapp/public/dispatch.fcgi”,  
“bin-environment” =\> ( “RAILS\_ENV” =\> “production” )  
)))  
}

$HTTP[“host”] =~ “bugs.example.com” {  
server.document-root = “/opt/webspace/bugzilla-2.20/”  
accesslog.filename = “/Users/USER/Sites/rails/log/access.log”  
cgi.assign = ( “.pl” =\> “/usr/bin/perl”,  
“.cgi” =\> “/usr/bin/perl” )  
}

# add mime-type assigns here

Cheers-  
-Ezra Z.  
Yakima Herald-Republic  
WebMaster

> **[yakimaherald.com | Yakima, Washington - We Tell Your Stories](https://www.yakimaherald.com/)**

509-577-7732  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ezran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b9bd4f/32.png) [@ezran](https://www.ruby-forum.com/u/ezran)\
**Post date:** [February 7, 2006, 12:06am UTC](https://www.ruby-forum.com/t/fcgi-to-run-cgi-scripts/53472/3 "2006-02-07T00:06:40Z")

</div>

Oh, one more thing. The mod\_cgi module is broken in a few recent  
releases of lighttpd. It might only affect 1.4.9 but maybe 1.4.8 too,  
im not sure. I do know that it is fixed in the svn repo in 1.4.10.

Cheers-  
-Ezra

On Feb 6, 2006, at 2:54 PM, Ezra Z. wrote:

> > 
> 
> e.g.:  
> the extension itself but the right part of the URL:  
> “mod\_redirect”,  
> server.pid-file = “/tmp/main\_lighttpd.pid”  
> server.error-handler-404 = “/dispatch.fcgi”  
> }
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

-Ezra Z.  
Yakima Herald-Republic  
WebMaster

> **[yakimaherald.com | Yakima, Washington - We Tell Your Stories](https://www.yakimaherald.com/)**

509-577-7732  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ezran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b9bd4f/32.png) [@ezran](https://www.ruby-forum.com/u/ezran)\
**Post date:** [February 7, 2006, 12:23am UTC](https://www.ruby-forum.com/t/fcgi-to-run-cgi-scripts/53472/4 "2006-02-07T00:23:14Z")

</div>

Ezra,

Thanks for your quick response.

This is probably the culprit!  
I saw that document about mod\_cgi too, and I couldn’t make it work.  
That’s why I thought of using mod\_fcgi instead.

Hmm… I wonder what my options are…  
Is there some other bug tracking package that is friendly with lighttpd  
and fcgi?

Do you know about Tract? It uses Python, so I don’t know if it will  
complicate the site requirement even further…

Thanks,  
Ezra

---

<div class="post-metadata">

**Author:** ![ezran](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b9bd4f/32.png) [@ezran](https://www.ruby-forum.com/u/ezran)\
**Post date:** [February 7, 2006, 2:16am UTC](https://www.ruby-forum.com/t/fcgi-to-run-cgi-scripts/53472/5 "2006-02-07T02:16:15Z")

</div>

1.4.8 works fine. 1.4.9 is broken as Ezra mentions.

Zack
