wiki-installation

Step 1: Installing MediaWiki

  1. Go to the following link: Manual

    MediaWiki and obtain the Long-Term Support (LTS) version of the wiki.

  2. Setup basic configuration:

    Navigate to the project directory:

cd /srv/wiki.example.com

Create necessary directories:

mkdir uploads
mkdir www

Download and extract MediaWiki:

wget https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.7.tar.gz www/tmp
tar xf mediawiki-1.39.7.tar.gz -C www/tmp
mv www/tmp www/w
rm  -rf  www/tmp
chown -R www-data:www-data www uploads

Configure .htaccess file:**

# Filename: /srv/wiki.example.com/www/.htaccess
RewriteEngine On

# main rewrite rule
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]

# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]

Step 2: Docker Compose

# file: /srv/wiki.example.com/docker/docker-compose.yaml
# note: docker-compose file to start up mediawiki in https://wiki.techplayr.com

name: 'wiki-example-com'

services:
  wiki:
    image: rsubr/php-apache-ubuntu:jammy
    container_name: wiki.techplayr.com
    restart: always

    volumes:
      - ./www:/var/www/html
      - ./uploads:/srv/wiki.techplayr.com/uploads
      - ./etc/apache2/mods-enabled/mpm_prefork.conf:/etc/apache2/mods-enabled/mpm_prefork.conf:ro
      - ./etc/php/99-local.ini:/etc/php/8.1/apache2/conf.d/99-local.ini:ro

    labels:
      - com.centurylinklabs.watchtower.enable=true
      - traefik.enable=true
      - traefik.http.routers.wiki.rule=Host(`wiki.example.com`) || Host (`m.wiki.example.com`)
      - traefik.http.routers.wiki.tls=true
      - traefik.http.routers.wiki.tls.certresolver=lets-encrypt

    depends_on:
      - mariadb

  mariadb:
    image: mariadb:11
    container_name: mariadb-wiki.techplayr.com
    restart: always

    environment:
      - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1
      - MARIADB_USER=${MARIADB_USER}
      - MARIADB_PASSWORD=${MARIADB_PASSWORD}
      - MARIADB_DATABASE=${MARIADB_DATABASE}

    volumes:
      - ./database:/var/lib/mysql

    labels:
      - com.centurylinklabs.watchtower.enable=true

    healthcheck:
      test: healthcheck.sh --connect --innodb_buffer_pool_loaded --innodb_initialized
      interval: 5s
      timeout: 180s
      retries: 3
# /srv/wiki.example.com/.env

COMPOSE_PROJECT_NAME=wiki

MARIADB_USER=wiki
MARIADB_PASSWORD=wiki
MARIADB_DATABASE=wiki

Step: 3 Wiki Config & Extra Namespaces

<?php
# Filename: /srv/wiki.example.com/www/w/LocalSettingsNamespaces.php
#### 1: AERONAUTICAL ENGINEERING: AERONAUTICAL ENGINEERING
define('NS_AERO', 3000);
$wgExtraNamespaces[NS_AERO] = 'AERO';
$wgNamespaceProtection[NS_AERO] = ['AERO-edit'];
$wgGroupPermissions['AERO']['AERO-edit'] = true;
$wgGroupPermissions['sysop'  ]['AERO-edit'] = true;
####


#### 2: AGRICULTURE ENGINEERING: AGRICULTURE ENGINEERING
define('NS_AGRI', 3002);
$wgExtraNamespaces[NS_AGRI] = 'AGRI';
$wgNamespaceProtection[NS_AGRI] = ['AGRI-edit'];
$wgGroupPermissions['AGRI']['AGRI-edit'] = true;
$wgGroupPermissions['sysop'  ]['AGRI-edit'] = true;
####


#### 3: ARTIFICIAL INTELLIGENCE AND DATA SCIENCE: ARTIFICIAL INTELLIGENCE AND DATA SCIENCE
define('NS_AIDATASCIENCE', 3004);
$wgExtraNamespaces[NS_AIDATASCIENCE] = 'AIDATASCIENCE';
$wgNamespaceProtection[NS_AIDATASCIENCE] = ['AIDATASCIENCE-edit'];
$wgGroupPermissions['AIDATASCIENCE']['AIDATASCIENCE-edit'] = true;
$wgGroupPermissions['sysop'  ]['AIDATASCIENCE-edit'] = true;
####

#### 4: AUTOMOBILE ENGINEERING: AUTOMOBILE ENGINEERING
define('NS_AUTO', 3008);
$wgExtraNamespaces[NS_AUTO] = 'AUTO';
$wgNamespaceProtection[NS_AUTO] = ['AUTO-edit'];
$wgGroupPermissions['AUTO']['AUTO-edit'] = true;
$wgGroupPermissions['sysop'  ]['AUTO-edit'] = true;
####

