FastCGIExternalServer demystified

« 1 2 3 4 5 6 7 8 9View All»

Last Fixups

The remaining problem is that PHP has a little issue with translating the path information it gets when running as an FCGI server. This results in

$_SERVER['SCRIPT_NAME']

being set to a wrong value. To fix this, we unfortunately have to patch PHP itself, namely the file

sapi/cgi/cgi_main.c

. There, after line 976, add this:

if (env_redirect_url &&
	strncmp(env_server_software, "Apache", sizeof("Apache")-1) == 0) {
	/*
	 * If we have an env_redirect_url and the web server is Apache
	 * it's very likely that env_redirect_url is the one we really
	 * want
	 */
	env_script_name = env_redirect_url;
}

This will make sure that the superglobal variable is set to the right value when using Apache 2.2 as your FastCGI frontend server. The patch has been tested with PHP 5.2.9 and 5.2.10 but might work with other versions as well.

This entry was posted in PHP, Software, the ugly truth and tagged , , . Bookmark the permalink.

One Response to FastCGIExternalServer demystified

  1. Pingback: External FastCGI With Apache « IT Know-It-All

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>