Linux Windows

Windows 10 Creators UpdateでApache on Ubuntu on Windows が出来る!最高ですね。

はじめに

くどうです。

Windows 10 Creators Updateが来ました!
さてUbuntu on Windowsも日本語入力可能など、いろいろ進化したようです。

しかし、インフラ屋にとってそこは重要じゃないです。

ping が打てて httpdが起動することが最高なのです。
今回のUpdateで出来るようになったようです!!!

では、見ていきましょう。

ping を試す。

以前は

ping: icmp open socket: Socket type not supported

とエラーが出てましたか

打てます!

root@doraemon:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=59 time=6.66 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=59 time=6.02 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 6.026/6.346/6.666/0.320 ms

最高ですね!!!

httpd ( Apache2 )

いたって簡単です。
apt-getでインストールします。

root@doraemon:~# apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap
Suggested packages:
  apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap
0 upgraded, 7 newly installed, 0 to remove and 57 not upgraded.
Need to get 1,267 kB of archives.
After this operation, 5,244 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ trusty/main libapr1 amd64 1.5.0-1 [85.1 kB]
Get:2 http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ trusty/main libaprutil1 amd64 1.5.3-1 [76.4 kB]
Get:3 http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ trusty/main libaprutil1-dbd-sqlite3 amd64 1.5.3-1 [10.5 kB]
Get:4 http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ trusty/main libaprutil1-ldap amd64 1.5.3-1 [8,634 B]
Get:5 http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ trusty-updates/main apache2-bin amd64 2.4.7-1ubuntu4.13 [839 kB]
Get:6 http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ trusty-updates/main apache2-data all 2.4.7-1ubuntu4.13 [160 kB]
Get:7 http://ftp.jaist.ac.jp/pub/Linux/ubuntu/ trusty-updates/main apache2 amd64 2.4.7-1ubuntu4.13 [87.4 kB]
Fetched 1,267 kB in 0s (1,416 kB/s)
Selecting previously unselected package libapr1:amd64.
(Reading database ... 169938 files and directories currently installed.)
Preparing to unpack .../libapr1_1.5.0-1_amd64.deb ...
Unpacking libapr1:amd64 (1.5.0-1) ...
Selecting previously unselected package libaprutil1:amd64.
Preparing to unpack .../libaprutil1_1.5.3-1_amd64.deb ...
Unpacking libaprutil1:amd64 (1.5.3-1) ...
Selecting previously unselected package libaprutil1-dbd-sqlite3:amd64.
Preparing to unpack .../libaprutil1-dbd-sqlite3_1.5.3-1_amd64.deb ...
Unpacking libaprutil1-dbd-sqlite3:amd64 (1.5.3-1) ...
Selecting previously unselected package libaprutil1-ldap:amd64.
Preparing to unpack .../libaprutil1-ldap_1.5.3-1_amd64.deb ...
Unpacking libaprutil1-ldap:amd64 (1.5.3-1) ...
Selecting previously unselected package apache2-bin.
Preparing to unpack .../apache2-bin_2.4.7-1ubuntu4.13_amd64.deb ...
Unpacking apache2-bin (2.4.7-1ubuntu4.13) ...
Selecting previously unselected package apache2-data.
Preparing to unpack .../apache2-data_2.4.7-1ubuntu4.13_all.deb ...
Unpacking apache2-data (2.4.7-1ubuntu4.13) ...
Selecting previously unselected package apache2.
Preparing to unpack .../apache2_2.4.7-1ubuntu4.13_amd64.deb ...
Unpacking apache2 (2.4.7-1ubuntu4.13) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Processing triggers for ureadahead (0.100.0-16) ...
Processing triggers for ufw (0.34~rc-0ubuntu2) ...
Setting up libapr1:amd64 (1.5.0-1) ...
Setting up libaprutil1:amd64 (1.5.3-1) ...
Setting up libaprutil1-dbd-sqlite3:amd64 (1.5.3-1) ...
Setting up libaprutil1-ldap:amd64 (1.5.3-1) ...
Setting up apache2-bin (2.4.7-1ubuntu4.13) ...
Setting up apache2-data (2.4.7-1ubuntu4.13) ...
Setting up apache2 (2.4.7-1ubuntu4.13) ...
Enabling module mpm_event.
Enabling module authz_core.
Enabling module authz_host.
Enabling module authn_core.
Enabling module auth_basic.
Enabling module access_compat.
Enabling module authn_file.
Enabling module authz_user.
Enabling module alias.
Enabling module dir.
Enabling module autoindex.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module filter.
Enabling module deflate.
Enabling module status.
Enabling conf charset.
root@doraemon:~# service apache2 start
 * Starting web server apache2                                                                                          AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
[Wed May 03 03:11:38.962489 2017] [core:warn] [pid 1326:tid 140608220039040] (92)Protocol not available: AH00076: Failed to enable APR_TCP_DEFER_ACCEPT
*
root@doraemon:~# service apache2 status
 * apache2 is running

いいですね!
動いてますね。

netstatでは何も表示されません。

root@doraemon:~# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   Path

psでプロセス確認してみます。

root@doraemon:~# ps aux | grep apache2
root      1327  0.0  0.0 130144  2276 ?        Ss   03:11   0:00 /usr/sbin/apache2 -k start
www-data  1330  0.0  0.0 417268  1648 ?        Sl   03:11   0:00 /usr/sbin/apache2 -k start
www-data  1331  0.0  0.0 417268  1652 ?        Sl   03:11   0:00 /usr/sbin/apache2 -k start
root      1399  0.0  0.0  72060   984 tty1     S    03:15   0:00 grep --color=auto apache2

起動はしているようなので実際に確認してみます。

root@doraemon:~# curl 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">
  <!--
    Modified from the Debian original for Ubuntu
    Last updated: 2014-03-19
    See: https://launchpad.net/bugs/1288690
  -->

以下省略

やっぱろブラウザから見たいですよね。
はい、見れます。
localhostにアクセスします。

おおおおおおおおおおおおおおおおおおおおおおおおお!

まとめ

Update前にはできなかったことが、Ubuntu on Windowsで様々出来るようになります。そう1台2役のサーバーが構築できるということです。
クラウド上のサーバー一台でWindowsとUbuntuが動作することを意味します。
すげぇwktkしますね!いろいろ試していきたいと思います。

ではでは

-Linux, Windows
-