#### 5: CIVIL ENGINEERING: CIVIL ENGINEERING
define('NS_CE', 3012);
$wgExtraNamespaces[NS_CE] = 'CE';
$wgNamespaceProtection[NS_CE] = ['CE-edit'];
$wgGroupPermissions['CE']['CE-edit'] = true;
$wgGroupPermissions['sysop'  ]['CE-edit'] = true;
####


#### 6: COMPUTER SCIENCE ENGINEERING: COMPUTER SCIENCE ENGINEERING
define('NS_CSE', 3014);
$wgExtraNamespaces[NS_CSE] = 'CSE';
$wgNamespaceProtection[NS_CSE] = ['CSE-edit'];
$wgGroupPermissions['CSE']['CSE-edit'] = true;
$wgGroupPermissions['sysop'  ]['CSE-edit'] = true;
####


#### 7: ELECTRICAL & ELECTRONICS ENGINEERING: ELECTRICAL & ELECTRONICS ENGINEERING
define('NS_EEE', 3016);
$wgExtraNamespaces[NS_EEE] = 'EEE';
$wgNamespaceProtection[NS_EEE] = ['EEE-edit'];
$wgGroupPermissions['EEE']['EEE-edit'] = true;
$wgGroupPermissions['sysop'  ]['EEE-edit'] = true;
####


#### 8: ELECTRONICS & COMMUNICATION ENGINEERING: ELECTRONICS & COMMUNICATION ENGINEERING
define('NS_ECE', 3018);
$wgExtraNamespaces[NS_ECE] = 'ECE';
$wgNamespaceProtection[NS_ECE] = ['ECE-edit'];
$wgGroupPermissions['ECE']['ECE-edit'] = true;
$wgGroupPermissions['sysop'  ]['ECE-edit'] = true;
####


#### 9: ELECTRONICS & INSTRUMENTATION ENGINEERING: ELECTRONICS & INSTRUMENTATION ENGINEERING
define('NS_EI', 3020);
$wgExtraNamespaces[NS_EI] = 'EI';
$wgNamespaceProtection[NS_EI] = ['EI-edit'];
$wgGroupPermissions['EI']['EI-edit'] = true;
$wgGroupPermissions['sysop'  ]['EI-edit'] = true;
####

#### 10: MECHANICAL ENGINEERING: MECHANICAL ENGINEERING
define('NS_MECH', 3024);
$wgExtraNamespaces[NS_MECH] = 'MECH';
$wgNamespaceProtection[NS_MECH] = ['MECH-edit'];
$wgGroupPermissions['MECH']['MECH-edit'] = true;
$wgGroupPermissions['sysop'  ]['MECH-edit'] = true;
####


#### 11: MECHATRONICS: MECHATRONICS
define('NS_MTRS', 3026);
$wgExtraNamespaces[NS_MTRS] = 'MTRS';
$wgNamespaceProtection[NS_MTRS] = ['MTRS-edit'];
$wgGroupPermissions['MTRS']['MTRS-edit'] = true;
$wgGroupPermissions['sysop'  ]['MTRS-edit'] = true;
####


#### 12: BIOTECHNOLOGY: BIOTECHNOLOGY
define('NS_BT', 3028);
$wgExtraNamespaces[NS_BT] = 'BT';
$wgNamespaceProtection[NS_BT] = ['BT-edit'];
$wgGroupPermissions['BT']['BT-edit'] = true;
$wgGroupPermissions['sysop'  ]['BT-edit'] = true;
####

#### 13: INFORMATION TECHNOLOGY: INFORMATION TECHNOLOGY
define('NS_IT', 3038);
$wgExtraNamespaces[NS_IT] = 'IT';
$wgNamespaceProtection[NS_IT] = ['IT-edit'];
$wgGroupPermissions['IT']['IT-edit'] = true;
$wgGroupPermissions['sysop'  ]['IT-edit'] = true;
####


#### 14: TEXTILE TECHNOLOGY: TEXTILE TECHNOLOGY
define('NS_TT', 3040);
$wgExtraNamespaces[NS_TT] = 'TT';
$wgNamespaceProtection[NS_TT] = ['TT-edit'];
$wgGroupPermissions['TT']['TT-edit'] = true;
$wgGroupPermissions['sysop'  ]['TT-edit'] = true;
####

