Ti sei perso il VI Convegno gt? Forse puoi rimediare... www.convegnogt.it X Chiudi

Visualizza un messaggio singolo
Vecchio 25-07-08, 21:11   #4 (permalink)
paolino
Moderatore
 
L'avatar di paolino
 
Data di registrazione: Apr 2005
Ubicazione: San Cipriano Beach
Messaggi: 4,274
allora adesso ti spiego tecnicamente come funziona fastcgi

in primo luogo devi modificare il file di configurazione di nginx per il dominio dove vuoi usare gli script php

ad esempio

Codice:
 location ~ \.php$ {
            fastcgi_pass   127.0.0.1:12384;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /home/www/miosito.com/html$fastcgi_script_name;
            include        conf/fastcgi_params;
        }

questa prima parte dice a nginx che deve inviare i file .php al server in ascolto su localhost alla porta 12384

ovviamente il server č stato precedentemente tramite questo script

Codice:
#!/bin/sh
# /opt/etc/init.d/S79php-fcgi
#
# NSLU2 spawn-fcgi script for lighttpd
#
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/usr/bin/spawn-fcgi"

## ABSOLUTE path to the PHP-FCGI binary
FCGIPROGRAM="/usr/bin/php-cgi"

## ABSOLUTE path and name of PID-file for spawed process
FCGIPID="/var/run/php-fcgi.pid"

## TCP port or  socket to bind to
#FCGISOCKET="/tmp/php-fcgi.sock"
FCGIPORT="12384"
FCGIADDRESS="127.0.0.1"

## number of PHP children to spawn (min 2)
PHP_FCGI_CHILDREN=2

## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=200

##  IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1"

## Allowed environment variables, separated by spaces
ALLOWED_ENV="PATH SHELL USER"

## user and group to run PHP-FCGI
USERID=www
GROUPID=www

################## no config below this line

if [ -z "$1" ] ; then
  case `echo "$0" | /bin/sed 's:^.*/\(.*\):\1:g'` in
    S??*) rc="start" ;;
    K??*) rc="stop" ;;
    *) rc="usage" ;;
  esac
else
  rc="$1"
fi

case "$rc" in
  start)
     echo -n "Starting PHP-FCGI: "
    export PHP_FCGI_MAX_REQUESTS
    export FCGI_WEB_SERVER_ADDRS
    ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS"
    if [ -n "$FCGISOCKET" ]; then
      EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID"
    elif [ -n "$FCGIPORT" ]; then
      EX="$SPAWNFCGI -a $FCGIADDRESS -p $FCGIPORT -f $FCGIPROGRAM -P $FCGIPID -C $PHP_FCGI_CHILDREN -u $USERID"
    else
      echo "- ERROR - socket or port must be specified!"
      exit 0
    fi
    E=
    for i in $ALLOWED_ENV; do
      eval "x=\$$i"
      E="$E $i=$x"
    done
    env - $E $EX
    echo ok
      ;;
  stop)
    if [ -n "`pidof php-fcgi`" ]; then
      echo -n "Stopping PHP-FCGI: "
      killall php-fcgi 2> /dev/null
      echo ok
    fi
      ;;
  restart)
    "$0" stop
    sleep 3
    "$0" start
      ;;
  *)  
    echo "Usage: $0 (start|stop|restart|usage)"
      ;;
esac
noterai che usa il programma /usr/bin/spawn-fcgi che č specifico per archlinux, sicuramente c'č una cosa simile per la tua distribuzione e credo sia /opt/script-cgi

a mio avviso dovresti avviare il demone cosė
Codice:
/opt/script-cgi -a 127.0.0.1 -p 8888 -u nginx -g nginx -f /opt/php/bin/php-cgi
poi modificare il file nginx.conf come ho scritto sopra, riavviare nginx e dovrebbe andare
__________________
paolino non in linea   Rispondi citando