php exits with 502 Bad Gateway

mfouwaaz nginx-forum at nginx.us
Sun Feb 19 19:05:02 UTC 2012


Sorry for missing that conf. portion.

....the fastcgi_params file

fastcgi_param	QUERY_STRING		$query_string;
fastcgi_param	REQUEST_METHOD		$request_method;
fastcgi_param	CONTENT_TYPE		$content_type;
fastcgi_param	CONTENT_LENGTH		$content_length;

fastcgi_param	SCRIPT_FILENAME		$request_filename;
fastcgi_param	SCRIPT_NAME		$fastcgi_script_name;
fastcgi_param	REQUEST_URI		$request_uri;
fastcgi_param	DOCUMENT_URI		$document_uri;
fastcgi_param	DOCUMENT_ROOT		$document_root;
fastcgi_param	SERVER_PROTOCOL		$server_protocol;

fastcgi_param	GATEWAY_INTERFACE	CGI/1.1;
fastcgi_param	SERVER_SOFTWARE		nginx;

fastcgi_param	REMOTE_ADDR		$remote_addr;
fastcgi_param	REMOTE_PORT		$remote_port;
fastcgi_param	SERVER_ADDR		$server_addr;
fastcgi_param	SERVER_PORT		$server_port;
fastcgi_param	SERVER_NAME		$server_name;

#fastcgi_param	HTTPS			$server_https;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param	REDIRECT_STATUS		200;



... and the entire php-fcgi file

#!/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="- USR=$USER PATH=/usr/bin
PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0
PHP_CONFIG_FILE=/etc/php5/cgi/php.ini

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


Thanks for your help!
Fouwaaz

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,222625,222675#msg-222675



More information about the nginx mailing list