Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
deb12:lamp [2024/05/23 06:12] – [WSL2 (NAT)] Bernard Condraudeb12:lamp [2025/11/17 14:53] (current) – [Create certificate for localhost] Bernard Condrau
Line 142: Line 142:
   * [[https://xdebug.org/docs/install|Xdebug: Installation]]   * [[https://xdebug.org/docs/install|Xdebug: Installation]]
   * [[https://xdebug.org/docs/all_settings|Xdebug: all settings]]   * [[https://xdebug.org/docs/all_settings|Xdebug: all settings]]
 +  * [[https://xdebug.org/docs/upgrade_guide|Upgrading from Xdebug 2 to 3]]
  
 ===== MariaDB 10.11.6 Installation ===== ===== MariaDB 10.11.6 Installation =====
Line 177: Line 178:
   * Your Linux box runs within a Hyper-V Virtual Machine   * Your Linux box runs within a Hyper-V Virtual Machine
   * You can access the Windows host through the IP address stored in ''/etc/resolv.conf''   * You can access the Windows host through the IP address stored in ''/etc/resolv.conf''
-  * ''xdebug.client''_host must be configured to use this IP address. Separate the directive from the xdebug settings by copying it into a separate file to be loaded after the xdebug settings, then run a script before starting or restarting the LAMP server:<code>#!/bin/bash+  * ''xdebug.client''_host must be configured to use this IP address. Separate the directive from the xdebug settings by copying it into a separate file to be loaded after the xdebug settings, then run a script to update this IP address before starting or restarting the LAMP server:<code>#!/bin/bash
 IP=$(ip route show | grep -i default | awk '{ print $3}') IP=$(ip route show | grep -i default | awk '{ print $3}')
 INI="/home/bco/conf/xdebug.host.ini" INI="/home/bco/conf/xdebug.host.ini"
 echo -e "[Xdebug]" > $INI echo -e "[Xdebug]" > $INI
 echo -e "xdebug.client_host=$IP" >> $INI</code> echo -e "xdebug.client_host=$IP" >> $INI</code>
 +  * Check the xdebug logfile with ''tail -f /path/to/log/xdebug.log'' until this is working properly
  
- +=== Windows host IP address === 
-  * WSL2: run the following command in PowerShell:<code>New-NetFirewallRule -DisplayName "xdebug" -InterfaceAlias "vEthernet (WSL (Hyper-V firewall))" -Direction Inbound -Protocol TCP -LocalPort 9003 -Action Allow</code> +  * Alternatively you could use the Windows host IP address (feasible if it remains the same through re-boots) in which case you need to add a firewall rule to allow access through the xdebug port. Command to run in an elevated PowerShell:<code>New-NetFirewallRule -DisplayName "xdebug" -InterfaceAlias "vEthernet (WSL (Hyper-V firewall))" -Direction Inbound -Protocol TCP -LocalPort 9003 -Action Allow</code> 
-  * Check with:<code>Get-NetFirewallRule -DisplayName "xdebug"+  * Commands to check or remove the firewall rule:<code>Get-NetFirewallRule -DisplayName "xdebug"
 Remove-NetFirewallRule -DisplayName "xdebug"</code> Remove-NetFirewallRule -DisplayName "xdebug"</code>
-  * Check logfile with tail -f /path/to/log/xdebug.log 
  
 ==== WSL2 (mirrored) ==== ==== WSL2 (mirrored) ====
-  * WSL2 runs networking in ''NAT'' or ''mirrored'' mode +  * WSL2 set to ''mirrored'' networking mode 
-  * To enabled ''mirrored'' mode, save the following content as file ''.wslconfig'' into folder ''C:\Users\<user>''<code>[wsl2] +  * This networking mode is available for Windows 11  23H2 and later 
-networkingMode=mirrored</code+  * To enabled ''mirrored'' mode, save the following content as file ''.wslconfig'' into folder ''C:\Users\<user>'' on your Windows host<file>[wsl2] 
-  * The following instructions apply to the default ''NAT'' mode +networkingMode=mirrored</file
-  * WSL2: run the following command in PowerShell:<code>New-NetFirewallRule -DisplayName "xdebug" -InterfaceAlias "vEthernet (WSL (Hyper-V firewall))" -Direction Inbound -Protocol TCP -LocalPort 9003 -Action Allow</code> +  * Your Linux box runs within a Hyper-V Virtual Machine 
-  * Check with:<code>Get-NetFirewallRule -DisplayName "xdebug+  * You can access the Windows host through the IP address ''127.0.0.1'', no firewall rule is necessary 
-Remove-NetFirewallRule -DisplayName "xdebug"</code> +  * ''xdebug.client''_host must be configured to use this IP address 
-  * Check logfile with tail -f /path/to/log/xdebug.log +  * Check the xdebug logfile with ''tail -f /path/to/log/xdebug.log'' until this is working properly 
 +  * Note that WSL in ''mirrored'' mode is less secure and can be directly accessed from your LAN
 ==== Links ==== ==== Links ====
   * [[https://gist.github.com/SomajitDey/68e8cd639e3bf592bded035630cf86ec|How to forward WSL2 port to Windows port and vice versa]]   * [[https://gist.github.com/SomajitDey/68e8cd639e3bf592bded035630cf86ec|How to forward WSL2 port to Windows port and vice versa]]
-  * [[https://xdebug.org/docs/upgrade_guide|Upgrading from Xdebug 2 to 3]] 
  
 ===== SSL for localhost ===== ===== SSL for localhost =====
Line 238: Line 238:
     * You can check the domain names included in the original certificate:<code>openssl x509 -text < $CERT_FILE</code>     * You can check the domain names included in the original certificate:<code>openssl x509 -text < $CERT_FILE</code>
  
 +==== Trust localhost certificate on Windows 11 ====
 +  * Run ''certmgr.msc'', then select //Trusted Root Certification Authorities//
 +  * Right-click on //Certificates// and select //All Tasks --> Import...//. Import the ''RootCA.crt'' file and accept all questions with default answer.
 ==== Links ==== ==== Links ====
   * [[https://www.sslshopper.com/ssl-checker.html|SSL Checker]]   * [[https://www.sslshopper.com/ssl-checker.html|SSL Checker]]