[Ubuntu 10.04] Install Nginx + PHP5 packages?

Gilles Ganault gilles.ganault at free.fr
Wed Jul 14 18:12:34 MSD 2010


On Wed, 14 Jul 2010 15:58:59 +0200, Gilles Ganault
<gilles.ganault at free.fr> wrote:
>... but it doesn't work any better (test.php: "No input file
>specified.") :-/

For those looking for the same thing, this article worked:

"PHP FastCGI with nginx on Ubuntu"
http://tomasz.sterna.tv/2009/04/php-fastcgi-with-nginx-on-ubuntu/

====================
# cat /etc/init.d/php-fastcgi

#!/bin/bash
BIND=127.0.0.1:9000
USER=www-data
PHP_FCGI_CHILDREN=15
PHP_FCGI_MAX_REQUESTS=1000

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin
PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0

start() {
      echo -n "Starting PHP FastCGI: "
      start-stop-daemon --quiet --start --background --chuid "$USER"
--exec /usr/bin/env -- $PHP_CGI_ARGS
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}
stop() {
      echo -n "Stopping PHP FastCGI: "
      killall -q -w -u $USER $PHP_CGI
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}

case "$1" in
    start)
      start
  ;;
    stop)
      stop
  ;;
    restart)
      stop
      start
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL
====================

chmod +x /etc/init.d/php-fastcgi
/etc/init.d/php-fastcgi start
update-rc.d php-fastcgi defaults

====================
# cat /etc/nginx/sites-available/default

server {
        listen          80;
        server_name     example.com;

        access_log      /var/log/nginx/access_log;
        error_log       /var/log/nginx/error_log warn;

        root            /var/www/nginx-default;

        index           index.php index.html;
        fastcgi_index   index.php;

        location ~ \.php {
                include /etc/nginx/fastcgi_params;
                keepalive_timeout 0;
                fastcgi_param   SCRIPT_FILENAME
$document_root$fastcgi_script_name;
                fastcgi_pass    127.0.0.1:9000;
        }
}
====================

Put a test PHP script in /var/www/nginx-default/, start Nginx
/etc/init.d/nginx start), and aim your browser.

HTH,




More information about the nginx mailing list