I am trying to make our mediawiki reachable from the internet, but it does not work. I have tried several things (you will see it in the config files..) but could only get to the point where the side is only loading without a stylesheet and only a few images.
Right now, it is fully working under example.com:8080/index.php/MainPage with a separate vhost.conf. It should be reachable under example.com/wiki/MainPage.
The Software I am using:
- MediaWiki 1.31.1
- PHP 7.2.24
- MySQL 5.7.32
- Apache 2.4.29
This is the working vhost.conf, only accessible from our internal network I want to get rid of:
<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/html <Directory /var/www/example.com/html> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ScriptAlias /cgi-bin /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> Include /etc/mediawiki/mediawiki.conf ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com <VirtualHost *:8080> ServerAdmin webmaster@localhost DocumentRoot /var/www/mediawiki <Directory /> Options FollowSymLinks AllowOverride None Order allow,deny allow from all </Directory> <Directory /var/www/mediawiki> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> Include /etc/mediawiki/mediawiki.conf ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order allow,deny allow from all </Directory> # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
That is my new vhost.conf:
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName example.com ServerAlias www.example.com DocumentRoot /var/www <Directory /var/www> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted allow from all </Directory> <Location /home> Order Allow,Deny Allow from all </Location> Alias /home "/var/www/example.com/html" <Directory /var/www/example.com/html> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ScriptAlias /cgi-bin /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # RewriteEngine On # RewriteRule ^/?(/.*)?$ %{DOCUMENT_ROOT}/example.com/html/$1 [L] <Location /wiki> Order Allow,Deny Allow from all </Location> #<Directory /> # Options FollowSymLinks # AllowOverride None # Order allow,deny # allow from all #</Directory> Alias /wiki "/var/www/mediawiki/index.php" # Alias /wiki/load.php "/var/www/mediawiki/load.php" Alias /wiki/images "/var/www/mediawiki/images" <Directory /var/www/mediawiki> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> <Directory /var/www/mediawiki/images> Options -Indexes </Directory> Include /etc/mediawiki/mediawiki.conf # RewriteEngine On # RewriteRule ^/?mediawiki(/.*)?$ %{DOCUMENT_ROOT}/mediawiki/index.php [L] </VirtualHost>
That is my LocalSettings.php:
<?php # This file was automatically generated by the MediaWiki 1.31.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 = "examplewiki"; $wgMetaNamespace = "examplewiki"; ## 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://www.example.com:8080"; ## Die Zeile stammt aus dem Test, das Wiki aus dem Internet erreichen ## zu können mit der "example.com.test.conf" für Apache: $wgServer = "http://example.com"; $wgScriptPath = "/mediawiki"; #$wgLoadScript = "/mediawiki/load.php"; $wgArticlePath = "/wiki/$1"; $wgUsePathInfo = false; $wgDebugLogFile = "/var/log/mediawiki/example.test5.log"; #wfErrorLog( "An error occurred.\n", '/var/log/mediawiki/my-custom-debug.log' ); ## The URL path to static resources (images, scripts, etc.) $wgResourceBasePath = $wgScriptPath; ## The URL path to the logo. Make sure you change this from the default, ## or else you'll overwrite your logo when you upgrade! $wgLogo = "$wgResourceBasePath/resources/assets/mediawiki.png"; ## UPO means: this is also a user preference option $wgEnableEmail = true; $wgEnableUserEmail = true; # UPO $wgEmergencyContact = "apache@www.example.com"; $wgPasswordSender = "apache@www.example.com"; $wgEnotifUserTalk = false; # UPO $wgEnotifWatchlist = false; # UPO $wgEmailAuthentication = true; ## Database settings $wgDBtype = "mysql"; $wgDBserver = "localhost"; $wgDBname = "wikidb"; $wgDBuser = "wikiuser"; $wgDBpassword = "**********"; # MySQL specific settings $wgDBprefix = ""; # MySQL table options to use during installation or update $wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary"; ## 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"; # 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 $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 publically accessible from the web. #$wgCacheDirectory = "$IP/cache"; # Site language code, should be one of the list in ./languages/data/Names.php $wgLanguageCode = "de"; $wgSecretKey = "************************************************"; # 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 = "*******************"; ## 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 = "https://creativecommons.org/licenses/by/4.0/"; $wgRightsText = "''Creative Commons'' „Namensnennung“"; $wgRightsIcon = "$wgResourceBasePath/resources/assets/licenses/cc-by.png"; # 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 = "timeless"; # Enabled skins. # The following skins were automatically enabled: wfLoadSkin( 'MonoBook' ); wfLoadSkin( 'Timeless' ); wfLoadSkin( 'Vector' ); # Enabled extensions. Most of the extensions are enabled by adding # wfLoadExtensions('ExtensionName'); # to LocalSettings.php. Check specific extension documentation for more details. # The following extensions were automatically enabled: wfLoadExtension( 'PdfHandler' ); # End of automatically generated settings. # Add more configuration options below. ## Folgende Dateitypen kann man hochaden: $wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx', 'pptx', 'ps', 'odt', 'ods', 'odp', 'odg' );
This is what $wgDebugLogFile outputs:
IP: 192.168.10.41 Start request GET /wiki HTTP HEADERS: HOST: www.example.com CONNECTION: keep-alive UPGRADE-INSECURE-REQUESTS: 1 USER-AGENT: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 ACCEPT-ENCODING: gzip, deflate ACCEPT-LANGUAGE: de-DE,de;q=0.9 [caches] cluster: APCBagOStuff, WAN: mediawiki-main-default, stash: db-replicated, message: APCBagOStuff, session: APCBagOStuff [caches] LocalisationCache: using store LCStoreDB [DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: calling initLB() before first connection. [DBReplication] Cannot use ChronologyProtector with EmptyBagOStuff. [DBReplication] Wikimedia\Rdbms\LBFactory::getChronologyProtector: using request info { "IPAddress": "192.168.10.41", "UserAgent": "Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/87.0.4280.88 Safari\/537.36", "ChronologyProtection": false, "ChronologyPositionIndex": 0 } [DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: connected to database 0 at 'localhost'. [CryptRand] 0 bytes of randomness leftover in the buffer. [session] SessionBackend "rp7s42bde18ddtt4frj91b53qe1av97b" is unsaved, marking dirty in constructor [session] SessionBackend "rp7s42bde18ddtt4frj91b53qe1av97b" save: dataDirty=1 metaDirty=1 forcePersist=0 [cookie] already deleted setcookie: "wikidb_session", "", "1576516093", "/", "", "", "1" [cookie] already deleted setcookie: "wikidbUserID", "", "1576516093", "/", "", "", "1" [cookie] already deleted setcookie: "wikidbToken", "", "1576516093", "/", "", "", "1" [cookie] already deleted setcookie: "forceHTTPS", "", "1576516093", "/", "", "", "1" [MessageCache] MessageCache::load: Loading de... local cache is empty, got from global cache Title::getRestrictionTypes: applicable restrictions to [[Hauptseite]] are {edit,move} [ContentHandler] Created handler for wikitext: WikitextContentHandler MediaWiki::preOutputCommit: primary transaction round committed MediaWiki::preOutputCommit: pre-send deferred updates completed MediaWiki::preOutputCommit: LBFactory shutdown completed OutputPage::sendCacheControl: private caching; Tue, 15 Dec 2020 17:08:13 GMT ** [Pingback] Pingback::sendPingback: couldn't acquire lock [DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: connected to database 0 at 'localhost'. Request ended normally [session] Saving all sessions on shutdown [DBConnection] Wikimedia\Rdbms\{closure}: closing connection to database 'localhost'. [DBConnection] Wikimedia\Rdbms\{closure}: closing connection to database 'localhost'. IP: 192.168.10.41 Start request GET /wiki/Hauptseite HTTP HEADERS: HOST: www.example.com CONNECTION: keep-alive UPGRADE-INSECURE-REQUESTS: 1 USER-AGENT: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 ACCEPT-ENCODING: gzip, deflate ACCEPT-LANGUAGE: de-DE,de;q=0.9 [caches] cluster: APCBagOStuff, WAN: mediawiki-main-default, stash: db-replicated, message: APCBagOStuff, session: APCBagOStuff [caches] LocalisationCache: using store LCStoreDB [DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: calling initLB() before first connection. [DBReplication] Cannot use ChronologyProtector with EmptyBagOStuff. [DBReplication] Wikimedia\Rdbms\LBFactory::getChronologyProtector: using request info { "IPAddress": "192.168.10.41", "UserAgent": "Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/87.0.4280.88 Safari\/537.36", "ChronologyProtection": false, "ChronologyPositionIndex": 0 } [DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: connected to database 0 at 'localhost'. [CryptRand] 0 bytes of randomness leftover in the buffer. [session] SessionBackend "t77rer33nv4m384vlclfhpvb1fogenpv" is unsaved, marking dirty in constructor [session] SessionBackend "t77rer33nv4m384vlclfhpvb1fogenpv" save: dataDirty=1 metaDirty=1 forcePersist=0 [cookie] already deleted setcookie: "wikidb_session", "", "1576516093", "/", "", "", "1" [cookie] already deleted setcookie: "wikidbUserID", "", "1576516093", "/", "", "", "1" [cookie] already deleted setcookie: "wikidbToken", "", "1576516093", "/", "", "", "1" [cookie] already deleted setcookie: "forceHTTPS", "", "1576516093", "/", "", "", "1" Title::getRestrictionTypes: applicable restrictions to [[Hauptseite]] are {edit,move} [ContentHandler] Created handler for wikitext: WikitextContentHandler OutputPage::checkLastModified: client did not send If-Modified-Since header [MessageCache] MessageCache::load: Loading de... local cache is empty, got from global cache Unstubbing $wgParser on call of $wgParser::firstCallInit from MessageCache->transform Parser: using preprocessor: Preprocessor_DOM Unstubbing $wgLang on call of $wgLang::_unstub from ParserOptions->__construct [caches] parser: APCBagOStuff Article::view using parser cache: yes Article::view: doing uncached parse [Preprocessor] Cached preprocessor output (key: wikidb:preprocess-xml:d1612c55c34f7cad24c22de9fc5cb36d:0) [Mime] MimeAnalyzer::loadFiles: loading mime types from /var/www/mediawiki/includes/libs/mime/mime.types [Mime] MimeAnalyzer::loadFiles: loading mime info from /var/www/mediawiki/includes/libs/mime/mime.info File::transform: Doing stat for mwstore://local-backend/local-thumb/2/24/mydomainLogo.png/133px-mydomainLogo.png [FileOperation] FileBackendStore::getFileStat: File mwstore://local-backend/local-thumb/2/24/mydomainLogo.png/133px-mydomainLogo.png does not exist. TransformationalImageHandler::doTransform: creating 133x104 thumbnail at /tmp/transform_b8ceaab162eb.png using scaler im TransformationalImageHandler::doTransform: returning unscaled image File::transform: Doing stat for mwstore://local-backend/local-thumb/2/24/mydomainLogo.png/133px-mydomainLogo.png TransformationalImageHandler::doTransform: creating 133x104 thumbnail at /tmp/transform_93f421a6235c.png using scaler im TransformationalImageHandler::doTransform: returning unscaled image File::transform: Doing stat for mwstore://local-backend/local-thumb/2/24/mydomainLogo.png/133px-mydomainLogo.png TransformationalImageHandler::doTransform: creating 133x104 thumbnail at /tmp/transform_5f377fc02094.png using scaler im TransformationalImageHandler::doTransform: returning unscaled image [Preprocessor] Loaded preprocessor output from cache (key: wikidb:preprocess-xml:d1612c55c34f7cad24c22de9fc5cb36d:0) Saved in parser cache with key wikidb:pcache:idhash:1-0!canonical and timestamp 20201215170813 and revision id 1631 MediaWiki::preOutputCommit: primary transaction round committed MediaWiki::preOutputCommit: pre-send deferred updates completed MediaWiki::preOutputCommit: LBFactory shutdown completed [MessageCache] MessageCache::load: Loading en... local cache is empty, global cache is expired/volatile, loading from database Title::getRestrictionTypes: applicable restrictions to [[Hauptseite]] are {edit,move} [GlobalTitleFail] MessageCache::parse called by TimelessTemplate->getUserLinks/TimelessTemplate->getPortlet/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set. SiteStats::loadAndLazyInit: reading site_stats from replica DB [GlobalTitleFail] MessageCache::parse called by TimelessTemplate->getMainNavigation/TimelessTemplate->getPortlet/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set. [GlobalTitleFail] MessageCache::parse called by TimelessTemplate->execute/TimelessTemplate->getPortlet/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set. [GlobalTitleFail] MessageCache::parse called by TimelessTemplate->getPageToolSidebar/TimelessTemplate->getPortlet/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set. [GlobalTitleFail] MessageCache::parse called by TimelessTemplate->getPageToolSidebar/TimelessTemplate->getPortlet/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set. [GlobalTitleFail] MessageCache::parse called by TimelessTemplate->getPageToolSidebar/TimelessTemplate->getPortlet/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set. [GlobalTitleFail] MessageCache::parse called by TimelessTemplate->execute/TimelessTemplate->getPortlet/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set. [GlobalTitleFail] MessageCache::parse called by TimelessTemplate->execute/TimelessTemplate->getPortlet/Message->parse/Message->toString/Message->parseText/MessageCache->parse with no title set. OutputPage::sendCacheControl: private caching; Tue, 15 Dec 2020 17:07:57 GMT ** [Pingback] Pingback::sendPingback: couldn't acquire lock [DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: connected to database 0 at 'localhost'. Request ended normally [session] Saving all sessions on shutdown [DBConnection] Wikimedia\Rdbms\{closure}: closing connection to database 'localhost'. [DBConnection] Wikimedia\Rdbms\{closure}: closing connection to database 'localhost'.
I hope you can see the problem...