Windows10をUbuntuのコマンドで操作する! 人気のあるプログラム言語PHPのインストール!

スポンサーリンク

コンテンツ

bash on Windows10を使用できるようにする方法と注意事項は、以下の記事にまとめてあります!正式名称は「bash on Ubuntu on Windows10」です。

Windows10をUbuntuのコマンドで操作する! 1.使えるように準備をする(開発者モードを有効にする)!

64ビット版 Windows10のインストール「bash on Windows10」と呼ばれている機能です。2016年5月現在、ベータ版です。Windows10インサイダー プレビュー版が必要です。通常のWindows10では利用できません

Windows10をUbuntuのコマンドで操作する! 2.「bash on Windows10」を有効にする!

「bash on Windows10」のインストール2016年5月現在、ベータ版です。Windows10インサイダー プレビュー版が必要です。通常のWindows10では利用できません。また、64ビット版Windows10でないと使用できま

Windows10をUbuntuのコマンドで操作する! 3.「bash on Windows10」のインストール!

「bash on Windows10」のインストール2016年5月現在、ベータ版です。Windows10インサイダー プレビュー版が必要です。通常のWindows10では利用できません。また、64ビット版Windows10でないと使用できま

Windows10をUbuntuのコマンドで操作する! 4.bash on Windows10(ばっしゅ おん うぃんどうずてん)を起動する!

前回までの記事この記事はbash on Windows10を使えるようにするまでの記事の4番目です。1-3番目の記事は以下をどうぞ!bash on Windows10の起動bash on Windows10を起動するには以下のようにします。

PHPのインストール

「bash on Windows10」でPHPをインストールするには、以下のコマンドを実行します

sudo apt-get install php5

それでは実行してみましょう。

t@DESKTOP-1QGFR8O:~$ sudo apt-get install php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfreetype6 os-prober
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libapache2-mod-php5 php5-cli php5-common php5-json php5-readline
Suggested packages:
  php-pear php5-user-cache
The following NEW packages will be installed:
  libapache2-mod-php5 php5 php5-cli php5-common php5-json php5-readline
0 upgraded, 6 newly installed, 0 to remove and 25 not upgraded.
Need to get 4,863 kB of archives.
After this operation, 20.5 MB of additional disk space will be used.
Abort. want to continue? [Y/n]  Y
t@DESKTOP-1QGFR8O:~$ sudo apt-get install php5
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfreetype6 os-prober
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libapache2-mod-php5 php5-cli php5-common php5-json php5-readline
Suggested packages:
  php-pear php5-user-cache
The following NEW packages will be installed:
  libapache2-mod-php5 php5 php5-cli php5-common php5-json php5-readline
0 upgraded, 6 newly installed, 0 to remove and 25 not upgraded.
Need to get 4,863 kB of archives.
After this operation, 20.5 MB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main php5-json amd64 1.3.2-2build1 [34.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty-updates/main php5-common amd64 5.5.9+dfsg-1ubuntu4.16 [445 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty-updates/main php5-cli amd64 5.5.9+dfsg-1ubuntu4.16 [2,164 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ trusty-updates/main php5-readline amd64 5.5.9+dfsg-1ubuntu4.16 [12.1 kB]
Get:5 http://archive.ubuntu.com/ubuntu/ trusty-updates/main libapache2-mod-php5 amd64 5.5.9+dfsg-1ubuntu4.16 [2,207 kB]
Get:6 http://archive.ubuntu.com/ubuntu/ trusty-updates/main php5 all 5.5.9+dfsg-1ubuntu4.16 [1,306 B]
Fetched 4,863 kB in 16s (295 kB/s)
E: Can not write log (Is /dev/pts mounted?) - openpty (2: No such file or directory)
Selecting previously unselected package php5-json.
(Reading database ... 27289 files and directories currently installed.)
Preparing to unpack .../php5-json_1.3.2-2build1_amd64.deb ...
Unpacking php5-json (1.3.2-2build1) ...
Selecting previously unselected package php5-common.
Preparing to unpack .../php5-common_5.5.9+dfsg-1ubuntu4.16_amd64.deb ...
Unpacking php5-common (5.5.9+dfsg-1ubuntu4.16) ...
Selecting previously unselected package php5-cli.
Preparing to unpack .../php5-cli_5.5.9+dfsg-1ubuntu4.16_amd64.deb ...
Unpacking php5-cli (5.5.9+dfsg-1ubuntu4.16) ...
Selecting previously unselected package php5-readline.
Preparing to unpack .../php5-readline_5.5.9+dfsg-1ubuntu4.16_amd64.deb ...
Unpacking php5-readline (5.5.9+dfsg-1ubuntu4.16) ...
Selecting previously unselected package libapache2-mod-php5.
Preparing to unpack .../libapache2-mod-php5_5.5.9+dfsg-1ubuntu4.16_amd64.deb ...
Unpacking libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.16) ...
Selecting previously unselected package php5.
Preparing to unpack .../php5_5.5.9+dfsg-1ubuntu4.16_all.deb ...
Unpacking php5 (5.5.9+dfsg-1ubuntu4.16) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up php5-json (1.3.2-2build1) ...
php5_invoke: Enable module json for apache2 SAPI
php5_invoke: Enable module json for cli SAPI
Setting up php5-common (5.5.9+dfsg-1ubuntu4.16) ...

Creating config file /etc/php5/mods-available/pdo.ini with new version
php5_invoke: Enable module pdo for apache2 SAPI
php5_invoke: Enable module pdo for cli SAPI

Creating config file /etc/php5/mods-available/opcache.ini with new version
php5_invoke: Enable module opcache for apache2 SAPI
php5_invoke: Enable module opcache for cli SAPI
Setting up php5-cli (5.5.9+dfsg-1ubuntu4.16) ...
update-alternatives: using /usr/bin/php5 to provide /usr/bin/php (php) in auto mode

Creating config file /etc/php5/cli/php.ini with new version
php5_invoke json: already enabled for cli SAPI
php5_invoke opcache: already enabled for cli SAPI
php5_invoke pdo: already enabled for cli SAPI
Setting up php5-readline (5.5.9+dfsg-1ubuntu4.16) ...

Creating config file /etc/php5/mods-available/readline.ini with new version
php5_invoke: Enable module readline for apache2 SAPI
php5_invoke: Enable module readline for cli SAPI
Setting up libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.16) ...

Creating config file /etc/php5/apache2/php.ini with new version
php5_invoke json: already enabled for apache2 SAPI
php5_invoke opcache: already enabled for apache2 SAPI
php5_invoke pdo: already enabled for apache2 SAPI
php5_invoke readline: already enabled for apache2 SAPI
Module mpm_event disabled.
Enabling module mpm_prefork.
apache2_switch_mpm Switch to prefork
runlevel:/var/run/utmp: No such file or directory
invoke-rc.d: policy-rc.d denied execution of restart.
apache2_invoke: Enable module php5
runlevel:/var/run/utmp: No such file or directory
invoke-rc.d: policy-rc.d denied execution of restart.
Setting up php5 (5.5.9+dfsg-1ubuntu4.16) ...

PHPのバージョンの確認

PHPのバージョンの確認をするには、以下のコマンドを実行します

php --version

それでは実行してみましょう。

t@DESKTOP-1QGFR8O:~$ php --version
PHP 5.5.9-1ubuntu4.16 (cli) (built: Apr 20 2016 14:31:27)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

PHP バージョン5.5.9が使用できるようです。