Mediawiki with docker. Can't locate LocalSettings.php and cannot access database

1.8k Views Asked by At

I have setup a mediawiki (version 1.35.1) with a mariadb using docker on my Raspberry Pi3. When I first run the docker-compose file everything works fine and I can create the LocalSettings.php.

Problem 1:
I copy the LocalSettings.php to the path /data/conf/LocalSettings.php, uncomment the line in the docker-compose.yml file and restart with docker-compose restart. But I always come back to the "Please complete the installation" page. It just works when i copy the file into the mediawiki container on path /var/www/html
Why is mediawiki not able to find the LocalSettings.php? Or am I understand something wrong?

Here is my docker-compose.yml file

version: '3.3'
services:
  mediawiki:
    image: mediawiki
    restart: always
    ports:
      - ${BIND_TO}:${INT_PORT}
    links:
      - database
    volumes:
      - data_mw_images:/var/www/html/images
      - ./data/sitemap:/var/www/html/sitemap
      # After initial setup, download LocalSettings.php to data/conf directory
      # and uncomment the following line and use compose to restart
      # the mediawiki service
      #- ./data/conf/LocalSettings.php:/var/www/html/LocalSettings.php:ro
      # - ./data/conf/.htaccess:/var/www/html/.htaccess:ro
      # Spezial Stuff (Google AdSense & Search Console)
      #- ./data/conf/robots.txt:/var/www/html/robots.txt:ro
      #- ./data/conf/ads.txt:/var/www/html/ads.txt:ro
      # Mediwaiki Extensions
      #- ./data/extensions/WikiCategoryTagCloud:/var/www/html/extensions/WikiCategoryTagCloud:ro
      #- ./data/extensions/CategoryTagCloud:/var/www/html/extensions/CategoryTagCloud:ro
      #- ./data/extensions/SelectCategory:/var/www/html/extensions/SelectCategory:ro
      #- ./data/extensions/googleAnalytics:/var/www/html/extensions/googleAnalytics:ro
      #- ./data/extensions/GoogleAdSense:/var/www/html/extensions/GoogleAdSense:ro
      #- ./data/extensions/Lockdown:/var/www/html/extensions/Lockdown:ro
      #- ./data/extensions/MobileFrontend:/var/www/html/extensions/MobileFrontend:ro
      #- ./data/extensions/CookieWarning:/var/www/html/extensions/CookieWarning:ro
      #- ./data/extensions/RelatedArticles:/var/www/html/extensions/RelatedArticles:ro
      #- ./data/extensions/Description2:/var/www/html/extensions/Description2:ro
      # Mediawiki Skins
      #- ./data/skins/MinervaNeue:/var/www/html/skins/MinervaNeue:ro

  database:
    image: linuxserver/mariadb:arm32v6-latest
    volumes:
      - data_mw_db:/var/lib/mysql
    restart: always
    environment:
      # @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
      MYSQL_DATABASE: ${MYSQL_DATABASE}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_RANDOM_ROOT_PASSWORD: ${MYSQL_RANDOM_ROOT_PASSWORD}
      TZ: ${TZ}
volumes:
  data_mw_db:
  data_mw_images:

Problem 2:
When I copy the LocalSettings.php into the container it works fine. But when I restart my Pi and try to access the Mediawiki page i get another error (but the error appears not eveytime I restart. Sometimes it works... ‍♂️)

Sorry! This site is experiencing technical difficulties.

Try waiting a few minutes and reloading.

(Cannot access the database)

Backtrace:

