Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

103,706 Posts in 18,327 Topics- by 8,526 Members - Latest Member: CocoChanels

July 04, 2009, 01:54:46 AM
CrystalTech ForumsProgramming/DesignPHP ForumWordPress, Fast-CGI, Incomplete headers. We solved it.
Pages: [1]   Go Down
Print
Author Topic: WordPress, Fast-CGI, Incomplete headers. We solved it.  (Read 6174 times)
IanLindsay [CT]
Newbie
*

Karma: +5/-3
Offline Offline

Posts: 12


OS:
Windows XP
Browser:
Firefox 2.0.0.11


« on: January 15, 2008, 05:08:59 AM »

Greetings, forum. I've worked at CrystalTech for more than a year, and I am making my first post.

There has been a good deal of frustration from WordPress users regarding this error message when using WordPress:
"The application misbehaved by not returning a complete set of HTTP headers."
Alternately known as an HTTP-500 error.


Sol (in server operations) found out exactly what was wrong and why. It turns out that I encountered this problem in different dress last year, so he asked me to do the write up.

Recent versions of WordPress were having problems that can be traced back to wp-db.php. The generic error message caused people on various forums to point the finger variously at fast-cgi/IIS, PHP4, WordPress, and even MySQL. The answer lies on line 163 of wp-db.php, where we see...

error_log($error_str, 0);

It isn't WordPress. Their application is fine, and only fails in this manner in IIS because of the permissions set to the log file that the error_log function writes to. That log file is determined in PHP.ini and php.exe doesn't have write-access to it.

I have reposted my response to a ticket regarding PHP formmail. The offending line in formmail was 556, and was the exact same function call. The solution is also the same.



The server is fine. The problem is a permissions/configuration related one.
The function call that I removed writes a message to whatever destination type is specified in the second argument of error_log(). See this page for details....
http://www.php.net/manual/en/function.error-log.php


To see where this error gets sent, you need to run this simple PHP script on your domain:
<?php  echo(phpinfo());  ?>

Doing so will display all the PHP settings.

Then search the page for "error_log".
...we can see that these messages will be directed to php_error.php (throws a 500 error).

What you are seeing is normal behavior.

If you decide you want the logs you should change the error_log() call's second argument to something other than zero. Again, referring to the php.net article on this function...

"2" is not an option, as PHP is built for a production environment. It shouldn't work.

"3" is certainly an option, but you will need to set proper permissions to a log file. Also make sure that the logs don't eat all your free-space.

"1" is also a good option if you already have a script setup to send mail from PHP. See the script in the Knowledge Base for a free script for this purpose.

If you are the self-teaching type, you might also find something more creative to do with the message. I might choose to insert the message into a DB. That way I could filter out the webserver's IP and time-date stamp it. Thereby giving you ONLY the hits to the script that DON'T come from the webserver.

Recapping...
Your server is fine.
If you want logging, you now have all the info you need to enable it.
If you don't want logging, your script will work fine by commenting out line 163 in wp-db.php.


Hit me up with questions.

« Last Edit: March 17, 2008, 01:18:16 AM by IanLindsay [CT] » Logged
Jason
Newbie
*

Karma: +6/-1
Offline Offline

Posts: 86

OS:
Windows XP
Browser:
Microsoft Internet Explorer 7.0


WWW
« Reply #1 on: January 16, 2008, 06:07:09 PM »

Excellent. Commenting out line 163 worked perfectly!!! Thanks.
Logged
ScruffyTeg
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 1

OS:
Windows XP
Browser:
Firefox 2.0.0.11


« Reply #2 on: January 24, 2008, 10:24:30 AM »

Hi Ian,

Nice post. Wish I had found your post before tracing my way through to a similar conclusion  Smiley  See http://wordpress.org/support/topic/149680 (502 Bad Gateway when installing WordPress)

Perhaps not exactly the same symptoms, but definitely the same root cause.
With my purist's hat on, editing the source of an application implies something is very wrong, but it's difficult to know where to point the finger of blame: Php+IIS, or WordPress? For example:
  • Should Php bomb out so dramatically if it can't write to error_log
  • Should WordPress even call error_log if there isn't a real error. (in the install case WordPress can't find the db tables as it hasn't created them yet!

Not being very familiar with php, it's difficult for me to say...

Thoughts?

Rich.
Logged
schauvin
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 2

OS:
Windows XP
Browser:
Firefox 2.0.0.12


« Reply #3 on: March 04, 2008, 09:54:34 AM »

Hi:

We have a similar problem tried your solution and did not work.

Last week we noticed that some random post, the colabora (a plug-in)
and the archive page could not be reached and the following error
message appeared:

"The specified CGI application misbehaved by not returning a complete set
of HTTP headers."

It was strange because we had not made any change to our files or blog configuration and when we run the blog in our computer server it works properly.

The only solution we found so far was to change the permanent link from this:
http://www.mydomain.com/blog/index.php/brainstore-una-fabrica-de-ideas/

to this:

http://www.mydomain.com/blog/?p=318

But in doing this we lost almost 500 backlinks!

Any help that let us restore the original permanent links is much appreciated.


Thanks

Silvia
Logged
Georges S. [CT]
CrystalTech
*****

Karma: +11/-0
Offline Offline

Posts: 57


OS:
Windows XP
Browser:
Firefox 2.0.0.12


WWW
« Reply #4 on: March 24, 2008, 07:46:08 PM »

I have found that the dir /blog/ seems to cause this error a lot. the fix I usually implement is to move the WP files to another directory (like /blog/1/). I am not that familiar with Wordpress so I don't know if there is any configuration changes that need to be made to move an existing WP site to another directory. I have only done this for problems during install.
Logged

Georges Sicot
Technical Support 
CrystalTech Web Hosting, Inc.
Toll Free: 1-877-323-4678
Phone: 602-263-0300 Opt. #4
Sol P [CT]
Sol of SOD
Administrator
*****

Karma: +13/-1
Offline Offline

Posts: 57


OS:
Windows Vista
Browser:
Firefox 3.0.3


« Reply #5 on: November 05, 2008, 04:04:30 PM »

You might see this error come up with the latest 2.6.3 release of wordpress on a fresh install right after the install.php loads up and you type in the db info (maybe a step or two later).
Instead of a incomplete headers error, it might show up as a fastcgi access violation.

ex:
-----
FastCGI Error
The FastCGI Handler was unable to process the request.

Error Details:

* The FastCGI process exited unexpectedly
* Error Number: -1073741819 (0xc0000005).
* Error Description: Unknown Error
-----

Seems to be the same thing we've seen from time to time. Most might get a different error since we swapped over to fastCGI - figured i'd update this post just in case someone gets confused (probably won't).

Easiest solution that's worked 90% of the time: go to a previous version - install off that, then upgrade to latest Should create the tables w/o a problem. 2.6.0 seems to work this time around.

A upgrade shouldn't see this problem, if it does recopy the wp-admin / wp-includes.

SOD | Sol
Logged
rbolesta
Newbie
*

Karma: +0/-0
Offline Offline

Posts: 3

OS:
Mac OS X
Browser:
Firefox 3.0.4


« Reply #6 on: January 02, 2009, 11:47:07 AM »

Just installed 2.7 without having to change anything except for whats normally involved in wp setup.
Logged
Pages: [1]   Go Up
Print
Jump to: