The Artima Developer Community
Sponsored Link

Web Buzz Forum
MediaWiki Installation: Friendly URLs

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Douglas Clifton

Posts: 861
Nickname: dwclifton
Registered: May, 2005

Douglas Clifton is a freelance Web programmer and writer
MediaWiki Installation: Friendly URLs Posted: Nov 18, 2008 1:31 PM
Reply to this message Reply

This post originated from an RSS feed registered with Web Buzz by Douglas Clifton.
Original Post: MediaWiki Installation: Friendly URLs
Feed Title: blogZero
Feed URL: http://loadaveragezero.com/app/s9y/index.php?/feeds/index.rss1
Feed Description: Web Development News, Culture and Opinion
Latest Web Buzz Posts
Latest Web Buzz Posts by Douglas Clifton
Latest Posts From blogZero

Advertisement

mediawiki wikizero Last week, while researching and evaluating open-source software packages written in PHP, I naturally took the time to install some of them to see how difficult it was and note any problems I might encounter. One of these was of particular interest. MediaWiki is the software that drives Wikipedia and the rest of the projects under the Wikimedia Foundation umbrella.

Goals

Some of the goals I had in mind when I set out on this little project were:

  • Follow best practices.
  • Virtualize the install so PHP scripts and other resources visitors should not have access to are hidden.
  • Friendly URLs—I don't want to see any .php extensions while browsing.
  • Customize the install for my particular needs.

bomb

Root

For security reasons, and the threat of downtime from customers who don't know what they're doing, most hosting companies severely limit what you're capable of doing in a shared environment—and of all things they're not going to give you root access or sudo(8) privileges. Even on a dedicated server this can be a sticky situation. In order to follow the instructions below, at some point you're going to need that capability to, for example, restart you're Web server daemon. If you're running Ubuntu or another Linux distribution, or Mac OS X, on a local development box, you should be all set. You should also be comfortable using a shell and know how to edit text files.

Download

First you need to grab the source code from the MediaWiki Web site. You'll find it on the Downloading MediaWiki page. It comes in a tarball—make sure you get the latest stable version. Also make sure you meet all the requirements before attempting the install. It helps to know which version of PHP and MySQL you're running beforehand.

Upload and unpack

After you download the file, upload it to your Web server into the docroot of your site. At the time I did this the MediaWiki latest stable version was 1.13.2 (released 10-2-2008), and the name of the compressed archive reflects this: mediawiki-1.13.2.tar.gz.

Fire-up your shell client and visit docroot. You can decompress and extract the source in one command:

$ tar xzvf mediawiki-1.13.2.tar.gz
You'll see a whole flurry of activity as the package is creating its source tree and populating the directories with files. You'll be left with a directory, just off docroot, with the same basename as the archive. The first thing I did was rename it to something more manageable:
$ mv mediawiki-1.13.2 w
There's no need for the archive any longer so get rid of it.
$ rm mediawiki-1.13.2.tar.gz
Then change into the w directory.
$ cd w

Configuration

The browser-based installer will want to write out a file called LocalSettings.php in the config directory. To forestall any permission problems make that directory world writable:

$ chmod a+w config

Now point your browser at the directory off docroot you just created: example.com/w/ and follow the instructions to set some basic options and create the database. In a bit you won't access the w folder directly, since we are going to virtualize it and create friendly URLs. Two things to keep in mind: the virtual directory does not really exist in the sense you create it in your filesystem, and (this is important), do not use the same name for both. By MediaWiki convention this virtual directory is called "wiki," which you should be familiar with from browsing around Wikipedia.

When the installation is complete, copy the config file down to the w directory and add a few lines.

$ cp config/LocalSettings.php .
// docroot/w/LocalSettings.php

$wgScriptPath  = '/w';        // real path
$wgArticlePath = '/wiki/$1';  // virtual path
$wgUsePathInfo = true;

These settings, and one more task with your Apache config file, will take care of ever having to access the w path directly, and will give you the nice URLs we're after.

Apache

You're going to need to be root on the box to do at least one of the following steps. Since I have a virtual.conf file for this site there was no need to edit httpd.conf directly. Your mileage may vary. Either way, in the <VirtualHost> container for your site you need to add an Alias to finish this job:

Alias /wiki /real/path/on/your/server/docroot/w/index.php
It's probably a good idea to make sure your config file(s) have no errors, then restart Apache:
$ apachectl configtest
Syntax OK
$ sudo apachectl graceful
Apache gracefully restarted

Then point your browser at: example.com/wiki/ and if everything went well you'll see the MediaWiki "Installed successfully" message on the Main_Page. An even cleaner set-up would be to create a sub-domain of your site, say: wiki.example.com, and install everything in the docroot. But I'm not going to get into that here.

mod_rewrite

There are a number of other solutions out there, many of them involving mod_rewrite. Unless you understand regular expressions and have some experience using mod_rewrite, or enjoy pain of the voodoo variety, I recommend going the Alias route. Why hit a tack with a sledgehammer?

Conclusion

MediaWiki is a large program and it uses lots of system resources. If you're in the market for a simple Wiki and one only you will be using then consider shopping around for something less complicated. I went for Big Daddy for a couple of reasons. One, I wanted to gain the experience of installing it, and two, I wanted to have my own sandbox, so to speak, to better understand the system, and in particular, to improve my skills editing Wiki documents using their markup language. With that said, it was worth the effort.

book Although there is little to see or do, you can visit wikiZero to see the results of a fairly fresh install. Also, if you're really planning on diving into this, and you're a dead-tree fan like me, O'Reilly published MediaWiki just last month. I took a look at it and read some third-party reviews. It's a keeper if you plan on using this software to any great extent.

Read: MediaWiki Installation: Friendly URLs

Topic: How Does an Anti-Virus Software Work? - The Inside Story Previous Topic   Next Topic Topic: I'm Back...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use