# Multiple \*.fcgi in /cgi-bin/ directory - binding

**URL:** <https://www.ruby-forum.com/t/multiple-fcgi-in-cgi-bin-directory-binding/208519>\
**Category:** NGINX\
**Created:** [June 20, 2011, 2:51pm UTC](https://www.ruby-forum.com/t/multiple-fcgi-in-cgi-bin-directory-binding/208519 "2011-06-20T14:51:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 20, 2011, 2:51pm UTC](https://www.ruby-forum.com/t/multiple-fcgi-in-cgi-bin-directory-binding/208519/1 "2011-06-20T14:51:18Z")

</div>

While trying to configure fastcgi with nginx, here are the steps that  
I have followed so far:

In /etc/nginx/nginx.conf:

```
    server {
            localhost 127.0.01;
            ..
            ..

            location ~ ^/cgi-bin/.*\.fcgi$ {
                    root /srv/prod/bin;
                    include /etc/nginx/fastcgi.conf;
                    #fastcgi_pass 127.0.0.1:9000;
                    fastcgi_pass unix:/tmp/user.socket;

            }
}

```

/etc/nginx/fastcgi.conf:

cat /etc/nginx/fastcgi.conf

fastcgi\_param SCRIPT\_FILENAME /srv/prod/bin$fastcgi\_script\_name;  
.  
.

The fcgi script is now bind using the unix socket as follows:

# spawn-fcgi -s /tmp/user.socket -a 127.0.0.1 -p 9000 [ -u -g

-U -G ]

This works fine for a given .fcgi script.

If I have 4 such scripts in the cgi-bin directory ( /srv/prod/bin) ,  
should I be doing 4 such independent spawn-fcgi-s . Is there an  
alternative to do the same ?  
Related, these .fcgi mentioned are executables of a C++ program.

Any suggestions for a better installation / best practices here ? Thanks  
!
