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

From Biowikifarm Metawiki
< User:Alvaro Ortiz-Troncoso
Revision as of 12:24, 30 January 2015 by Alvaro Ortiz-Troncoso (Talk | contribs) (Link to common files and 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.

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

Create a new wiki directory

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>

Grant user rights

Once the database has been created by the maintenance script, the db wiki user has to get these rights:

-- DROP , INDEX ,CREATE TEMPORARY TABLES seems necessary only for Semantic MediaWiki Wikis or maybe only Semantic Forms
GRANT SELECT , INSERT , UPDATE , DELETE , DROP , INDEX ,CREATE TEMPORARY TABLES ON  `wikiname`.* TO  'wikiuser'@'localhost';


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 = "";

$wgDefaultSkin = 'vector';

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

There are of course many more available settings.

Update database tables

You'll need to run the update script, to ensure that tables required in LocalSettings are available:

cd /var/www/v-XXX/w;   sudo -u www-data php ./maintenance/update.php  --quick --conf ./LocalSettings.php

Edit Web server settings

There are two files where you can place your server configuration.

No own domain name

If your server has no own domain name, you can place the configuration in
/etc/nginx/sites-enabled/default

Own domain name

If you have your own domain name, then plaease make a new configuration in
/etc/nginx/sites-available
and link it from
/etc/nginx/sites-enabled
Assuming you wiki is called "<wikiname>" and is located at
/var/www/<wikipath>
:
# === Wiki: path=mywiki, ShortURL=mywiki ===
 location /<wikiname> {
   try_files $uri @do_<wikiname>_wikipage;
 }
 location @do_<wikiname>_wikipage {
   rewrite "^/<wikiname>$" /<wikiname>/ redirect;
   rewrite "^/<wikiname>/([^?]*)(?:\?(.*))?$" /<wikiname>/index.php?title=$1&$args last;
 }
 location /<wikiname>/media {
   location ~ ^/<wikiname>/media/thumb/(archive/)?[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ {
     try_files $uri @thumb_<wikiname>;
   }
 }
 location @thumb_<wikiname> {
   rewrite ^/<wikiname>/media/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /<wikipath>/thumb.php?f=$1&wi$
   rewrite ^/<wikiname>/media/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ /<wikipath>/thumb.php$
   include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME  $document_root/<wikipath>/thumb.php; fastcgi$
 }

Test the configuration

nginx -t

Then restart nginx

/usr/sbin/apache2ctl -k graceful && sudo service nginx restart && sudo service php5-fpm restart

Testing the installation

You should now be able to see your wiki at: http://servername/wikiname/index.php?title=Main_Page

Debugging

If it doesn't work, you can enable logging:

In LocalSettings.php, add:

$wgDebugLogFile = "$IP/debug.log";

In the wiki's directory, do

touch debug.log
chown www-data:www-data debug.log

To see log output, do

tail -n300 -f debug.log

Please remember to disable logging once you have solved the problem.