Manual:Running MediaWiki on Windows Subsystem for Linux/de

From Linux Web Expert

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This is documentation for running MediaWiki on Windows 10 with the Windows Subsystem for Linux (WSL). See Handbuch:Ausführen von MediaWiki auf Windows for documentation on running MediaWiki directly on Windows.

Windows 10 includes a Linux compatibility layer, the Windows Subsystem for Linux, designed to help web developers needing a Linux/Unix development environment on a Windows computer. This can be used to run MediaWiki as if on a Linux machine, with less overhead and better integration compared to setting up and running a virtual machine.

This may be good option for Windows 10 laptops with limited RAM and CPU resources. However, WSL requires a 64-bit edition of Windows 10 (x64 or ARM64), and cannot run on 32-bit x86 Windows 10 installations.

Security notes

MediaWiki is a web application, and following these directions will set up a web server that runs on your computer and can be exposed to other computers on the network. In particular, note that PHP and other Linux code running in the web server may have access to your Windows C:\ drive and may be able to read or modify files or run Windows programs.

It is strongly recommended to use this for development purposes only, not for server deployments, and to limit network access to the web server to avoid accidentally opening anything to the network. Führe nur MediaWiki und Erweiterungen, die du vertraust, aus.

WSL-Versionen

There are two major versions of WSL available: the original which emulates the Linux kernel ABI as a Windows driver, and the newer WSL2 which uses a specialized Hyper-V virtual machine to run a native Linux kernel. While MediaWiki should work with WSL1, the May 2020 Update introduces WSL 2 as an alternative. It is possible to freely upgrade/downgrade from WSL1 and WSL2.

WSL2 is compatible with more software, but can complicate some integration scenarios a little as the VM has its own IP address separate from localhost. (Servers are port-forwarded to localhost, so this mostly works ok for setting up a web server.)

Note that WSL2 requires hardware support for virtualization and uses Hyper-V under the hood, but is available on Windows 10 Home as well as Windows 10 Pro. WSL1 benötigt keine Virtualisierung. This will make it easier for developers to install on existing machines without spending money on a Pro upgrade, but may have compatibility problems with other VM software like VirtualBox (v6.0 is the earliest version that can coexist with Hyper-V based products).

Einrichtung

  • Gehe in die Systemsteuerung, Programme und Features, dann den Link "Windows-Features aktivieren oder deaktivieren" auf der linken Seite, oder führe C:\Windows\System32\OptionalFeatures.exe aus.
    • Check "Windows Subsystem for Linux" and, for WSL2, "Virtual Machine Platform"
    • lass es installieren und starte neu
  • Go to 'Microsoft Store' and search for the latest "Ubuntu" Linux distribution
    • installiere es!
    • Debian ist auch verfügbar, könnte aber in einigen Punkten etwas anders sein.
  • Click on the "Ubuntu" icon in Start menu or enter wsl from a PowerShell session, (notice how the prompt changes from Windows to Linux style).
    • follow the on-screen prompts about setting up a Linux username and password
    • lass es extrahieren

WSL-Einrichtung

To use WSL2 mode, exit and run in a PowerShell session:

  • wsl --set-version Ubuntu 2

This may take a few minutes to convert filesystems.

To verify which version of WSL is in use do:

  • wsl -l -v

Dependency setup

First, ensure the system image is up to date: run sudo apt update && sudo apt upgrade -y in the Ubuntu terminal. This may take a few minutes after first installation.

Install deps: sudo apt install apache2 composer git git-review imagemagick mysql-client mysql-server php php-apcu php-cli php-gd php-intl php-mbstring php-mysql php-xml zip

Running services

You may have to manually start up services:

  • sudo service mysql start
  • sudo service apache2 start
    • on WSL1 this may prompt Windows Firewall about the listening port. Allow it, but consider limiting to "private" networks for safety.

You may have to jump through some hoops to set the root password on mysql:

  • Führe mysql als root aus:
    • sudo mysql
  • Führe in der mysql-Terminal aus:
    • use mysql;
    • alter user 'root'@'localhost' identified by 'your-password-here'; - If that fails try update user set authentication_string=password('your-password-here'), plugin='mysql_native_password' where user='root'; instead.
    • create user 'your_name'@'localhost' identified by 'your-password-here';
    • create database 'database_name'; - This must match with the wiki database in the install process
    • grant all on 'database_name'.* to 'your_name'@'localhost';
    • flush privileges;
    • exit
  • Now you can use username 'root', password 'your-password-here' when logging in from the installer

MediaWiki-Einrichtung

Clone things from git as you would on a Linux server.

Apache on Ubuntu is set by default to point at /var/www/html for the docroot, you can create a dir under there to check out or reconfigure Apache with a custom path. I recommend /var/www/html/w for consistency with convention that /w/index.php is the main script path.

Erweiterungen

Zum Beispiel (von skins/):

Don't forget to run composer update --no-dev in the MW directory, and for any extension dirs that require it.

Run the web installer in a browser at http://localhost/w/; use your name and database here for installation.

When the installer prompts you to download LocalSettings.php at the end, save it into \\wsl$\Ubuntu\var\www\html\w or equivalent and you will be able to access your wiki!

Job queue

You may want or need to manually run the job queue runner.

Ideally this should be done via the web server, but in a pinch you can fire up the Ubuntu terminal and run:

  • cd /var/www/html/
  • php maintenance/runJobs.php

Other configuration

For the most part the WSL environment will look like any other Ubuntu or Debian system, except that services won't automatically start and must be manually run on every boot. See Running MediaWiki on Debian or Ubuntu for general instructions on running on these operation systems.

Dateien bearbeiten

From the Windows side you can access Linux files in \\wsl$\Ubuntu, so Windows text editors that are ok with Unix line endings can be used to work with your code and config.

Visual Studio Code also has a WSL remoting extension which can integrate more directly with the WSL environment, which might be good for using PHP linting in the editor.

Or, you can use your favorite terminal-based editors.