===== Compilar e instalar cgiwrap para soportar FastCGI en Nginx (CentOS 6.X) ==== **Dependencias para compilar / instalar Fcgiwrap en CentOS 6.x** yum groupinstall 'Development Tools' # Se instala el repositorio EPEL: http://fedoraproject.org/wiki/EPEL/es rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm yum install fcgi-devel **URL Fcgiwrap**: [[http://nginx.localdomain.pl/wiki/FcgiWrap]] wget https://codeload.github.com/gnosek/fcgiwrap/legacy.tar.gz/master -O fcgiwrap.tar.gz tar zxvf fcgiwrap.tar.gz cd gnosek-fcgiwrap-66e7b7d autoreconf -i ./configure make make install yum install spawn-fcgi Editar el fichero /etc/sysconfig/spawn-fcgi. OPTIONS="-u nginx -g nginx -a 127.0.0.1 -p 9001 -P /var/run/spawn-fcgi.pid -- /usr/local/sbin/fcgiwrap" Inicializamos el demonio e indicamos que arranque al inicio. chkconfig spawn-fcgi on service spawn-fcgi start ==== Instalar Nginx en Centos 6.X ==== Agregamos el repositorio creando el fichero ///etc/yum.repos.d/nginx.repo// [nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/centos/6/$basearch/ gpgcheck=0 enabled=1 yum install nginx ==== Configurar host en Nginx para usar FastCGI ==== server { listen 80; server_name pollux.dominio localhost; root /var/www/static/cgi-bin; # access_log /var/www/logs/example.com.access.log; location / { index index.cgi; } location ~ \.pl|cgi|fcgi$ { try_files $uri =404; gzip off; fastcgi_pass 127.0.0.1:9001; fastcgi_index index.cgi; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } } service nginx start chkconfig nginx on NOTA: También se podría haber utilizado el fichero socket en vez del puerto (Mirar ///etc/sysconfig/spawn-fcgi//). Un ejemplo muy simple para probar la activación de FastCGI en Nginx. #!/bin/bash echo "Content-type: text/html" echo "" echo '' echo '' echo '' echo 'Hola mundo' echo '' echo '' echo 'Hola mundo' echo '' echo '' exit 0 Dada esta configuración, los ficheros CGI (Python, Perl, C,...) deben tener extensión //.cgi// y estar en ///var/www/static/cgi-bin//. Leer la web oficial para más información. **Ejemplo de URL**: http://dominio/script.cgi