User:Alvaro Ortiz-Troncoso/Draft Create a new mediawiki instance

From Biowikifarm Metawiki
< User:Alvaro Ortiz-Troncoso
Revision as of 15:08, 28 January 2015 by Alvaro Ortiz-Troncoso (Talk | contribs) (Create local directories)

Jump to: navigation, search

As more wikis are needed it would be nice to have a scriptable method to create new wiki instances. This page documents creating a wiki by hand in such a way that it would be feasable to automatize the steps in a script. Possible usages for a script would be:

  • Installing an instance with a different version of mediawiki.
  • delegate wiki installation to wiki administartors (provide a UI)

See also: Create_a_new_mediawiki_instance (using a template and a database dump).

Prepare a new wiki instance

Create a new directory in /var/www for the wiki installation.

mkdir /var/www/new_wiki
cd /var/www/new_wiki

Create the wiki database

Link the maintenance directory from the common wiki installation

ln -s /usr/share/mediawiki20/maintenance maintenance

Run the installer php ./maintenance/install.php with the following options

--dbuser
Database user
--dbpass
Database user password
--confpath
Path to where the LocalSettings.php shall be stored
--dbname
Name of the database to be created
--pass
Wiki administrator password
--scriptpath
Path to the wiki files, relative to /var/www

Arguments:

  • <name>: The name of the wiki
  • <admin>: The username of the wiki administrator (WikiSysop)
php ./maintenance/install.php --dbuser <dbuser> --dbpass <dbpass> --confpath <confpath> --dbname <dbname> --pass <pass> --scriptpath <scriptpath> <name> <admin>

Edit local configuration file

Biowikifarm uses a shared configuration which is in stored in MediaWikiCommonSettings.php directly in the www-root. To create configuration for an individual wiki on biowikifarm, you need to edit the file LocalSettings.php in the wiki's directory. For a a minmalistic configuration, set these variables in LocalSettings.php:

$wgSitename
Name that appears on the wiki pages, e.g. "My Wiki"
$wgScriptPath
URL base path to folder containing the wiki; relative to /var/www. Defaults for all runtime URL paths are based off of this, e.g. "mywiki"
$wgArticlePath
Virtual path. This directory MUST be different from the one used in $wgScriptPath, e.g. "/mywiki/$1"
$wgDBname
Name of the database where this wiki stores its contents, e.g. "mywiki"
$wgLanguageCode
Language to use for the interface, e.g. "en"
$wgSecretKey
A 64-character random string, e.g. the output of "openssl rand -hex 32"
<?php
$IP = dirname( __FILE__ );

$wgSitename = "";
$wgScriptPath = ""; 
$wgArticlePath = "";  
$wgUsePathInfo = true;
$wgDBname = "";
$wgLanguageCode = "";
$wgSecretKey = "66deda950ceef35d4f9fd4a6d04ca1ebdf869108827f489e3f50a8b267456c4a";

$wgDefaultSkin = 'vector';

#INCLUDING COMMON SETTINGS:
include_once("$IP/../MediaWikiCommonSettings.php");
include_once("$IP/../MediaWiki_NonDevSettings.php");

There are of course many more available settings.

Link to common files and directories

Define the path to the base Mediawiki installation (scope is restricted to this shell)

 MWPATH=/usr/share/mediawiki20

(Soft-) Link folders and files to the common mediawiki installation:

# Main web entry point for MediaWiki
ln -s $MWPATH/index.php index.php
ln -s $MWPATH/index.php5 index.php5
# Stub file for compatibility with older versions
ln -s $MWPATH/wiki.phtml wiki.phtml

# Entry point for API queries
ln -s $MWPATH/api.php api.php 
ln -s $MWPATH/api.php5 api5.php

# PHP script to be used as 404 handler to create and stream out a
# not yet existing image thumbnail.
ln -s $MWPATH/thumb_handler.php5 thumb_handler.php5
# PHP script to stream out an image thumbnail.
ln -s $MWPATH/thumb.php thumb.php
ln -s $MWPATH/thumb.php5 thumb.php5
# Image authorisation script
ln -s $MWPATH/img_auth.php img_auth.php
ln -s $MWPATH/img_auth.php5 img_auth.php5

# Entry point for the resource loader.
ln -s $MWPATH/load.php load.php
ln -s $MWPATH/load.php5 load.php5

# Entry point for the search API
ln -s $MWPATH/opensearch_desc.php5 opensearch_desc.php5

# Script that redirects to the article passed in the "wpDropdown" parameter.
# This is used by the nostalgia skin for the special pages drop-down
ln -s $MWPATH/redirect.php redirect.php
ln -s $MWPATH/redirect.php5 redirect.php5
ln -s $MWPATH/redirect.phtml redirect.phtml

# Directoriess equiered by Mediawiki
ln -s $MWPATH/bin bin
ln -s $MWPATH/docs docs
ln -s $MWPATH/extensions extensions
ln -s $MWPATH/includes includes
ln -s $MWPATH/languages languages
ln -s $MWPATH/maintenance maintenance
ln -s $MWPATH/resources resources
ln -s $MWPATH/serialized serialized
ln -s $MWPATH/skins skins

Create local directories

Make sure the right directotry is used

cd /var/www/new_wiki

Create the cache directory and make it writable for the web server

mkdir cache
chown www-data:www-data cache

If media are stored locally, create the media directory and make it writable for the web server

mkdir media
chown www-data:www-data media

Edit Web server settings