From Greg Porter's Wiki
Loading a Wiki Engine
Decide what you need
I know you're a hotshot programmer, with leet PHP or whatever skills. That's nice. Good for you. Resist the temptation to build something from scratch unless you just want to spend hundreds of hours on something that someone else has already done. Spend a few minutes looking to see if something already exists. I bet it does. If it's open source, you can take it and tweak it, add to it, and make it your own.
Pick which one is for you
There's lots of wiki engines out there. There's so many that it's hard to pick. Lucky for you, lots of people have this problem and there's probably some sites that review and compare the various packages. I typed "compare wikis" into Google, and the first hit I got was for WikiMatrix, which promises to "compare them all". It even has a "Wiki Choice Wizard" where you answer a few questions and it picks the right wiki engine for you. (I answered a few questions like "Is Open Source required?" and it came up with a short list of wikis. I decided to go with MediaWiki, the wiki engine that Wikipedia uses. It's a big, beefy, industrial strength, but not so friendly for newbies wiki engine. For sake of example (and because I want to learn it anyway) I picked MediaWiki. You should probably *NOT* pick MediaWiki if you just want a simple lightweight wiki engine.)
Read the instructions
Well regarded popular projects like MediaWiki have documentation. Really. Resist the temptation to just blindly Google for "install MediaWiki". Instead go to the project's web site and READ THE OFFICIAL DOCUMENTATION. If it turns out to be lame and useless, *then* go to Google and wander through thousands of lame hints. In the case of MediaWiki, on the home page is a link to installation. They have a full blown step by step installation guide. These guides can be a bit confusing. A lot of them, like this one, have two basic sections. There's a generic section, that takes you through a generic install on a non-distribution specific platform. It is good to read this quickly, just to see how much pain is involved. The second section has system specific instructions, where hopefully someone has specific instructions for your platform of choice. So for this example, I read the generic instructions, and then the Fedora instructions. Hmm, seems a bit intricate.
Make a backup
BEFORE you install something substantial, make a backup. If you are installing on a vm, make a snapshot. If you are installing on your vhost at your ISP, then back up everything with an rsync command.
# rsync -avh -e ssh email@example.com:/home/porterg/* . firstname.lastname@example.org's password: receiving file list ... done cron_worked logs -> /logs/porterg mbox Mail/ annon-ftp-old/ cgi-bin/ downloads/ downloads/apl.dump downloads/blue_bayou.zip downloads/mediawiki-1.14.0.tar.gz downloads/pivot_1403_full.zip <snip>
Find the pre-requisites. Install them. Make sure they work before you go any further.
So after I read the documentation (yes, I really read the documentation) it appears that the "LAMP" stack (Linux, Apache, MySQL, Perl/PHP/Python) is required. This is common for many projects. Your Linux distribution may have a pre-bundled MediaWiki package already. Imagine that. So a simple 'yum install mediawiki' installs MediaWiki and all the dependencies. I verified this by trying a yum-my install and saw that all LAMP prerequisites were installed. All you have to do after this is the post-configuration (which may prove complicated).
Since I am practicing for installing MediaWiki on my ISP, where I have to install all of this by hand without root access or yum, I will choose the hard road. Yow.
Well, I assume you are using Linux. Okay, the 'L' is done :)
Hmm. Apache. Came stock on my Fedora test box. My ISP vhost has it already as well. Guess I don't have to mess with that much. You should verify the version number, though.
porterg@hickory:~$ apache2 <tab> <tab> apache2 apache2ctl porterg@hickory:~$ apache2ctl -v Server version: Apache/2.2.8 (Ubuntu) Server built: Jun 26 2008 07:04:49
My ISP has helpfully installed MySQL for me. All I had to do is figure out what the database name and password was. The ISP has a web page on using their MySQL with that exact info on it.
porterg@hickory:~$ mysql -u porterg -p porterg Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10328622 Server version: 5.0.51a-3ubuntu5.4 (Ubuntu) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>
Well, so far so good (easy, even). My ISP hooked me up. Let's see what version of PHP is installed.
porterg@hickory:~$ php -v PHP 5.2.4-2ubuntu5.4 with Suhosin-Patch 0.9.6.2 (cli) (built: Nov 25 2008 23:46:54) Copyright (c) 1997-2007 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies with Suhosin v0.9.22, Copyright (c) 2007, by SektionEins GmbH
So the basic components of the LAMP stack appear to be installed on my vhost at my ISP. I'm going to hope that they have properly integrated and configured them for typical 'LAMP-Y' applications. Sometimes getting the LAMP components to play together is harder than getting the components themselves.
Since I'm doing the 'generic' install (not using yum), I have to get the package (in a tarball), and unzip the tarball into a directory under the document root.
The install docs say to use a 'short URL friendly' name like <apache document root>/w, not /wiki. Then they show you how to make an alias of /wiki to /w. They say this is better. I guess I'll go with that.
My apache document root is /home/porterg/public_html.
porterg@hickory:~/public_html$ pwd /home/porterg/public_html porterg@hickory:~/public_html/w$ wget http://download.wikimedia.org/mediawiki/1.14/mediawiki-1.14.0.tar.gz --10:37:31-- http://download.wikimedia.org/mediawiki/1.14/mediawiki-1.14.0.tar.gz => `mediawiki-1.14.0.tar.gz' Resolving download.wikimedia.org... 22.214.171.124, 2620:0:860:2:230:48ff:fe5a:eb1e Connecting to download.wikimedia.org|126.96.36.199|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 10,122,254 (9.7M) [application/octet-stream] 100%[====================================>] 10,122,254 5.83M/s 10:37:33 (5.82 MB/s) - `mediawiki-1.14.0.tar.gz' saved [10122254/10122254] porterg@hickory:~/public_html/w$ tar -xvf *gz mediawiki-1.14.0/ mediawiki-1.14.0/README mediawiki-1.14.0/serialized/ <snip> porterg@hickory:~/public_html/w$ mv mediawiki-1.14.0 w
So now I have the contents of the tarball in /home/porterg/public_html/w. The docs say make the config directory writable by apache.
porterg@hickory:~/public_html/w$ chmod 777 config
This is dangerous. Remember to chmod it back to something sane (755?) after the install.
So assuming that your LAMP stack is functioning, and you have unzipped the tarball into some folder, now you have to configure the package. In the case of MediaWiki, they have made a happy web page for you to use to configure the wiki. Many packages don't do this, you have to manually configure some (many?) text config files.
To configure your shiny new MediaWiki, point your browser at the wiki folder. Click on the link. Wow! This is pretty cool. The happy web page checks to see if the LAMP stack is configured. I see:
* PHP 5.2.4-2ubuntu5.4 installed * Found database drivers for: MySQL * PHP server API is apache2handler; ok, using pretty URLs (index.php/Page_Title) * Have XML / Latin1-UTF-8 conversion support. * Session save path (/var/lib/php5) appears to be valid. * PHP's memory_limit is 128M. * Couldn't find Turck MMCache, eAccelerator, APC or XCache; cannot use these for object caching. * Found GNU diff3: /usr/bin/diff3. * Found ImageMagick: /usr/bin/convert; image thumbnailing will be enabled if you enable uploads. * Found GD graphics library built-in. * Installation directory: /home/porterg/public_html/w * Script URI path: /w * Installing MediaWiki with php file extensions * Environment checked. You can install MediaWiki.
Thanks, he.net! That was easy!
So I can see the config web page, and it seems happy. Now I have to answer some questions about name of the wiki, license, database connection details. Try to leave as many as possible default. You should have the database connection details from your ISP.
Click on the create link. Hey! It says it worked! Now it says:
Installation successful! Move the config/LocalSettings.php file to the parent directory, then follow this link to your wiki. You should change file permissions for LocalSettings.php as required to prevent other users on the server reading passwords and altering configuration data.
Yay! Okay. I moved and tweaked the file like so (also fixed the perms on the config dir):
porterg@hickory:~/public_html/w/config$ ls index.php index.php5 LocalSettings.php porterg@hickory:~/public_html/w/config$ mv LocalSettings.php .. porterg@hickory:~/public_html/w/config$ cd .. porterg@hickory:~/public_html/w$ ls -al LocalSettings.php -rw-rw-rw- 1 porterg users 4297 2009-05-03 11:16 LocalSettings.php porterg@hickory:~/public_html/w$ chmod go-rwx LocalSettings.php porterg@hickory:~/public_html/w$ ls -al LocalSettings.php -rw------- 1 porterg users 4297 2009-05-03 11:16 LocalSettings.php porterg@hickory:~/public_html/w$ ls -ald config/ drwxrwxrwx 2 porterg users 24 2009-05-03 11:21 config/ porterg@hickory:~/public_html/w$ chmod 755 config/ porterg@hickory:~/public_html/w$ ls -ald config/ drwxr-xr-x 2 porterg users 24 2009-05-03 11:21 config/
Hey! They didn't lie. It really does work!
There's a couple of things you should tweak. Find a logo and get rid of the default flower logo. Change the short /w path to the wiki to a better /wiki path with some .htaccess tweaks. "Real" wikis allow anyone to change pages, but you probably don't want that (unless you like Cialis ads). I like to upload pictures to use on pages, this is turned off by default.
Change the Logo
Get a logo. Read the manual. The logo image is supposed to be a standard, required size of 135 x 135 pixels. I think I tried a different size once, and it got stretched and jammed into the default 135x135 and looked really goofy.
In the wiki directory, /w, there's a images folder already made for you. That's a convenient place to use, although not required. You could put it anywhere that the web server can get to.
Then change the LocalSettings.php in the wiki directory and add the path to the logo file. That's it. Mine looks like:
Tweak the Config to allow for a /wiki path
The docs say that a short path like /w is "better". If you want to use /wiki in a browser URL, you have to make changes in 2 places. In the folder above the wiki, the document root, you have to make a file named .htaccess (or tweak the one that's there) and tell apache to rewrite incoming /wiki requests to the real path of /w. You also have to tweak LocalSettings.php. Read the manual. My .htaccess has this rewrite section in it:
RewriteEngine On #Added following lines IAW http://www.mediawiki.org/wiki/Manual:Short_URL/wiki/Page_title_--_no_root_access to convert /w paths to /wiki #glporter, 5 May 09 RewriteRule ^wiki/(.*)$ /w/index.php?title=$1 [PT,L,QSA] RewriteRule ^wiki/*$ /w/index.php [L,QSA]
My LocalSettings.php has this section in it:
#Added following lines IAW http://www.mediawiki.org/wiki/Manual:Short_URL/wiki/Page_title_--_no_root_access to convert /w paths to /wiki #glporter, 5 May 09 $wgScriptPath = "/w"; # Path to the actual files (right part of first rewrite rule). Should already be there $wgArticlePath = "/wiki/$1"; # Virtual path (left part of first rewrite rule). MUST be DIFFERENT from the path above! $wgUsePathInfo = true;
Block Anonymous Users From Changing Pages
"Real" wikis are supposed to allow anyone to make edits or add pages. That's the spirit of a wiki, on the whole a wiki should get better and better if everyone is allowed access. MediaWiki was designed this way. It's actually a bit hard to make MediaWiki stop behaving this way. Read the manual. I tweaked my LocalSettings.php file and made my wiki require that only the admin could make accounts, and that only people with accounts could make pages or edit stuff. My LocalSettings.php file looks like this:
# See http://meta.wikimedia.org/wiki/MediaWiki_FAQ#How_do_I_allow_only_logged-in_users_to_edit.3F # Added 5 May 09, glporter # Only SysOp (Admin) can create accounts - $wgGroupPermissions['*']['createaccount'] = false; #No anonymous editing allowed - $wgGroupPermissions['*']['edit'] = false;
Read the manual. Change the line in LocalSettings.php that looks like
$wgEnableUploads = false;
$wgEnableUploads = true;
I lucked out. My ISP must have figured that lots of customers would want MediaWiki installed, and pre-configured their servers to have all the right stuff, configured correctly. All I had to do is read the docs, make a directory, unzip the tarball into the wiki directory, configure it using the web page based configuration tool, and then tweak it a bit. Your Mileage May Vary.