вторник, 1 октября 2013 г.

NGINX + FastCGI Perl on Gentoo

Adding to make.conf modules required for nginx and cgi wrapper

NGINX_MODULES_HTTP="access auth_basic autoindex charset fastcgi gzip gzip_static limit_req map proxy rewrite scgi ssi stub_status"
NGINX_MODULES_MAIL=""

Emerging nginx
emerge -av nginx www-misc/fcgiwrap www-servers/spawn-fcgi

  • www-misc/fcgiwrap, a FastCGI server for wrapping CGI scripts
  • www-servers/spawn-fcgi, a FastCGI manager for spawning fcgiwrap.
Make any adjustments you like to /etc/nginx/mime.types. I added:
types {
    …
    application/x-python                  py;
    application/x-shell                   sh;
    …
}
 
Configure spawn-fcgi to launch fcgiwrap with:
# cp /etc/conf.d/spawn-fcgi /etc/conf.d/spawn-fcgi.fcgiwrap
# emacs /etc/conf.d/spawn-fcgi.fcgiwrap
# cat /etc/conf.d/spawn-fcgi.fcgiwrap
FCGI_SOCKET=/var/run/fcgiwrap.sock
FCGI_ADDRESS=
FCGI_PORT=
FCGI_PROGRAM=/usr/sbin/fcgiwrap
FCGI_USER=nginx
FCGI_GROUP=nginx
FCGI_EXTRA_OPTIONS="-M 0700"
ALLOWED_ENV="PATH HOME"
HOME=/
FCGI_CHILDREN=1
FCGI_CHROOT=
# cd /etc/init.d/
# ln -s spawn-fcgi spawn-fcgi.fcgiwrap
 
Start fcgiwrap with:
# /etc/init.d/spawn-fcgi.fcgiwrap start
 
Add it to the default runlevel with:
# rc-update add spawn-fcgi.fcgiwrap default
 
NGINX configuration:
server {
...
location / {
    include fastcgi_params;
    fastcgi_pass  unix:/var/run/fcgiwrap.sock-1;
  }
...
}
 
Should work now!