MediaWiki on Debian/PostgreSQL

From Alteeve Wiki
Jump to navigation Jump to search

 AN!Wiki :: MediaWiki on Debian/PostgreSQL

How to install MediaWiki on a Debian Sarge server using PostgreSQL 8.x

A few assumptions:

  • Your website exists in '/var/www/<FQDN>/' with the four subdirectories:
    • html/ (Document Root, aka 'html')
    • cgi-bin/ (CGI scripts, aka 'cgi-bin')
    • logs/ (log files, aka 'logs')
    • temp/ (working directory, aka 'temp')

This also assumes that you've got PostgreSQL set to require a password for the DB owner (by setting 'md5' in 'pg_hba.conf' for the user name. In this doc the owning DB user will be 'digimer'.

All steps are showing from the command line shell and

Download

Download the latest version from here.

It may be easiest to right->click on the link, go to the terminal, switch into the 'temp' directory and type:

wget http://download.wikimedia.org/mediawiki/1.16/mediawiki-1.16.0.tar.gz

Replace the URL with the latest one available from the above link. This is a good time to mention that this How-To was written for MediaWiki 1.16.0 so if your version is different some steps may vary.

To extract, while still in 'temp', simply type:

tar -xvzf mediawiki-1.16.0.tar.gz

Last, change the ownership of the extracted files to 'www-data:www-data' (or the user:group of your choice). You will need root access to do this.

chown www-data:www-data . -R

Install

You will need to create a database, move the files into place and then setup the config file.

Create The DB

As the 'postgres' user or as the user that will own the database run:

sudo su postgres -c "createdb tb_wiki -O digimer"

Replace 'tb_wiki' with the name of you wiki and 'digimer' with the name of the user you created to own the DB.

Now add the language 'plpgsql' to the DB. This will need to be run as 'postgres' or a DB user with admin access:

sudo su postgres -c "createlang plpgsql tb_wiki"

Again, replace 'tb_wiki' with the name of your DB.

Install tsearch2

Only follow this section if you are using PostgreSQL older than 8.3.x. Newer versions have tsearch2 standard.

Locate 'tsearch2.sql' and load it into the database. It should be in '/usr/share/postgresql/8.1/contrib/tsearch2.sql', replacing '8.1' with the version of PostgreSQL on your server. The second through last steps must be run as 'postgres'. They load 'tsearch' and give the owning user appropriate access.

locate tsearch2.sql | grep postgresql
su postgres
psql tb_wiki < /usr/share/postgresql/8.1/contrib/tsearch2.sql
psql -d tb_wiki -c "grant select on pg_ts_cfg to digimer;"
psql -d tb_wiki -c "grant select on pg_ts_cfgmap to digimer;"
psql -d tb_wiki -c "grant select on pg_ts_dict to digimer;"
psql -d tb_wiki -c "grant select on pg_ts_parser to digimer;"
psql -d tb_wiki -c "update pg_ts_cfg set locale = current_setting('lc_collate') where ts_name = 'default' and prs_name='default';"
exit

Again, replace 'tb_wiki' and 'digimer' with your DB's name and user as needed. Note that in the official docs on the MediaWiki page, the tables 'pg_ts_cfg' and 'pg_ts_cfgmap' are called 'pg_ts_config' and 'pg_ts_config_map' respectively.

Done!

Moving Files

The files were extracted under the 'temp' directory. Now copy them to the 'html' directory. I like to copy rather than move in case I screw up and want to start over. You may need to do this as root or as the user set with proper permissions on the '/var/www/<FQDN>/temp/' directory.

cd /var/www/<FQDN>/temp/
cp -Rvp temp/mediawiki-1.16.0/* html/
cd html/

You should now see the MediaWiki files in the 'html' directory. Double check that they have proper ownership.

To see if things are working so far, go to your website and you should see:

Note: Screen caps are from mediawiki 1.13.2

MW First Screen
  • The above steps were largely taken from the MediaWiki Install steps.

Configuring MediaWiki

While still looking at the page above, click on the set up the wiki link. You should see a page similar to the one on the right side of this page:

File:Mw config.png
MediaWiki configuration page

Be sure to switch to 'PostgreSQL' for the database and to set the database name, user name and password as you set earlier. As for which license you use, what you call your wiki and so on is up to you.

If you do not see 'PostgreSQL' as an option under 'Found database drivers for:', be sure that 'php5-pgsql' installed. If you just installed it, you will need to restart apache2 before the install scipt will see that the database driver exists.

If everything went well you should see this after proceeding:

File:Mw post config.png
MediaWiki post-configuration page
  • The above steps were largely taken from the MediaWiki Config steps.

Starting The Wiki

Before you can log into the wiki for the first time, you need to move the configuration file into place. Go back to your 'html' directory, copy 'config/LocalSettings.php' to the 'html' directory and change it's permissions to prevent global read access as your passwords are in it. Double check that the webserver user has read access to the LocalSettings.php file.

cd /var/www/<FQDN>/html/
cp -p config/LocalSettings.php .
chown www-data:www-data LocalSettings.php
chmod 770 LocalSettings.php

Now go back to the post configuration page and follow the this link link at the bottom of the page.

That's it!

You should now be looking at your shiny new wiki! Be sure to login for the first time using the name and password you set above.

Further Config

Here are steps for various methods of further configuring your wiki.

Restrict Edit to Registered Users Only

To setup your wiki to allow only logged in users edit LocalSettings.php and add this:

 # Logo.
 $wgLogo="/an-tools_logo.png";
 
 # Restrict edit access to logged in users only.
 $wgGroupPermissions['*']['edit'] = false;
 
 # Geshi extension
 require_once("$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");
 
 # Send's an email on any page edit.
 $wgEnotifWatchlist = true;
 
 # Declare this twice so it works for all versions
 $wgUsersNotifiedOnAllChanges =
 $wgUsersNotifedOnAllChanges = array( 'Digimer' );
 
 # Enable more upload types.
 # odp = Open Document Presentation
 # ods = Open Document Spreadsheet
 # odt = Open Document Text
 # pdf = Portable Document Format
 $wgFileExtensions = array_merge($wgFileExtensions, array('odp', 'ods', 'odt', 'pdf'));

 

Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.