-
Notifications
You must be signed in to change notification settings - Fork 4
Integrating with Mediawiki
Edward Hibbert edited this page Jan 11, 2021
·
27 revisions
Restarters can integrate with a MediaWiki installation.
If enabled, when logging in to Restarters, users are automatically created an account on, and/or logged in to, the MediaWiki install.
FEATURE__WIKI_INTEGRATION=true
-
WIKI_URL
points at your local MediaWiki install -
WIKI_APIUSER
andWIKI_APIPASSWORD
set to match that of a user on MediaWiki that hasadministrator
role
If the automatic log in is being problematic, and you just want to log in to see how something looks when authenticated, you can log in direct at /Special:UserLogin.
- the domain at which you install MediaWiki should match that of the Laravel application plus a subdomain of
wiki
- this ensures that the session cookie can be set to log you in
- see https://github.com/therestartproject/wiki-utils for more info
- Create a mediawiki.yml file containing this:
# MediaWiki with MariaDB
#
# Access via "http://localhost:8080"
# (or "http://$(docker-machine ip):8080" if using docker-machine)
version: '3'
services:
mediawiki:
build: .
restart: always
ports:
- 8080:80
links:
- database
volumes:
- /var/www/html/images
# After initial setup, download LocalSettings.php to the same directory as
# this yaml and uncomment the following line and use compose to restart
# the mediawiki service
# - ./LocalSettings.php:/var/www/html/LocalSettings.php
database:
image: mariadb
restart: always
environment:
# @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
MYSQL_DATABASE: my_wiki
MYSQL_USER: wikiuser
MYSQL_PASSWORD: example
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
Create a Dockerfile containing this:
FROM php:7.2-apache
# System dependencies
RUN set -eux; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
git \
librsvg2-bin \
imagemagick \
# Required for SyntaxHighlighting
python3 \
; \
rm -rf /var/lib/apt/lists/*
# Install the PHP extensions we need
RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libicu-dev \
; \
\
docker-php-ext-install -j "$(nproc)" \
intl \
mbstring \
mysqli \
opcache \
; \
\
pecl install APCu-5.1.18; \
docker-php-ext-enable \
apcu \
; \
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { print $3 }' \
| sort -u \
| xargs -r dpkg-query -S \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=60'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
# SQLite Directory Setup
RUN set -eux; \
mkdir -p /var/www/data; \
chown -R www-data:www-data /var/www/data
# Version
ENV MEDIAWIKI_MAJOR_VERSION 1.31
ENV MEDIAWIKI_VERSION 1.31.10
# MediaWiki setup
RUN set -eux; \
fetchDeps=" \
gnupg \
dirmngr \
"; \
apt-get update; \
apt-get install -y --no-install-recommends $fetchDeps; \
\
curl -fSL "https://releases.wikimedia.org/mediawiki/${MEDIAWIKI_MAJOR_VERSION}/mediawiki-${MEDIAWIKI_VERSION}.tar.gz" -o mediawiki.tar.gz; \
curl -fSL "https://releases.wikimedia.org/mediawiki/${MEDIAWIKI_MAJOR_VERSION}/mediawiki-${MEDIAWIKI_VERSION}.tar.gz.sig" -o mediawiki.tar.gz.sig; \
export GNUPGHOME="$(mktemp -d)"; \
# gpg key from https://www.mediawiki.org/keys/keys.txt
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys \
D7D6767D135A514BEB86E9BA75682B08E8A3FEC4 \
441276E9CCD15F44F6D97D18C119E1A64D70938E \
F7F780D82EBFB8A56556E7EE82403E59F9F8CD79 \
1D98867E82982C8FE0ABC25F9B69B3109D3BB7B0 \
; \
gpg --batch --verify mediawiki.tar.gz.sig mediawiki.tar.gz; \
tar -x --strip-components=1 -f mediawiki.tar.gz; \
gpgconf --kill all; \
rm -r "$GNUPGHOME" mediawiki.tar.gz.sig mediawiki.tar.gz; \
chown -R www-data:www-data extensions skins cache images; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \
rm -rf /var/lib/apt/lists/*
CMD ["apache2-foreground"]
- docker-compose -f mediawiki.yml up
- We will go through standard mediawiki install and database migration to ensure that we can do so, and so that we have a working LocalSettings.php for this version before customising it. Go to http://localhost:8080 and go through setup. Use the defaults except for
- database host of 'database'
- database name of 'my_wiki'
- database table prefix of 'mw_'
- database username of 'wikiuser'
- database password of 'example'
- name of wiki 'Restarters Wiki'
- Administrator account - provide your own details
- This will give you a LocalSettings.php.
- docker cp "LocalSettings.php" restart_mediawiki_1:/var/www/html/
- Copy and decrypt an SQL backup of the wiki, e.g. to wiki.sql.
- docker cp wiki.sql :/tmp/
- docker exec -it bash
- mysql -u wikiuser -p my_wiki < /tmp/wiki.sql
- docker exec -it bash
- cd /var/www/wiki/maintenance; php update.php
- Set wiki.restarters.test to 127.0.0.1 in your hosts file.
- Check that the wiki appears with some contents and the default skin at http://localhost:8080/
- docker exec -it bash
- apt-get update ; apt-get install vim wget unzip
- Edit composer.local.json and set it to:
{
"require": {
"mediawiki/chameleon-skin": "2.1.0"
}
}
- wget https://getcomposer.org/composer-1.phar ; mv composer-1.phar composer.phar; php composer.phar install
- Copy the wiki-restarters-skin project using docker cp .\ :/var/www/html/skins/chameleon/
- Save off LocalSettings.php - this means we have a reference of a working config for this mediawiki version.
- Copy https://github.com/TheRestartProject/wiki-utils/tree/master/deployment/LocalSettings.example.php to LocalSettings.php.
- Correct any syntax errors and copy the $wgDB* settings from the version you installed.
- Set these:
$wgDefaultSkin = "chameleon";
$wgArticlePath = $wgScriptPath.'/index.php/$1';
wfLoadSkin('chameleon')
$egChameleonLayoutFile = __DIR__.'/skins/chameleon/layouts/body.xml';
$gCookieDomain = "restarters.test";
$wgServer = "http://wiki.restarters.test:8080";
- If migrating from an older MW version, check that we call
addModuleScripts( 'skin.chameleon.jquery-sticky' )
- the name of this method has changed. - tar up the extensions folder from the live server and extract it in your container.
- Upgrade ApprovedRevs extension from https://www.mediawiki.org/wiki/Extension:Approved_Revs#Download.
- Hack these methods to be public:
includes/skins/BaseTemplate.php: public function getFooterLinks( $option = null ) {
includes/skins/BaseTemplate.php: public function makeSearchInput( $attrs = [] ) {
includes/skins/Skin.php: public function getFooterLinks(): array {
To log in, you need to go to http://localhost:8080/index.php/Special:UserLogin as SSO won't work.