LAMP Inside WSL2

Running Apache, MySQL and PHP Inside WSL2

With systemd 142,543 running, the distribution behaves like the server in apt and dnf. Ubuntu 26.04 225 's archive has Apache 2.4.66 129 and PHP 8.5: sudo apt install apache2 php8.5 php8.5-fpm php8.5-mysql libapache2-mod-php8.5. Its MySQL 524 is 8.4 LTS, so take 9.7 LTS from Oracle's apt repository, which has a resolute suite: install mysql-apt-config (from dev.mysql.com/downloads/repo/apt) with dpkg -i, pick mysql-9.7-lts, then sudo apt update && sudo apt install mysql-server. MySQL explains the choice.

Checking systemd and the native stack inside Ubuntu-26.04Shell
whoami; systemctl is-system-running
apache2 -v | head -1
php -v | head -1
sudo mysql -Ne "SELECT VERSION()"
systemctl is-enabled apache2 mysql php8.5-fpm | paste -sd' '
Output
dev
running
Server version: Apache/2.4.66 (Ubuntu)
PHP 8.5.4 (cli) (built: Sep  2 2026 14:42:18) (NTS)
9.7.2
enabled enabled enabled

The services start with the distribution, at the first wsl command after Windows boots. In .wslconfig, instanceIdleTimeout=-1 under [general] stops WSL 6 shutting an idle distribution after 15 seconds, and memory=4GB under [wsl2] caps the VM, which may otherwise take half your RAM.