2017年11月1日水曜日

install PHP for Basix(Ubuntu)

UbuntuをベースにしているBasix上で、コマンドラインからPHPを使おうとしたら、下記のエラーが発生。php がインストールされていないらしい。

$ php
プログラム 'php' は以下のパッケージで見つかりました:
 * php7.0-cli
 * hhvm
次の操作を試してください: sudo apt install <選択したパッケージ>

PHPのバージョンは気にしないので、下記のようにしてphpをインストール。

$ sudo apt-get update

$ sudo apt-get install php
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています                
状態情報を読み取っています... 完了
以下のパッケージが自動でインストールされましたが、もう必要とされていません:
  libllvm3.8 libmircommon5 libsnapd-glib1 snapd snapd-login-service
これを削除するには 'sudo apt autoremove' を利用してください。
以下の追加パッケージがインストールされます:
  php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json
  php7.0-opcache php7.0-readline
提案パッケージ:
  php-pear
以下のパッケージが新たにインストールされます:
  php php-common php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-json
  php7.0-opcache php7.0-readline
アップグレード: 0 個、新規インストール: 9 個、削除: 0 個、保留: 164 個。
3,544 kB のアーカイブを取得する必要があります。
この操作後に追加で 14.2 MB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://jp.archive.ubuntu.com/ubuntu xenial/main amd64 php-common all 1:35ubuntu6 [10.8 kB]
取得:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0-common amd64 7.0.22-0ubuntu0.16.04.1 [843 kB]
取得:3 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0-json amd64 7.0.22-0ubuntu0.16.04.1 [16.9 kB]
取得:4 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0-opcache amd64 7.0.22-0ubuntu0.16.04.1 [77.1 kB]
取得:5 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0-readline amd64 7.0.22-0ubuntu0.16.04.1 [12.8 kB]
取得:6 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0-cli amd64 7.0.22-0ubuntu0.16.04.1 [1,287 kB]
取得:7 http://jp.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 php7.0-fpm amd64 7.0.22-0ubuntu0.16.04.1 [1,293 kB]
取得:8 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 php7.0 all 7.0.22-0ubuntu0.16.04.1 [1,294 B]
取得:9 http://jp.archive.ubuntu.com/ubuntu xenial/main amd64 php all 1:7.0+35ubuntu6 [2,832 B]
3,544 kB を 4秒 で取得しました (717 kB/s)
以前に未選択のパッケージ php-common を選択しています。
dpkg: 警告: パッケージ 'ubiquity-frontend-debconf' のファイル一覧ファイルがありません。このパッケージには、現在インストールされているファイルがないものとします
(データベースを読み込んでいます ... 現在 164691 個のファイルとディレクトリがインストールされています。)
.../php-common_1%3a35ubuntu6_all.deb を展開する準備をしています ...
php-common (1:35ubuntu6) を展開しています...
以前に未選択のパッケージ php7.0-common を選択しています。
.../php7.0-common_7.0.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
php7.0-common (7.0.22-0ubuntu0.16.04.1) を展開しています...
以前に未選択のパッケージ php7.0-json を選択しています。
.../php7.0-json_7.0.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
php7.0-json (7.0.22-0ubuntu0.16.04.1) を展開しています...
以前に未選択のパッケージ php7.0-opcache を選択しています。
.../php7.0-opcache_7.0.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
php7.0-opcache (7.0.22-0ubuntu0.16.04.1) を展開しています...
以前に未選択のパッケージ php7.0-readline を選択しています。
.../php7.0-readline_7.0.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
php7.0-readline (7.0.22-0ubuntu0.16.04.1) を展開しています...
以前に未選択のパッケージ php7.0-cli を選択しています。
.../php7.0-cli_7.0.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
php7.0-cli (7.0.22-0ubuntu0.16.04.1) を展開しています...
以前に未選択のパッケージ php7.0-fpm を選択しています。
.../php7.0-fpm_7.0.22-0ubuntu0.16.04.1_amd64.deb を展開する準備をしています ...
php7.0-fpm (7.0.22-0ubuntu0.16.04.1) を展開しています...
以前に未選択のパッケージ php7.0 を選択しています。
.../php7.0_7.0.22-0ubuntu0.16.04.1_all.deb を展開する準備をしています ...
php7.0 (7.0.22-0ubuntu0.16.04.1) を展開しています...
以前に未選択のパッケージ php を選択しています。
.../php_1%3a7.0+35ubuntu6_all.deb を展開する準備をしています ...
php (1:7.0+35ubuntu6) を展開しています...
man-db (2.7.5-1) のトリガを処理しています ...
ureadahead (0.100.0-19) のトリガを処理しています ...
ureadahead will be reprofiled on next reboot
systemd (229-4ubuntu19) のトリガを処理しています ...
php-common (1:35ubuntu6) を設定しています ...
php7.0-common (7.0.22-0ubuntu0.16.04.1) を設定しています ...

