MediaWiki Stylesheet Not Loading (load.php shows main page)

230 Views Asked by At

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,

  1. ./startup starts the wiki, database, and reverse proxy
  2. docker container exec -ti swarm_lithia-wiki<tab> bash to run bash in the mediawiki container
  3. Inside the container, mkdir lithia && mv * lithia; moves everything to the lithia directory so that everything can be served properly
  4. 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 the LocalSettings.php volume to swarm.yml.
  • Run ./startup again to restart the service which will undo the mv above as well as mount the LocalSettings.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?

1

There are 1 best solutions below

2
On

because its MIME type ('text/html') is not a supported stylesheet MIME type

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 in Manual:load.php and this thread

Inside your MediaWiki container, navigate to the maintenance folder and execute eval.php to check if your MediaWiki environment is functioning correctly.

cd /path/to/mediawiki/maintenance
php eval.php

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. Check LocalSettings.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.