結局wslの再起動で解決したが、以下その経過ログ
作業ログ
service自体は上手く立っているようだ
$ service apache2 status
* apache2 is running
$ curl -I localhost
curl: (7) Couldn't connect to server
$ curl -I 0.0.0.0
curl: (7) Couldn't connect to server
service apache2 stop
やstart
で再起動などを繰り返してみた、error_logには起動の旨書かれている
$ tail -f /var/log/apache2/error.log
[Mon Aug 29 09:36:31.687131 2022] [mpm_prefork:notice] [pid 300] AH00163: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations
[Mon Aug 29 09:36:31.687177 2022] [core:notice] [pid 300] AH00094: Command line: '/usr/sbin/apache2'
[Mon Aug 29 09:36:52.204486 2022] [mpm_prefork:notice] [pid 300] AH00169: caught SIGTERM, shutting down
[Mon Aug 29 09:37:08.792250 2022] [mpm_prefork:notice] [pid 377] AH00163: Apache/2.4.52 (Ubuntu) configured -- resuming normal operations
[Mon Aug 29 09:37:08.792293 2022] [core:notice] [pid 377] AH00094: Command line: '/usr/sbin/apache2'
lsofでhttp(:80)ポート確認、問題なく確保できている
$ sudo lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 377 root 3u IPv6 17054 0t0 TCP *:http (LISTEN)
apache2 380 www-data 3u IPv6 17054 0t0 TCP *:http (LISTEN)
apache2 381 www-data 3u IPv6 17054 0t0 TCP *:http (LISTEN)
apache2 382 www-data 3u IPv6 17054 0t0 TCP *:http (LISTEN)
apache2 383 www-data 3u IPv6 17054 0t0 TCP *:http (LISTEN)
apache2 384 www-data 3u IPv6 17054 0t0 TCP *:http (LISTEN)
ネットワークを見てみる、wslはifconfig
ではなくip
で見る 見たところinet設定が無い
$ ip address show
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 72:e4:06:4e:49:0e brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 4a:5d:49:a6:df:ab brd ff:ff:ff:ff:ff:ff
4: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
5: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:15:5d:10:0f:49 brd ff:ff:ff:ff:ff:ff
wsl再起動する、Win側のコマンドプロンプトで以下実行
C:\> wsl --shutdown
起動はubuntuターミナルを起動すればOK、ネットワークを見るとちゃんとloopbackのinetが復活している
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 0e:c6:f7:f3:01:85 brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether d2:da:3f:4b:54:fb brd ff:ff:ff:ff:ff:ff
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:15:5d:10:06:fb brd ff:ff:ff:ff:ff:ff
inet 172.28.230.27/20 brd 172.28.239.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::215:5dff:fe10:6fb/64 scope link
valid_lft forever preferred_lft forever
5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
service apache2を再起動してcurlできるようになった
$ sudo service apache2 start
* Starting Apache httpd web server apache2
$ curl http://localhost
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
...