Creating config file /etc/php/7.0/mods-available/calendar.ini with new version

Creating config file /etc/php/7.0/mods-available/ctype.ini with new version

Creating config file /etc/php/7.0/mods-available/exif.ini with new version

Creating config file /etc/php/7.0/mods-available/fileinfo.ini with new version

Creating config file /etc/php/7.0/mods-available/ftp.ini with new version

Creating config file /etc/php/7.0/mods-available/gettext.ini with new version

Creating config file /etc/php/7.0/mods-available/iconv.ini with new version

Creating config file /etc/php/7.0/mods-available/pdo.ini with new version

Creating config file /etc/php/7.0/mods-available/phar.ini with new version

Creating config file /etc/php/7.0/mods-available/posix.ini with new version

Creating config file /etc/php/7.0/mods-available/shmop.ini with new version

Creating config file /etc/php/7.0/mods-available/sockets.ini with new version

Creating config file /etc/php/7.0/mods-available/sysvmsg.ini with new version

Creating config file /etc/php/7.0/mods-available/sysvsem.ini with new version

Creating config file /etc/php/7.0/mods-available/sysvshm.ini with new version

Creating config file /etc/php/7.0/mods-available/tokenizer.ini with new version
php7.0-json (7.0.22-0ubuntu0.16.04.1) を設定しています ...

Creating config file /etc/php/7.0/mods-available/json.ini with new version
php7.0-opcache (7.0.22-0ubuntu0.16.04.1) を設定しています ...

Creating config file /etc/php/7.0/mods-available/opcache.ini with new version
php7.0-readline (7.0.22-0ubuntu0.16.04.1) を設定しています ...

Creating config file /etc/php/7.0/mods-available/readline.ini with new version
php7.0-cli (7.0.22-0ubuntu0.16.04.1) を設定しています ...
update-alternatives: /usr/bin/php (php) を提供するために自動モードで /usr/bin/php7.0 を使います
update-alternatives: /usr/bin/phar (phar) を提供するために自動モードで /usr/bin/phar7.0 を使います
update-alternatives: /usr/bin/phar.phar (phar.phar) を提供するために自動モードで /usr/bin/phar.phar7.0 を使います

Creating config file /etc/php/7.0/cli/php.ini with new version
php7.0-fpm (7.0.22-0ubuntu0.16.04.1) を設定しています ...

Creating config file /etc/php/7.0/fpm/php.ini with new version
php7.0 (7.0.22-0ubuntu0.16.04.1) を設定しています ...
php (1:7.0+35ubuntu6) を設定しています ...
systemd (229-4ubuntu19) のトリガを処理しています ...
ureadahead (0.100.0-19) のトリガを処理しています ...

インストールが完了したので、インストールされたPHPのバージョンを確認。

$ php -v
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

PHP 7がインストールされた。目的のPHPプログラムを動かしてみる。問題なく動きました。作業完了。