Wednesday, February 18, 2009

CGI Error-The specified CGI application misbehaved by not returning a complete set of HTTP headers

The "CGI Header" error typically this happens more on a faster machine (it has to do with timing of IIS/PHP and database connections). Logging out of the PureCMS system might result in IIS responding with a CGI Error. Refreshing the client browser (press the F5 key) typically results in the login page correctly appearing. If this error happens regularly, try configuring your web server to be optimized for Programs (not Background Services). These options can be found in the System control panel under Performance Options.

There is another option if optimizing your Web server for Programs does not solve the problem. There is a free utility called "FastCGI" that is a generic "plug in" for IIS that helps to execute CGI applications (PHP, Perl, etc.) faster by pooling those processes rather than making IIS launch them for every request. This has been shown to work well with PureCMS to avoid the "CGI Header Error" issues mentioned above.

Setting Up FastCGI on IIS for PureCMS

Download http://www.caraveo.com/fastcgi/fastcgi-0.6.zip and unpack isapi_fcgi.dll.
Place the "isapi_fcgi.dll" file into the "App\PHP" subfolder of your PureCMS installation directory, e.g. "D:\PureCMS\App\PHP" (the same directory as php.e-x-e)
Copy and paste the following text (between the "----" lines) into a text editor (such as Notepad). Modify the file path for PHP appropriately (point it to your installation folder for PureCMS), and save the file with a ".reg" extension. Then double-click that file and click "Yes" to merge this information into your registry. Make sure that the file names are in 8.3 format. For example, instead of "c:\program files\globalscape\purecms" use "c:\progra~1\global~1\purecms".
------------------- fastcgi.reg -------------------------
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\FASTCGI]
"StartServers"=dword:00000005
"IncrementServers"=dword:00000002
"MaxServers"=dword:00000019
"Timeout"=dword:00000258

[HKEY_LOCAL_MACHINE\SOFTWARE\FASTCGI\.php]
"AppPath"="D:\\PureCMS\\app\\php\\php.exe"
"BindPath"="php-fcgi"
---------------------------------------------------------

Change script mappings for .PHP to point to D:\PureCMS\app\php\isapi_fcgi.dll instead of PHP.exe. This is done in the IIS manager: right-click on the PureCMS site and choose "Properties." Change to the "Home Directory" tab and click the "Configuration" button in the bottom right. Go to the "App Mappings" tab. Find the ".php" extension in the "Application Mappings" list, click it and choose "Edit." For the Executable entry, "Browse" and find the isapi_fcgi.dll location and choose that.
If you are configuring IIS on a Win2K3 machine, you must also take the extra step of adding it as an allowed ISAPI extension. (see IIS help file for more details, or ask us to help!)
If you are not running on Win2K3, you should toggle Application protection from "High" to Medium" to "High" due to some weird IIS issue. To do so, right-click on your PureCMS site in IIS manager and choose Properties. In the "Home Directory" tab, change the "Application Protection" list to "Medium" and press APPLY. Then change it back to "High" and press Apply again. If you are curious about why this is necessary, read here: http://www.ensim.com/support/wwp/documents/wwp_pro_3.2_docs/wwp32_applHelp/WebHelp/Sites-related.htm
Copy PHP.INI from d:\PureCMS\Main\ into d:\PureCMS\App\php\php.ini (this is a very important step!!!)
8) For FastCGI to work properly, you will need to use PHP 4.3.4; PureCMS ships with PHP 4.3.3.
Download PHP 4.3.4 here, and unzip the following files into your PureCMS PHP folder (e.g. c:\program files\globalscape\purecms\app\php\) -- overwrite whatever files are already there: php.exe, php_ts.dll, and mssql.dll
Restarted the web server. To do so, open a command prompt window and type "iisreset".
Access PureCMS from a browser. Installing FastCGI should eliminate the "This application has misbehaved" errors.
Reference: http://help.globalscape.com/help/purecms3/Error_Message__CGI_Error-The_specified_CGI_application_misbehaved_by_not_returning_a_complete_set_of_HTTP_headers.htm

Regards,
Vijay Modi

No comments:

Post a Comment