Manual:$wgThumbnailScriptPath

Details
Give a path here to use thumb.php for thumbnail generation on client request, instead of generating them on render and outputting a static URL. This is necessary if some of your apache servers don't have read/write access to the thumbnail path. Example: $wgThumbnailScriptPath = "{$wgScriptPath}/thumb.php";