.png)
Я нахожусь в процессе настройки WSL на Windows для работы с PHP-вещями с моим PHPStorm. Запустил конфигурацию, установил Apache и PHP. Для проверки я открываю браузер на localhost
, он работает, а на 127.0.0.1
— нет.
Мне нужно, чтобы он работал, чтобы иметь возможность настроить отладку xdebug через переадресацию портов. Мне не удалось сделать это с localhost, хотя я довольно легко привык делать это на моей другой машине (Linux), где я работаю с docker.
Изнутри моего Ubuntu:
~$ cat /etc/hosts
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateHosts = false
127.0.0.1 localhost
127.0.1.1 JB-PC.localdomain JB-PC
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Из Windows:
C:\WINDOWS\system32>ipconfig
Configuration IP de Windows
Carte Ethernet Ethernet :
Suffixe DNS propre à la connexion. . . : Home
Adresse IPv6 de liaison locale. . . . .: fe80::f04e:ae2b:40b9:3d82%6
Adresse IPv4. . . . . . . . . . . . . .: 10.0.0.8
Masque de sous-réseau. . . . . . . . . : 255.255.255.0
Passerelle par défaut. . . . . . . . . : 10.0.0.138
Carte Ethernet vEthernet (WSL) :
Suffixe DNS propre à la connexion. . . :
Adresse IPv6 de liaison locale. . . . .: fe80::68c3:25c9:588a:a957%17
Adresse IPv4. . . . . . . . . . . . . .: 172.20.32.1
Masque de sous-réseau. . . . . . . . . : 255.255.240.0
Passerelle par défaut. . . . . . . . . :
localhost
пинги на ::1 :
C:\WINDOWS\system32>ping localhost
Envoi d’une requête 'ping' sur JB-PC [::1] avec 32 octets de données :
Réponse de ::1 : temps<1ms
Réponse de ::1 : temps<1ms
Réponse de ::1 : temps<1ms
Réponse de ::1 : temps<1ms
Statistiques Ping pour ::1:
Paquets : envoyés = 4, reçus = 4, perdus = 0 (perte 0%),
Durée approximative des boucles en millisecondes :
Minimum = 0ms, Maximum = 0ms, Moyenne = 0ms
и 127.0.0.1
пинги тоже:
C:\WINDOWS\system32>ping 127.0.0.1
Envoi d’une requête 'Ping' 127.0.0.1 avec 32 octets de données :
Réponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
Réponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
Réponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
Réponse de 127.0.0.1 : octets=32 temps<1ms TTL=128
Statistiques Ping pour 127.0.0.1:
Paquets : envoyés = 4, reçus = 4, perdus = 0 (perte 0%),
Durée approximative des boucles en millisecondes :
Minimum = 0ms, Maximum = 0ms, Moyenne = 0ms
Я также попробовал ответыздесь, но они не помогли.
[EDIT] Следуя совету @NotTheDr01ds, я попробовал с python. Доступ к localhost или 127.0.0.1 на порту 8080 работает так же, но доступ, http://0.0.0.0:8080/
как ни странно, не работает, хотя CLI говорит, что он обслуживает именно это:
C:\WINDOWS\system32>python3 -m http.server 8080 --bind 0.0.0.0
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...
127.0.0.1 - - [17/Apr/2021 21:20:38] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [17/Apr/2021 21:20:39] code 404, message File not found
127.0.0.1 - - [17/Apr/2021 21:20:39] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [17/Apr/2021 21:21:15] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [17/Apr/2021 21:21:15] code 404, message File not found
127.0.0.1 - - [17/Apr/2021 21:21:15] "GET /favicon.ico HTTP/1.1" 404 -
Мой виртуальный хост Apache:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /mnt/c/Users/JB/Documents/projects/bdzserver/public
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
<Directory /mnt/c/Users/JB/Documents/projects/bdzserver>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>