How can I run Perl scripts using FastCGI on Nginx? How can I run Perl scripts using FastCGI on Nginx? nginx nginx

How can I run Perl scripts using FastCGI on Nginx?


The webserver needs a Unix domain socket to connect to the FastCGI application, but the socket can't be created. Most likely the directory you want it to be in doesn't exist (because they are automatically created when you do a bind).


Leon is exactly correct. There are two prerequisites for allowing the socket to listen:

  1. Make sure the socket directory exists.
  2. This is defined in the fastcgi-wrapper.pl script as /var/run/nginx/perl_cgi-dispatch.sock. Therefore, you will need to make sure /var/run/nginx exists.
  3. Make sure the socket directory is owned by the same user that the fastcgi-wrapper.pl is being executed as.


I'm gonna try and "water down" fastcgi-wrapper.pl, so it can be used with spawn-fcgi.

I use two of those sockets allready:

spawn-fcgi -C 3 -u www-data -s /var/run/php-fcgi.sock -P /var/run/php-fcgi.pid -- /usr/bin/php5-cgispawn-fcgi -F 3 -u www-data -s /var/run/lua-fcgi.sock -P /var/run/lua-fcgi.pid -- /usr/bin/wsapi.fcgi

Inside /var/run I have:

-rw-r--r-- 1 root     root     14 2010-08-07 12:14 /var/run/lua-fcgi.pidsrwxr-xr-x 1 www-data www-data  0 2010-08-07 12:14 /var/run/lua-fcgi.sock=-rw-r--r-- 1 root     root      4 2010-08-07 12:14 /var/run/php-fcgi.pidsrwxr-xr-x 1 www-data www-data  0 2010-08-07 12:14 /var/run/php-fcgi.sock=

I can easily start and stop the FastCGI wrappers, and I want to do that with Perl too.

If anyone has already a script, that works with spawn-fcgi, I'd be happt to use that, or at least have a look at it.

Cheers,--polemon