After installing mediawiki, stylesheets don't load properly. Here are minimum reproduction instructions:
Using the following git repo: https://sourceforge.net/p/mediawiki-problem/code/ci/step1/tree/ starting with branch step1
,
./startup
starts the wiki, database, and reverse proxydocker container exec -ti swarm_lithia-wiki<tab> bash
to run bash in the mediawiki container- Inside the container,
mkdir lithia && mv * lithia;
moves everything to thelithia
directory so that everything can be served properly - Visit http://localhost:80/lithia in a web browser, and I see the prompt to install
During the install, I set the following settings:
- Database host
lithia-db
(matching the service name in the docker compose file) - Database name
lithia
- Database table prefix
li_
- Database username
root
- Database password
moresecurepassword
- Next
- Uncheck "Use the same account as for installation"
- Database username
lithiauser
- Database password
somesecurepassword
- Check "Create the account..."
- Continue
- Name of wiki
Lithia
- Your username:
lmat
- Password:
goodpassword
- Select "I'm bored..." then Continue then Continue
Everything looks good.
Save LocalSettings.php
in the git repository in /lithia-wiki
.
- Check out
step2
in the repo to add theLocalSettings.php
volume toswarm.yml
. - Run
./startup
again to restart the service which will undo themv
above as well as mount theLocalSettings.php
file.
Now behold, the page loads without CSS
Investigating the problem, I see the following in the browser console:
Refused to apply style from
'http://localhost/lithia/load.php?lang=en&modules=skins.vector.styles.legacy&only=styles&skin=vector'
because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict
MIME checking is enabled.
Visiting that page, http://localhost/lithia/load.php?lang=en&modules=skins.vector.styles.legacy&only=styles&skin=vector, it is loading the main page.
How should I fix this? What did I do wrong during setup?
That usually happens when MediaWiki cannot find the specified resources, often due to misconfigurations or path issues.
You need to debug
load.php
, as suggested inManual:load.php
and this threadInside your MediaWiki container, navigate to the
maintenance
folder and executeeval.php
to check if your MediaWiki environment is functioning correctly.Enter some simple MediaWiki PHP commands to see if they execute successfully.
See "The wiki appears without styles applied and images are missing":
MediaWiki's
ResourceLoader
is responsible for delivering CSS and JS. Make sure that the URLs are correctly configured. CheckLocalSettings.php
to make sure$wgScriptPath
,$wgResourceBasePath
and other URL settings are correctly set.And make sure that URL rewriting is configured correctly in your web server. That can cause unexpected behavior if incorrectly set up. Validate that the web server is properly forwarding requests to MediaWiki.
Since Docker, inspect your Dockerfile and docker-compose file for any issues that may cause this problem. File permission issue due to a host directory mount could be a problem.