GriffJon.com Blog

« 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.)


Remember me?



Stylin'

Normal (Bloggish)
Default
Fire (FireFox Showcase)
GriffJon.com (Pages past)
GriffJon.com (Tribute to Dragon Warrior)
Printer-Friendly High-contrast

Calendar

October 2006
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

Contact Me

email: (my name)  (`at')   G r i f f  J o n (`.dot')c o m
PGPPGP Key
efax:1.925.666.3613
IM
ICQ:16386214
Y!

MSN

AIM

GriffJon

Web
/.#14945
LJ:LiveJournal
Flikr:Photos

Disclaimer

My personal opinions do not necesarily reflect on my employers, schools, any government, U n i t e d   S t a t e s   P e a c e   C o r p s, my friends, or my family.

They may not even reflect my current opinions

Furthermore, these opinions do not unfairly influence any official decisions I make in my academic or professional work.

If you wish permission to reprint or reuse anything within these pages, I require that you contact me for permission. I'll likely give it to you, and probably even a link back.

Software, scripts, and configuration files downloaded from this website come with NO WARRANTY express or implied, and are for use AT YOUR OWN RISK. They are available under the GPL unless otherwise noted.