I'm recovering from a severe case of 'NIH'-disease and for me it means that I've turned to tried and tested solutions for my web projects. Here are the notes on the subject of installing latest stable (v1.9.3) MediaWiki engine (the heart of Wikipedia) on my hosting company's PHP 5.2 server.

Installing MediaWiki is pretty straight-forward but not without gotchas.

I went as described in README:

  1. Downloaded mediawiki-1.9.3.tar.gz to the root directory:

    $ curl -o mediawiki-1.9.3.tar.gz http://ovh.dl.sourceforge.net/sourceforge/wikipedia/mediawiki-1.9.3.tar.gz
  2. Unarchived it and renamed the resulting directory to wiki/:

    $ tar zxvf mediawiki-1.9.3.tar.gz
    $ mv mediawiki-1.9.3 wiki/
  3. Changed permissions on the wiki/config/ directory to allow read-write access by PHP scripts:

    $ chmod a+w wiki/config/

    Opened the config page in my browser: http://www.yoursite.here/wiki/config. The script has analyzed its environment and advised to disable PHP's register_globals option:

    Warning: PHP's register_globals option is enabled

    I can't modify php.ini config file directly since my site is on a hosted server, so I went on and added 'php_flag register_globals off' (sans quotes) to the hidden .htaccess file in wiki/ folder:

    $ echo "php_flag register_globals off" >> /path/to/wiki/.htaccess
  4. Hit "Refresh" to make sure that wiki/config/ page has seen the changes I've made and then proceeded to fill the form with my database credentials, user accounts etc.:

Filling the MediaWiki installation form

After I made sure that everything is correct and pressed the "Install MediaWiki" button at the bottom of the page, installation process started and several seconds later I was greeted with a new page asking me to remove the wiki/config/ directory and open the home page of my new Wiki.

I did exactly that but the home page was blank! No title, no content - just empty space. After hitting "Refresh" a couple of times, an error appeared:

Fatal error: Cannot access protected property DatabaseMysql::$mOut in /path/to/wiki/includes/Database.php on line 429

I googled this error and found a mention on MediaWiki's Support Desk page. It suggested a downgrade to PHP v5.1.x - but for me downgrading was not an option because I couldn't do that much with my hosted account and it seemed like a wrong way anyway. I continued my search and found this helpful article on WikiMedia's forum: Wiki became unavailable--interpreting error messages. Aha, broken version of eAccelerator! Now that seems more relevant! I added an option to disable eAccelerator alltogether to the .htaccess file:

          $ echo "php_flag eaccelerator.enable 0" >> wiki/.htaccess


No luck! Still the same error. I created a test file named phpinfo.php:



and then opened it in my browser by going to /wiki/phpinfo.php. Looks like eAccelerator is still active:

Looks like eAccelerator is still active!

One more thing to try - if we can't disable it let's tell eAccelerator to skip PHP files in MediaWiki's includes/ folder by creating a filter (note the single and double quotes!):

          $ echo 'php_flag eaccelerator.filter "*.php !/path/to/wiki/includes/*.php"' >> wiki/.htaccess


Great, this worked! Of course, YMMV and your setup may or may not have the same problems - but here I've documented some useful techniques to make MediaWiki work on an average LAMP server running recent versions of "M" and "P" (MySQL and PHP, that is) in an unfortunate case when it refuses to work out of the box.

In one of my future posts I'll cover installing RSS feed extension and making it work. I'll try to make it general enough to make sense for other MediaWiki extensions as well.