{"id":682,"date":"2007-12-12T02:53:46","date_gmt":"2007-12-12T07:53:46","guid":{"rendered":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki"},"modified":"2007-12-12T02:53:51","modified_gmt":"2007-12-12T07:53:51","slug":"adventures-with-apaches-rewrite-engine-and-mediawiki","status":"publish","type":"post","link":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki","title":{"rendered":"Adventures with Apache&#8217;s Rewrite Engine (and MediaWiki)"},"content":{"rendered":"<p>We&#8217;ve migrated some services from a machine, to another. The architecture of these machines, and directory structures are completely different. So I&#8217;ve played Joe Random Sysadmin.<\/p>\n<p>MediaWiki is completely configured from LocalSettings.php<em><\/em>. It does not have any configuration data stored in the database, so editing the LocalSettings.php file is really all you need to do. One document you want to read, in case the LocalSettings.php configuration is not hard-wired in your brain is the documentation on <a href=\"http:\/\/www.mediawiki.org\/wiki\/LocalSettings.php\">LocalSettings.php<\/a>. Items you would likely need to change:<\/p>\n<ul>\n<li>$IP &#8211; where on disk, MediaWiki is installed<\/li>\n<li>$wgScriptPath &#8211; a lot of things depend on this, and if you&#8217;re making a change in Apache, I seriously suggest paying attention to this one. I have installed MediaWiki into a directory such that its called w\/. There&#8217;s a RewriteRule for this, so $wgScriptPath is now set to \/w.<\/li>\n<li>$wgUploadDirectory &#8211; wherever this is, make sure its writeable by the web-server (let the directory be owned by www-data on a Debian system, for instance).<\/li>\n<\/ul>\n<p>Everything else is pretty kosher, you don&#8217;t actually need to change much more than that. I found that using <a href=\"http:\/\/www.mediawiki.org\/wiki\/Manual:$wgCacheEpoch\">$wgCacheEpoch<\/a> was really very handy, when actually testing MediaWiki. $wgCacheEpoch=&#8221;date +%Y%m%d%H%M%S&#8221;; (well, get that value from your shell, trivial to do in vim).<\/p>\n<p>Now, on to Apache. Make sure the RewriteEngine is on (read more about <a href=\"http:\/\/httpd.apache.org\/docs\/2.2\/mod\/mod_rewrite.html\">mod_rewrite<\/a>). The rewrite rule that I have in the configuration is:<br \/>&nbsp;&nbsp;&nbsp; RewriteRule ^\/wiki(\/(.*))? \/w\/index.php$1<\/p>\n<p>That basically ensures we get rid of the ugly index.php in MediaWiki URLs and we get sensible domain.name.com\/wiki\/PageTitle. When faced with problems, ensure you&#8217;re getting the RewriteLog. This is done via:<br \/>&nbsp;&nbsp;&nbsp; RewriteLog \/var\/log\/apache2\/rewrite.log<br \/>&nbsp;&nbsp;&nbsp; RewriteLogLevel 3<\/p>\n<p>Now, to debug, get intimate with rewrite.log.<\/p>\n<p>(2) init rewrite engine with requested uri \/wiki\/Contributing<br \/>(3) applying pattern &#8216;^\/wiki(\/(.*))?&#8217; to uri &#8216;\/wiki\/Contributing&#8217;<br \/>(2) rewrite &#8216;\/wiki\/Contributing&#8217; -&gt; &#8216;\/w\/index.php?\/Contributing&#8217;<br \/>(3) split uri=\/w\/index.php?\/Contributing -&gt; uri=\/w\/index.php, args=\/Contributing<br \/>(2) local path result: \/w\/index.php<br \/>(2) prefixed with document_root to \/data0\/forge\/work\/w\/index.php<br \/>(1) go-ahead with \/data0\/forge\/work\/w\/index.php [OK]<br \/>(2) init rewrite engine with requested uri \/data0\/forge\/work\/w\/skins\/monobook\/main.css<br \/>(3) applying pattern &#8216;^\/wiki(\/(.*))?&#8217; to uri &#8216;\/data0\/forge\/work\/w\/skins\/monobook\/main.css&#8217;<\/p>\n<p>My real problem was there, where document_root was getting a prefix to the actual path. Which as we all know, is easily fixable in LocalSettings.php. And voila! that&#8217;s your Apache+MediaWiki <i>issue<\/i> solved. Now, everything just loads.<\/p>\n<p>Another useful debugging tool, besides the access and error logs, is also the Firefox Page Information (Ctrl+I). You can also see what&#8217;s being loaded, and how.<\/p>\n<p>Incidentally, I hopped on to #apache on freenode, only to see many a question being asked about mod_rewrite. I think there&#8217;s clearly a big opportunity here, business wise, for good sys-admins. Master Apache.<\/p>\n<p>Technorati Tags: <a class=\"performancingtags\" href=\"http:\/\/technorati.com\/tag\/apache\" rel=\"tag\">apache<\/a>, <a class=\"performancingtags\" href=\"http:\/\/technorati.com\/tag\/mediawiki\" rel=\"tag\">mediawiki<\/a>, <a class=\"performancingtags\" href=\"http:\/\/technorati.com\/tag\/mod_rewrite\" rel=\"tag\">mod_rewrite<\/a>, <a class=\"performancingtags\" href=\"http:\/\/technorati.com\/tag\/rewritelog\" rel=\"tag\">rewritelog<\/a>, <a class=\"performancingtags\" href=\"http:\/\/technorati.com\/tag\/localsettings.php\" rel=\"tag\">localsettings.php<\/a><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20Adventures%20with%20Apache%27s%20Rewrite%20Engine%20%28and%20MediaWiki%29&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2007%2F12%2F12%2Fadventures-with-apaches-rewrite-engine-and-mediawiki&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"68a7055de8\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-682\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-682\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-682\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>We&#8217;ve migrated some services from a machine, to another. The architecture of these machines, and directory structures are completely different. So I&#8217;ve played Joe Random Sysadmin. MediaWiki is completely configured from LocalSettings.php. It does not have any configuration data stored in the database, so editing the LocalSettings.php file is really all you need to do. [&hellip;]<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20Adventures%20with%20Apache%27s%20Rewrite%20Engine%20%28and%20MediaWiki%29&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2007%2F12%2F12%2Fadventures-with-apaches-rewrite-engine-and-mediawiki&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"68a7055de8\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-682\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-682\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-682\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/12\/adventures-with-apaches-rewrite-engine-and-mediawiki?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[1],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4vJD-b0","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":661,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/11\/14\/openofficeorg-23-exports-to-mediawiki","url_meta":{"origin":682,"position":0},"title":"OpenOffice.org 2.3 exports to MediaWiki","date":"14\/11\/2007","format":false,"excerpt":"One interesting feature of OpenOffice.org 2.3 is its Export to MediaWiki functionality. Its simply, a File -> Export, give it a filename, and select MediaWiki. Automatically, you have a .txt file, that you can paste directly into MediaWiki. There, an offline editor for MediaWiki! Sadly, this isn't as well integrated\u2026","rel":"","context":"In &quot;General&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1760,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2010\/05\/09\/wikipedia-available-in-print-via-pediapress","url_meta":{"origin":682,"position":1},"title":"Wikipedia available in print via PediaPress","date":"9\/5\/2010","format":false,"excerpt":"Over a year ago, I found out about Wikitravel Press from Jani Patokallio, at BarCampKL 2009. I was pretty excited since it was based on the open content Wikitravel, it was printed on demand, and it was updated on a regular basis. Imagine getting accurate travel guides when you were\u2026","rel":"","context":"In &quot;General&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1553,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2009\/06\/29\/the-fracas","url_meta":{"origin":682,"position":2},"title":"The fracas","date":"29\/6\/2009","format":false,"excerpt":"Dear Nasrul, I've watched the vitriol on osdcmy-list, I've seen the attacks on Facebook, and on Twitter and I've read all the comments on the Open Malaysia blog, and I think its time I chime in. Firstly, I need to ask: do you know much about open source? I would\u2026","rel":"","context":"In &quot;General&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":505,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/04\/02\/forge-gets-an-update-summer-of-code-progressing-well","url_meta":{"origin":682,"position":3},"title":"Forge gets an update, Summer of Code progressing well","date":"2\/4\/2007","format":false,"excerpt":"MySQL Forge has been recently worked on. The Wiki got updated, there are some new extensions sitting around, and its \"secure\" as MediaWiki can get. The Forge itself has a nice little MySQL Conference & Expo banner, kudos to Lenz. Incidentally, register now, already. MediaWiki doesn't have great banner support,\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":417,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2006\/07\/24\/forge-wiki","url_meta":{"origin":682,"position":4},"title":"Forge wiki","date":"24\/7\/2006","format":false,"excerpt":"Just a quick note to say that the MySQL Forge Wiki looks like the rest of the Forge, and there's now SpamBlacklist installed. If spam still persists (you know you're popular when spam's abound, right?), we might have to install captchas. From an accessibility perspective, I don't quite like this\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":476,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/02\/24\/sysadmin-adventures","url_meta":{"origin":682,"position":5},"title":"Sysadmin adventures","date":"24\/2\/2007","format":false,"excerpt":"Well, its been a while since I dirtied my hands in the sysadmin forays. I was wondering why my system was not accepting mail for a domain that clearly pointed to it. Running host just pointed to the mailserver correctly, but when I ran it on the mailserver, there was\u2026","rel":"","context":"In &quot;General&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"amp_enabled":true,"_links":{"self":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/682"}],"collection":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/comments?post=682"}],"version-history":[{"count":0,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/682\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/media?parent=682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/categories?post=682"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/tags?post=682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}