#0 /var/www/html/includes/libs/rdbms/loadbalancer/LoadBalancer.php(934): Wikimedia\Rdbms\LoadBalancer->reportConnectionError()
#1 /var/www/html/includes/libs/rdbms/loadbalancer/LoadBalancer.php(901): Wikimedia\Rdbms\LoadBalancer->getServerConnection(0, 'mywikidb', 0)
#2 /var/www/html/includes/libs/rdbms/loadbalancer/LoadBalancer.php(1046): Wikimedia\Rdbms\LoadBalancer->getConnection(-1, Array, 'mywikidb', 0)
#3 /var/www/html/includes/GlobalFunctions.php(2469): Wikimedia\Rdbms\LoadBalancer->getMaintenanceConnectionRef(-1, Array, 'mywikidb')
#4 /var/www/html/includes/cache/localisation/LCStoreDB.php(56): wfGetDB(-1)
#5 /var/www/html/includes/cache/localisation/LocalisationCache.php(449): LCStoreDB->get('en', 'deps')
#6 /var/www/html/includes/cache/localisation/LocalisationCache.php(495): LocalisationCache->isExpired('en')
#7 /var/www/html/includes/cache/localisation/LocalisationCache.php(414): LocalisationCache->initLanguage('en')
#8 /var/www/html/includes/cache/localisation/LocalisationCache.php(333): LocalisationCache->loadSubitem('en', 'messages', 'title-invalid-e...')
#9 /var/www/html/languages/Language.php(2645): LocalisationCache->getSubitem('en', 'messages', 'title-invalid-e...')
#10 /var/www/html/includes/cache/MessageCache.php(1030): Language->getMessage('title-invalid-e...')
#11 /var/www/html/includes/cache/MessageCache.php(988): MessageCache->getMessageForLang(Object(LanguageEn), 'title-invalid-e...', false, Array)
#12 /var/www/html/includes/cache/MessageCache.php(930): MessageCache->getMessageFromFallbackChain(Object(LanguageEn), 'title-invalid-e...', false)
#13 /var/www/html/includes/language/Message.php(1304): MessageCache->get('title-invalid-e...', false, Object(LanguageEn))
#14 /var/www/html/includes/language/Message.php(862): Message->fetchMessage()
#15 /var/www/html/includes/language/Message.php(954): Message->toString('text')
#16 /var/www/html/includes/title/MalformedTitleException.php(51): Message->text()
#17 /var/www/html/includes/title/MediaWikiTitleCodec.php(346): MalformedTitleException->__construct('title-invalid-e...', '')
#18 /var/www/html/includes/Title.php(3413): MediaWikiTitleCodec->splitTitleString('', 0)
#19 /var/www/html/includes/Title.php(427): Title->secureAndSplit('')
#20 /var/www/html/includes/MediaWiki.php(88): Title::newFromURL(NULL)
#21 /var/www/html/includes/MediaWiki.php(151): MediaWiki->parseTitle()
#22 /var/www/html/includes/MediaWiki.php(902): MediaWiki->getTitle()
#23 /var/www/html/includes/MediaWiki.php(543): MediaWiki->main()
#24 /var/www/html/index.php(53): MediaWiki->run()
#25 /var/www/html/index.php(46): wfIndexMain()
#26 {main}

Does anyone know how to fix that?

Here is the LocalSettings.php:

<?php
# This file was automatically generated by the MediaWiki 1.35.1
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See includes/DefaultSettings.php 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 Home";
$wgMetaNamespace = "Wiki_Home";

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

## The protocol and server name to use in fully-qualified URLs
$wgServer = "http://192.168.178.22:9002";

## 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/wiki.png" ];

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

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

$wgEmergencyContact = "[email protected]";
$wgPasswordSender = "[email protected]";

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

## Database settings
$wgDBtype = "mysql";
$wgDBserver = "database";
$wgDBname = "wikidb";
$wgDBuser = "mediawikiuser";
$wgDBpassword = "xxx";

# MySQL specific settings
$wgDBprefix = "";

# 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 = false;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

# 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;

## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale. This should ideally be set to an English
## language locale so that the behaviour of C library functions will
## be consistent with typical installations. Use $wgLanguageCode to
## localise the wiki.
$wgShellLocale = "C.UTF-8";

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

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

$wgSecretKey = "xxx";

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

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

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "vector";

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


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

$wgSessionCacheType = CACHE_DB;

Hope someone can help me.

Thanks and Regards

0

There are 0 best solutions below