« Life Updates |
Main
| Christian Assassination Politics? »
MediaWiki on Windows/Apache2/PHP, fun problems with it not working
August 22, 2005 ( geek )
Again, at work, and finally wrestled a problem to the ground that has very little online information.
Setup: MediaWiki, Windows platform, Apache2 web, PHP4, MySQL
First, always remember to change your MySQL user password to the old_password schema (also, you must actually change the password when you do this, or it won't update!
mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd')
-> WHERE User = 'some_user';
mysql> FLUSH PRIVILEGES;
Symptoms:
The wiki is installed... and... sometimes... works. index.php gives 500 Errors, and the log reports things like:
File does not exist: C:/www/php/php.exe
or
malformed header from script. Bad header=HTTP/1.1 301 Moved Permanently: php.exe
CTRL-f5 refreshes (clearing the cache_ works, but other refreshes don't. Sometimes a page works, sometimes it don't.
Fixing it...
First, get a Mounds or Almond Joy candybar. If you don't get the joke, you're too young to be worrying about the problem.
Check LocalSettings.php in the wiki's root directory, make sure
$wgScriptPath is set to /wiki and not /php/php.exe or similar.
That helped, but lead to the intermittent-working problems. I found this email exchange as a next step, MediaWiki uses 301 redirects to enable caching of wiki pages (passed in CGI variables, so normally wouldn't client-side cache)
That site suggests:
This isn't a valid solution, but I edited index.php to remove the 301
redirect code, and everything now appears to work properly. Does that spark any ideas?
So, I changed
$wgOut->redirect( $wgTitle->getFullURL(), '301');
to
/* $wgOut->redirect( $wgTitle->getFullURL(), '301'); */
and it made index.php work, but nothing linked from there (for obvious reasons, think about what you just did).
So I returned to Google seeking more information on caching and 301 redirects, and found this mail archive on Mediawiki caching, which gave me the final clue:
If you really need to disable HTTP client caching for some reason (or the internal parser caching), see DefaultSettings.php for the list of all configurable settings that you can set in LocalSettings.php
So, in the wiki's includes directory, open DefaultSettings.php and find
# Client-side caching:
$wgCachePages = true; # Allow client-side caching of pages
And change that to false. Whee!
I do NOT know if this is the wise/correct thing to do, certainly not on a high-bandwidth/usage wiki! However, it works. If anyone finds the real underlying problem, post it as a comment here, or somewhere on the net at least, to spread the love!
Posted by griffjon at August 22, 2005 02:21 PM
Trackback Pings
TrackBack URL for this entry:
http://www.GriffJon.com/journal/MT/mt-trackback.cgi/79
Listed below are links to weblogs that reference MediaWiki on Windows/Apache2/PHP, fun problems with it not working:
» MediaWiki caching, refresh, reload problem from jotsheet
To disable client-side caching in MediaWiki, set $wgCachePages in includes/DefaultSettings.php to "false". [Read More]
Tracked on September 4, 2005 01:52 PM
Comments
from http://www.srcf.ucam.org/faq/cgi.html:
"In detail... the problem comes when your script effectively does:
header("HTTP/1.1 301 Moved Permanently");
(e.g. in line 240 of OutputPage.php).
This is a raw HTTP header. When PHP-running-as-an-Apache-module sees this function call with an argument starting "HTTP", it knows that it doesn't need to add it's own "HTTP" header as it usually would, and sends it on to the browser.
But when invoking any CGI process (including PHP-running-as-a-CGI-program), Apache *always* adds the "HTTP" line itself, and it is simply not part of the CGI specification for the CGI script to do that, unless the CGI script is invoked in "non-parsed header" mode (in which case the CGI script *must* provide the HTTP line itself). [...]
All is not lost, though, since you can achieve exactly the same effect with:
header("Status: 301 Moved Permanantly");"
Posted by: M3ax at September 29, 2005 06:00 PM
Post a comment
Thanks for signing in, . Now you can comment. (sign out)
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)