Install Mediawiki

From The Maceys in California
Revision as of 23:17, 25 January 2026 by Lynn Macey (talk | contribs) (Created page with "== MediaWiki Installation == ===Pre-requisites=== There are usually one or two of them around. This procedure requires a full lamp installation. MediaWiki has an optional requirement for a module that is part of the PECL library. PECL must be installed in order to use it. Install PECL <syntaxhighlight lang=shell> pecl install APCu sed -i 's/;extension=xsl/a extension=apcu.so' </syntaxhighlight> ====Install Composer==== Composer is used to install Mediawiki extensi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

MediaWiki Installation

Pre-requisites

There are usually one or two of them around. This procedure requires a full lamp installation.

MediaWiki has an optional requirement for a module that is part of the PECL library. PECL must be installed in order to use it.

Install PECL

pecl install APCu
sed -i 's/;extension=xsl/a extension=apcu.so'

Install Composer

Composer is used to install Mediawiki extensions and PHP modules needed by the extensions.

sudo apt install composer
composer --version


Install ImageMagick

apt install imagemagick -y

Create the database

This can be done with Phpmyadmin or this script.

sudo mariadb -u root -p  <<EOF
CREATE DATABASE mediawiki;
CREATE USER 'mediawiki'@'localhost' IDENTIFIED BY 'zaq1plm';
GRANT ALL PRIVILEGES ON mediawiki.* TO 'mediawiki'@'localhost' WITH GRANT OPTION;
\q
EOF

Download and Unpack the Package

cd /var/www/html
wget https://releases.wikimedia.org/mediawiki/1.41/mediawiki-1.41.0.tar.gz
tar xvf mediawiki-1.41.0.tar.gz
ln -s mediawiki-1.41.0 wiki

Craft the Site Config File

This is a quick solution to the the reverse proxy problem. The initial idea of doing the reverse proxy to wiki.maceys.net causes a loop and fails. Each application will respond on a different port.

cd /etc/apache2/sites-available
cp 000-default.conf 001-wiki.conf
sed -i 's/*:80/*:9202/' 001-wiki.conf
sed -i 's\/var/www/html\/var/www/html/wiki\' 001-wiki.conf
sed -i 's/error.log/wiki-error.log/' 001-wiki.conf
sed -i 's/access.log/wiki-access.log/' 001-wiki.conf
echo ' ' > /tmp/z
echo '        <Directory "/var/www/html/wiki/">' >> /tmp/z
echo '            DirectoryIndex index.php index.html' >> /tmp/z
echo '            Options FollowSymLinks' >> /tmp/z
echo '            AllowOverride All' >> /tmp/z
echo '            Require all granted' >> /tmp/z
echo '            Options MultiViews FollowSymlinks' >> /tmp/z
echo '        </Directory>' >> /tmp/z
echo ' ' >> /tmp/z 
echo '        <Directory "/var/www/html/wiki/images">' >> /tmp/z
echo '            # Ignore .htaccess files' >> /tmp/z
echo '            AllowOverride None' >> /tmp/z
echo ' ' >> /tmp/z   
echo "            # Serve HTML as plaintext, don't execute SHTML" >> /tmp/z
echo '            AddType text/plain .html .htm .shtml .phtml' >> /tmp/z
echo ' ' >> /tmp/z    
echo "            # Don't run arbitrary PHP code." >> /tmp/z
echo '            # php_admin_flag engine off' >> /tmp/z
echo ' ' >> /tmp/z 
echo '            # Tell browsers to not sniff files' >> /tmp/z
echo '            Header set X-Content-Type-Options nosniff' >> /tmp/z
echo ' ' >> /tmp/z    
echo "            # If you've other scripting languages, disable them too." >> /tmp/z
echo '        </Directory>' >> /tmp/z
sed -i -e '/DocumentRoot/r /tmp/z' 001-wiki.conf
cd ../sites-enabled
ln -s ../sites-available/001-wiki.conf .

Add the Port Number to the ports.conf File

csplit ports.conf /Listen/ /IfModule/
echo 'Listen 9202'>>xx01
sort xx01|uniq>xx01a
sed -i '/^$/d' xx01a
echo ''>> xx01a
cat xx00 xx01a xx02 > ports.conf
rm -f xx0*

Restart Apache

systemctl restart apache2

Configure the Wiki Install

Open the site in browser.

http://<host>:9202

If all is well, proceed to "set up the wiki"

Language -> Continue
Connect to Database -> Database name: mediawiki, Database username: mediawiki -> Continue
Database Settings -> Continue 
Name -> Fill in appropriate values. Leave "Ask more questions" set -> Continue
Options -> Set Timeless as the default skin. Check all the Extensions boxes -> Continue
Install -> Continue ... Continue

Install LocalSettings.php

This is a manual process since the file ends up in the Downloads folder. Copy the current one in Downloads to the /var/www/html/wiki directory and then click on "enter your wiki" If you click before copying the file the installation will start over.

Post Install Changes

You will need to login from here on.

Expand the Menu Sidebar

Edit the Navigation URL to read "index.php?title=MediaWiki:Sidebar&action=edit". Replace the initial menu with:

* navigation
** mainpage|mainpage-description
** recentchanges-url|recentchanges
** randompage-url|randompage
** helppage|help-mediawiki
* Common
** Special:EditPage|Edit Page
** Special:CreateTemplate|Create a Template
** Special:WantedPages|Wanted pages
** Special:WantedTemplates|Wanted templates
** Special:UserCredentials|User Credentials
* SEARCH
* TOOLBOX
* LANGUAGES

Save changes.

Install Skins

Install Chameleon

Do not run as root. Do an su to www-data

cd /var/www/html/wiki
COMPOSER=composer.local.json composer require --no-update mediawiki/chameleon-skin:~4.0
composer update mediawiki/chameleon-skin --no-dev -o

Add the following lines to LocalSettings.php

wfLoadExtension( 'Bootstrap' );
wfLoadSkin( 'chameleon' );

Note that the bootstrap extension may already be loaded.

https://www.mediawiki.org/wiki/Skin:Chameleon

Install Citizen

wget https://github.com/StarCitizenTools/mediawiki-skins-Citizen/archive/main.zip

https://www.mediawiki.org/wiki/Skin:Citizen

DeskMessMirrored

Download from here: https://www.mediawiki.org/wiki/Special:SkinDistributor/DeskMessMirrored

cd /tmp
wget https://extdist.wmflabs.org/dist/skins/DeskMessMirrored-REL1_40-79bde9e.tar.gz
tar xvf DeskMessMirrored-REL1_40-79bde9e.tar.gz
mv DeskMessMirrored /var/www/html/wiki/skins
rm DeskMessMirrored-REL1_40-79bde9e.tar.gz

Add the following code at the bottom of your LocalSettings.php file:

wfLoadSkin( 'DeskMessMirrored' );

https://www.mediawiki.org/wiki/Skin:DeskMessMirrored

Install Foreground
cd /var/www/html/wiki/skins
git clone https://github.com/wikimedia/mediawiki-skins-Foreground.git Foreground

Add the following code at the bottom of your LocalSettings.php file:

wfLoadSkin( 'Foreground' );

https://foreground.wikiproject.net/wiki/Main_Page

Install Material
cd /var/www/html/wiki/skins
git clone https://gerrit.wikimedia.org/r/mediawiki/skins/Material

Add the following code at the bottom of your LocalSettings.php file:

wfLoadSkin( 'Material' );

https://www.mediawiki.org/wiki/Skin:Material

Install Medik
cd /tmp
wget https://bitbucket.org/wikiskripta/medik/get/master.zip
mv *medik* /var/www/html/wiki/skins/Medik
rm master.zip

Add the following code at the bottom of your LocalSettings.php file:

wfLoadSkin( 'Medik' );

https://www.mediawiki.org/wiki/Skin:Medik

Install Pivot

https://pivot.wikiproject.net/wiki/Main_Page

Install Tweeli

https://tweeki.kollabor.at/wiki/Welcome

Install Extensions

https://blog.fedecarg.com/2008/03/08/20-mediawiki-extensions-you-should-be-using/

look here for a list: https://www.pro.wiki/pricing#Extensions

https://www.mediawiki.org/wiki/Documentation/Style_guide/templates

Install the mediawiki-extension command

https://www.npmjs.com/package/mediawiki-extension?activeTab=readme

Install node: apt install nodejs; apt install npm; /usr/bin/npm install -g mediawiki-extension

Install Composer Utility

As a regular user execute the following:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

Using Compuser to Install Extensions

https://professional.wiki/en/articles/installing-mediawiki-extensions-with-composer

Install ExtensionInstall

Install this first so that it can document the process for the ones below.

Doesn't install, not found.

https://www.mediawiki.org/wiki/Template:ExtensionInstall

Also checkout: https://www.mediawiki.org/wiki/Category:Extension_templates

Install AccessControl

Add these to LocalSettings

$wgGroupPermissions['*']['writeapi']        = false;
$wgGroupPermissions['*']['createpage']      = false;
$wgGroupPermissions['*']['createtalk']      = false;
wfLoadExtension( 'AccessControl' );
 cd /var/www/html/wiki/extensions
 git clone https://github.com/wikimedia/mediawiki-extensions-AccessControl.git AccessControl

See README for additional configuration

CodeMirror
cd /var/www/html/wiki/extensions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror

Add the following code at the bottom of your LocalSettings.php file:

wfLoadExtension( 'CodeMirror' );

https://www.mediawiki.org/wiki/Extension:CodeMirror

Install ConfirmAccount
cd /var/www/html/wiki/extensions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmAccount
php maintenance/update.php

Make the following changes to LocalSettings.php

wfLoadExtension( 'ConfirmAccount' );
$wgGroupPermissions['*']['createaccount'] = false; // REQUIRED to enforce account requests via this extension
$wgGroupPermissions['bureaucrat']['createaccount'] = true; // optional to allow account creation by this trusted user group

https://www.mediawiki.org/wiki/Extension:ConfirmAccount

Install Create User Page

cd extensions/

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CreateUserPage

Add the following code at the bottom of your LocalSettings.php file:

wfLoadExtension( 'CreateUserPage' );

DataTransfer
cd /var/www/html/wiki/extensions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/DataTransfer

Add the following code at the bottom of your LocalSettings.php file:

wfLoadExtension( 'DataTransfer' );

https://www.mediawiki.org/wiki/Extension:Data_Transfer

Install EmbedVideo

git clone https://gitlab.com/hydrawiki/extensions/EmbedVideo.git

wfLoadExtension("EmbedVideo"); https://www.mediawiki.org/wiki/Extension:EmbedVideo

External Data

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/ExternalData

wfLoadExtension( 'ExternalData' );

https://www.mediawiki.org/wiki/Extension:External_Data

Install Lingo
cd /var/www/html/wiki
COMPOSER=composer.local.json php composer.phar require --no-update mediawiki/lingo ^3.0
php composer.phar update --no-dev mediawiki/lingo

Any future update is then just a call to php composer.phar update --no-dev mediawiki/lingo

Add to the end of LocalSettings.php: wfLoadExtension('Lingo');

Install PageForms
cd /var/www/html/wiki/extensions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PageForms.git

Add the following line to the local modifications section of LocalSettings.php

wfLoadExtension( 'PageForms' );

https://www.mediawiki.org/wiki/Extension:Page_Forms/Page_Forms_and_templates

Install HeaderTabs
cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/HeaderTabs

Add the following code at the bottom of your LocalSettings.php file:

wfLoadExtension( 'HeaderTabs' );

https://www.mediawiki.org/wiki/Extension:Header_Tabs

Install HTMLTags

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/HTMLTags.git

wfLoadExtension( 'HTMLTags' );

https://www.mediawiki.org/wiki/Extension:HTML_Tags

Install JsonConfig

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/JsonConfig

Add the following code at the bottom of your LocalSettings.php file:

wfLoadExtension( 'JsonConfig' );

https://www.mediawiki.org/wiki/Extension:JsonConfig

Lockdown

https://www.mediawiki.org/wiki/Extension:Lockdown

Install Maps

COMPOSER=composer.local.json composer require --no-update mediawiki/maps:~10.1

composer update mediawiki/maps --no-dev -o

wfLoadExtension( 'Maps' );

$egMapsDefaultService = 'leaflet';

https://maps.extension.wiki/wiki/Installation

Install MobileFrontend

Done...except it throws a 500 error

https://www.mediawiki.org/wiki/Extension:MobileFrontend

Install Networks

COMPOSER=composer.local.json composer require --no-update professional-wiki/network:~2.0

composer update professional-wiki/network --no-dev -o

wfLoadExtension( 'Network' );

Minimal example

{{#network:}}

Example with parameters

{{#network:Page1 | Page2 | Page3
 | class = col-lg-3 mt-0
 | exclude = Main Page ; Sitemap
}}

https://github.com/ProfessionalWiki/Network#network

Install New User Page

cd extensions/

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/NewUserMessage

Add the following code at the bottom of your LocalSettings.php file:

wfLoadExtension( 'NewUserMessage' );

Install Pipe Escape

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/PipeEscape

wfLoadExtension( 'PipeEscape' );

Install SkinPerPage
cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/SkinPerPage

Add the following code at the bottom of your LocalSettings.php file:

wfLoadExtension( 'SkinPerPage' );
<skin>SkinName</skin>

https://www.mediawiki.org/wiki/Extension:SkinPerPage

Install Semantc_MediaWiki

Check back with this one. Does not complete install

COMPOSER=composer.local.json php composer.phar require --no-update mediawiki/semantic-media-wiki

composer update --no-dev

wfLoadExtension( 'SemanticMediaWiki' ); enableSemantics( 'example.org' );

php maintenance/update.php

See installation page, then look at the docs

https://www.mediawiki.org/wiki/Extension:Semantic_MediaWiki

Install TemplateSandbox

cd /var/www/html/wiki/extensions

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateSandbox

wfLoadExtension( 'TemplateSandbox' );

https://www.mediawiki.org/wiki/Extension:TemplateSandbox

Install TemplateWizard

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateWizard

wfLoadExtension( 'TemplateWizard' );

https://www.mediawiki.org/wiki/Extension:TemplateWizard

Install TemplateStyles

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateStyles

wfLoadExtension( 'TemplateStyles' );

https://www.mediawiki.org/wiki/Extension:TemplateStyles

Install TitleKey

cd extensions/

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/TitleKey

Add the following code at the bottom of your LocalSettings.php file:

wfLoadExtension( 'TitleKey' );

Install Variables

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Variables

wfLoadExtension( 'Variables' );

https://www.mediawiki.org/wiki/Extension:Variables

See Also

MediaWiki Home Page