#### 15: LEARNING CENTRE: LEARNING CENTRE
define('NS_LC', 3046);
$wgExtraNamespaces[NS_LC] = 'LC';
$wgNamespaceProtection[NS_LC] = ['LC-edit'];
$wgGroupPermissions['LC']['LC-edit'] = true;
$wgGroupPermissions['sysop'  ]['LC-edit'] = true;
####


#### 16: RESEARCH&DEVELOPMENT: RESEARCH&DEVELOPMENT
define('NS_RD', 3048);
$wgExtraNamespaces[NS_RD] = 'RD';
$wgNamespaceProtection[NS_RD] = ['RD-edit'];
$wgGroupPermissions['RD']['RD-edit'] = true;
$wgGroupPermissions['sysop'  ]['RD-edit'] = true;
####


#### 17: TRAINING & PLACEMENT: TRAINING & PLACEMENT
define('NS_TP', 3052);
$wgExtraNamespaces[NS_TP] = 'TP';
$wgNamespaceProtection[NS_TP] = ['TP-edit'];
$wgGroupPermissions['TP']['TP-edit'] = true;
$wgGroupPermissions['sysop'  ]['TP-edit'] = true;
####

#### 18: CONTROLLER OF EXAMINATION: CONTROLLER OF EXAMINATION
define('NS_COE', 3060);
$wgExtraNamespaces[NS_COE] = 'COE';
$wgNamespaceProtection[NS_COE] = ['COE-edit'];
$wgGroupPermissions['COE']['COE-edit'] = true;
$wgGroupPermissions['sysop'  ]['COE-edit'] = true;
####

#### 19: NEWSLETTER: NEWSLETTER
define('NS_NEWSLETTER', 3076);
$wgExtraNamespaces[NS_NEWSLETTER] = 'NEWSLETTER';
$wgNamespaceProtection[NS_NEWSLETTER] = ['NEWSLETTER-edit'];
$wgGroupPermissions['NEWSLETTER']['NEWSLETTER-edit'] = true;
$wgGroupPermissions['sysop'  ]['NEWSLETTER-edit'] = true;
####


#### 20: COMMITTEES: COMMITTEES
define('NS_COMMITTEES', 3078);
$wgExtraNamespaces[NS_COMMITTEES] = 'COMMITTEES';
$wgNamespaceProtection[NS_COMMITTEES] = ['COMMITTEES-edit'];
$wgGroupPermissions['COMMITTEES']['COMMITTEES-edit'] = true;
$wgGroupPermissions['sysop'  ]['COMMITTEES-edit'] = true;
####

#### 21: MENTOR: MENTOR
define('NS_MENTOR', 3082);
$wgExtraNamespaces[NS_MENTOR] = 'MENTOR';
$wgNamespaceProtection[NS_MENTOR] = ['MENTOR-edit'];
$wgGroupPermissions['MENTOR']['MENTOR-edit'] = true;
$wgGroupPermissions['sysop'  ]['MENTOR-edit'] = true;
####
<?php
# Filename: /srv/wiki.example.com/www/w/LocalSettings.php
# This file was automatically generated by the MediaWiki 1.39.7
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See docs/Configuration.md for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
        exit;
}


## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;

$wgSitename = "Wiki";

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/w";

## The protocol and server name to use in fully-qualified URLs
$wgServer = "https://wiki.example.com";

## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

## The URL paths to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogos = [
        '1x' => "$wgResourceBasePath/resources/assets/change-your-logo.svg",
        'icon' => "$wgResourceBasePath/resources/assets/change-your-logo.svg",
];

## UPO means: this is also a user preference option

$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO

$wgEmergencyContact = "";
$wgPasswordSender = "";

$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;

## Database settings
$wgDBtype = "mysql";
$wgDBserver = "mariadb";
$wgDBname = "wiki";
$wgDBuser = "wiki";
$wgDBpassword = "wiki";

# MySQL specific settings
$wgDBprefix = "wiki_";

# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

# Shared database table
# This has no effect unless $wgSharedDB is also set.
$wgSharedTables[] = "actor";

## Shared memory settings
$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = [];

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

# Maximum size of Upload files restricted to 4MB
$wgMaxUploadSize = 4194304;

# InstantCommons allows wiki to use images from https://commons.wikimedia.org
$wgUseInstantCommons = false;

# Periodically send a pingback to https://www.mediawiki.org/ with basic data
# about this MediaWiki instance. The Wikimedia Foundation shares this data
# with MediaWiki developers to help guide future development efforts.
$wgPingback = true;

# Site language code, should be one of the list in ./includes/languages/data/Names.php
$wgLanguageCode = "en";

# Time zone
$wgLocaltimezone = "UTC";

## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publicly accessible from the web.
$wgCacheDirectory = "$IP/cache";

$wgSecretKey = "7037cfbff7da76f8063cd7a22e2cb869d581249c3a866b21b46c06c6135402aa";

# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "622ca77613558d5f";

## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

#### Page edit permissions

# The following permissions were set based on your choice in the installer
$wgGroupPermissions['*']['createaccount'    ] = false;
$wgGroupPermissions['*']['autocreateaccount'] = true;

# Only registered users can read pages
$wgGroupPermissions['*'   ]['read'] = false;
$wgGroupPermissions['user']['read'] = true;

# Anonymous users and non-faculty (students) cannot edit pages
$wgGroupPermissions['*'   ]['edit'] = false;
$wgGroupPermissions['user']['edit'] = false;

# Faculty members can edit
$wgGroupPermissions['Faculty']['edit'] = true;
$wgGroupPermissions['sysop'  ]['edit'] = true;

# Disable user created bot access (for APIs)
$wgEnableBotPasswords = false;

# Ensure only authorized users can access uploads
$wgUploadPath = "$wgScriptPath/img_auth.php";
$wgUploadDirectory = '/srv/wiki.example.com/uploads';
$wgEnableUploads = true;
$wgWhitelistRead = false;

# Allow to split site_stats across multiple rows
$wgMultiShardSiteStats = true;

####

## Default skin: you can change the default skin. Use the internal symbolic
## names, e.g. 'vector' or 'monobook':
$wgDefaultSkin = "vector";
$wgMFDefaultSkinClass = 'SkinMinerva';
$wgMFAutodetectMobileView = true;
$wgMobileUrlTemplate = 'm.wiki.bitsathy.ac.in';

# Enabled skins.
# The following skins were automatically enabled:
wfLoadSkin( 'MinervaNeue' );
wfLoadSkin( 'MonoBook' );
wfLoadSkin( 'Timeless' );
wfLoadSkin( 'Vector' );

# Enabled extensions. Most of the extensions are enabled by adding
# wfLoadExtension( 'ExtensionName' );
# to LocalSettings.php. Check specific extension documentation for more details.
# The following extensions were automatically enabled:
wfLoadExtension( 'AbuseFilter' );
wfLoadExtension( 'CategoryTree' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'CiteThisPage' );
wfLoadExtension( 'CodeEditor' );
wfLoadExtension( 'ConfirmEdit' );
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'ImageMap' );
wfLoadExtension( 'InputBox' );
wfLoadExtension( 'Interwiki' );
wfLoadExtension( 'Math' );
wfLoadExtension( 'MultimediaViewer' );
wfLoadExtension( 'Nuke' );
wfLoadExtension( 'OATHAuth' );
wfLoadExtension( 'PageImages' );
wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'PdfHandler' );
wfLoadExtension( 'Poem' );
wfLoadExtension( 'Renameuser' );
wfLoadExtension( 'ReplaceText' );
wfLoadExtension( 'Scribunto' );
wfLoadExtension( 'SecureLinkFixer' );
wfLoadExtension( 'SpamBlacklist' );
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'TemplateData' );
wfLoadExtension( 'TextExtracts' );
wfLoadExtension( 'TitleBlacklist' );
wfLoadExtension( 'VisualEditor' );
wfLoadExtension( 'WikiEditor' );


# Include extra namespaces
require_once "$IP/LocalSettingsNamespaces.php";

# End of automatically generated settings.
# Add more configuration options below.

// Per default, the VisualEditor only works with Namespace 0 (NS_MAIN),
// i.e. the main article namespace. To change this, adapt the following example
// that enables namespaces 0 (main), 2 (user) and 102 (some user specific one)
$wgVisualEditorAvailableNamespaces = [
    NS_MAIN => true,
    NS_USER => true,
    102 => true,
    NS_AERO => true,
    NS_AGRI => true,
    NS_AIDATASCIENCE => true,
    NS_AUTO => true,
    NS_CE => true,
    NS_CSE => true,
    NS_EEE => true,
    NS_ECE => true,
    NS_EI => true,
    NS_MECH => true,
    NS_MTRS => true,
    NS_BT => true,
    NS_IT => true,
    NS_TT => true,
    NS_LC => true,
    NS_RD => true,
    NS_TP => true,
    NS_COE => true,
    NS_NEWSLETTER => true,
    NS_COMMITTEES => true,
    NS_MENTOR => true,
    "_merge_strategy" => "array_plus"
];

After creating the files, run the following command to start the containers:

docker-compose up -d

Navigate to https://wiki.example.com and follow the on-screen instructions to set up the wiki.