読者です 読者をやめる 読者になる 読者になる

【PHP】Ubuntu 16.04ではPHP5.6をインストールすることは出来ない

発端

さぁ心機一転、Ubuntu16.04でPHPインストールしようとした。まぁ7.xも悪くないけど今回は安定志向ということでPHP5.6をインストールすることに

sudo apt show php

結果

user@ubuntu:~$ sudo apt show php
Package: php
Version: 1:7.0+42+deb.sury.org~xenial+1
Priority: optional
Section: php
Source: php-defaults (42+deb.sury.org~xenial+1)
Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Installed-Size: 11.3 kB
Depends: php7.0
Download-Size: 4,588 B
APT-Sources: http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 Packages
Description: server-side, HTML-embedded scripting language (default)
 PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
 open source general-purpose scripting language that is especially suited
 for web development and can be embedded into HTML.
 .
 This package is a dependency package, which depends on Debian's default
 PHP version (currently 7.0).

N: There is 1 additional record. Please use the '-a' switch to see it

ん??????????????????デフォルトで7だと?

16.04のデフォルトはPHP 7

なんかそうっぽい まだ安定版じゃないって開発者自身が言ってたくせに何やってるんだ感

5.6をインストール

いつものPPA追加するしかない

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php5.6
user@ubuntu:~$ sudo apt show php5.6
Package: php5.6
Version: 5.6.22-4+deb.sury.org~xenial+1
Priority: optional
Section: php
Maintainer: Debian PHP Maintainers <pkg-php-maint@lists.alioth.debian.org>
Installed-Size: 278 kB
Provides: php
Depends: libapache2-mod-php5.6 | php5.6-fpm | php5.6-cgi, php5.6-common
Download-Size: 253 kB
APT-Manual-Installed: yes
APT-Sources: http://ppa.launchpad.net/ondrej/php/ubuntu xenial/main amd64 Packages
Description: server-side, HTML-embedded scripting language (metapackage)
 This package is a metapackage that, when installed, guarantees that you
 have at least one of the four server-side versions of the PHP interpreter
 installed. Removing this package won't remove PHP from your system, however
 it may remove other packages that depend on this one.
 .
 PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
 open source general-purpose scripting language that is especially suited
 for web development and can be embedded into HTML.

やっためう!

これだけでは終わらないPHP5.6の罠

Apache2で使うときは

sudo apt install libapache2-mod-php5.6 libapache2-mpm-itk

した後に sudo a2enmod php5.6 が必要