๐Ÿง Instalaciรณn WSL Debian

Objetivo: Preparar un entorno de trabajo en WSL Debian (Apache2, PHP 8.4, MariaDB y phpMyAdmin) para nuestras pรกginas web y para nuestros proyectos con ESP32.

๐Ÿ—‘๏ธ Paso 0: Desinstalar WSL y Debian (opcional)

๐Ÿ“‹ Ejecutar desde PowerShell como Administrador solo si quieres quitar Debian y volver a instalar desde cero.

Ver quรฉ distros tienes

wsl --list --verbose
โš ๏ธ IMPORTANTE:
  • Comprueba que el nombre sea Debian (como en la lista).
  • Se borra todo lo instalado dentro de Debian (Apache, PHP, MariaDB, etc.).

Apagar WSL y quitar Debian

wsl --shutdown
wsl --unregister Debian

๐Ÿš€ Paso 1: Instalar WSL y Debian

๐Ÿ“‹ Ejecutar desde PowerShell como Administrador:

Habilitar WSL en Windows

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
โš ๏ธ IMPORTANTE:
  • Ejecutar ambos comandos por separado
  • Esperar a que cada comando termine completamente
  • Reiniciar el sistema despuรฉs de ejecutar ambos comandos

Instalar Debian

wsl --install -d Debian
โš ๏ธ IMPORTANTE:
  • Crear usuario: me
  • Contraseรฑa: me
  • NOTA.- Al escribir la contraseรฑa, no se verรก nada en la pantalla, solo se escribirรก.
โœ… Cuando termine la instalaciรณn de Debian, cierra la ventana de PowerShell.

Abrir Debian

๐Ÿ” Buscar: Teclea "Debian"
๐ŸชŸ Tecla Windows y pinchar en el icono de ๐Ÿ”ด Debian

Se abrirรก una ventana de Debian donde se debe ejecutar los siguientes comandos:

๐Ÿ”ง Paso 2: Configurar Debian

sudo apt update && sudo apt upgrade -y
sudo apt install apache2 -y
sudo chown -R $USER:$USER /var/www/html
sudo apt install -y gnupg apt-transport-https ca-certificates curl
curl -fsSL https://packages.sury.org/php/apt.gpg | sudo gpg --dearmor -o /usr/share/keyrings/sury-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/sury-archive-keyring.gpg] https://packages.sury.org/php/ bookworm main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update && sudo apt upgrade -y
sudo apt install -y php8.4
php -v
โš ๏ธ Repositorios Debian: hace falta el repositorio oficial de Debian para librerรญas como libzip4 y libavif15. Sin esto fallan las extensiones zip y gd.
printf '%s\n' 'deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware' 'deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware' 'deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware' | sudo tee /etc/apt/sources.list
sudo apt update
sudo apt install -y libzip4 libavif15
sudo apt install -y php8.4-{cli,fpm,mysql,mbstring,curl,xml,zip,bcmath,gd}
sudo apt install mariadb-server mariadb-client -y
mysql --version
sudo apt install phpmyadmin -y
sudo a2enconf phpmyadmin
sudo systemctl reload apache2
sudo apt install -y curl wget git vim nano htop tree unzip rsync openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
sudo mariadb

MariaDB [(none)]>

ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password USING PASSWORD('me');
FLUSH PRIVILEGES;
quit
sudo chown -R $USER:$USER /var/www/html