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

【WordPressカスタマイズ相談】現役プログラマが解決策を教えます

WordPress(ワードプレス)のお悩み、うまくいかなくてお困りなこと、不具合調査、新規制作依頼まで、ウェブアプリケーションエンジニアがあなたをサポートします。

Cloud9 でPHP7をインストールする手順

f:id:jsaz:20160924013847p:plain
少し前まではWindowsパソコンで開発環境といえばXAMPを設定して使っていましたが、最近はCloud9を使っています。
ちょっとした調査や検証は「新しくworkspaceを作り、確認したら削除する」といった使い方もよくしております。

今回はPHPフレームワークの「CakePHP3.2」と「laraval5.3」をインストールしたかったのでPHP7をインストールする必要がありました。

cloud9のデフォルトPHPは5.5.9でしたので、PHP7へアップデートしてみたいと思います。


参考サイトは英語と日本語の2つのサイトです。
community.c9.io

qiita.com


※コマンドと結果も記載していますので長文になります。


[PR]PHP7の基本構文から、クラス、DB連携、セキュリティ対策まで、しっかり習得!

PHPバージョン確認
cloud9:~/workspace $ php -v
PHP 5.5.9-1ubuntu4.19 (cli) (built: Jul 28 2016 19:31:33)
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
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
aptのパッケージ更新
cloud9:~/workspace $ sudo apt-get update
Ign http://downloads-distro.mongodb.org dist InRelease
Hit http://ppa.launchpad.net trusty InRelease
Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB]
Hit http://ppa.launchpad.net trusty InRelease
Hit http://downloads-distro.mongodb.org dist Release.gpg
Ign http://asia-east1.gce.clouds.archive.ubuntu.com trusty InRelease
Ign http://toolbelt.heroku.com ./ InRelease
Hit http://ppa.launchpad.net trusty/main amd64 Packages
Get:2 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Hit http://downloads-distro.mongodb.org dist Release
Hit http://ppa.launchpad.net trusty/main i386 Packages
Get:3 http://security.ubuntu.com trusty-security/main Sources [152 kB]
Get:4 http://toolbelt.heroku.com ./ Release.gpg [473 B]
Hit http://downloads-distro.mongodb.org dist/10gen amd64 Packages
Hit http://ppa.launchpad.net trusty/main amd64 Packages
Get:5 http://toolbelt.heroku.com ./ Release [1609 B]
Hit http://ppa.launchpad.net trusty/main i386 Packages
Get:6 http://security.ubuntu.com trusty-security/universe Sources [49.4 kB]
Get:7 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports InRelease [65.9 kB]
Hit http://downloads-distro.mongodb.org dist/10gen i386 Packages
Get:8 http://security.ubuntu.com trusty-security/main amd64 Packages [657 kB]
Get:9 http://toolbelt.heroku.com ./ Packages [724 B]
Get:10 http://asia-east1.gce.clouds.archive.ubuntu.com trusty Release.gpg [933 B]
Get:11 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/main Sources [473 kB]
Get:12 http://security.ubuntu.com trusty-security/universe amd64 Packages [178 kB]
Get:13 http://security.ubuntu.com trusty-security/main i386 Packages [613 kB]
Get:14 http://security.ubuntu.com trusty-security/universe i386 Packages [178 kB]
Get:15 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/restricted Sources [5247 B]
Get:16 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/universe Sources [207 kB]
Get:17 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/multiverse Sources [6922 B]
Get:18 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [1120 kB]
Get:19 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/restricted amd64 Packages [23.5 kB]
Get:20 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [483 kB]
Get:21 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/multiverse amd64 Packages [16.1 kB]
Get:22 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/main i386 Packages [1075 kB]
Get:23 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/restricted i386 Packages [23.1 kB]
Get:24 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/universe i386 Packages [484 kB]
Get:25 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-updates/multiverse i386 Packages [16.7 kB]
Get:26 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/main Sources [10.3 kB]
Get:27 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/restricted Sources [40 B]
Get:28 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/universe Sources [41.1 kB]
Get:29 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/multiverse Sources [1751 B]
Get:30 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/main amd64 Packages [14.8 kB]
Get:31 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/restricted amd64 Packages [40 B]
Get:32 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/universe amd64 Packages [52.6 kB]
Get:33 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/multiverse amd64 Packages [1396 B]
Get:34 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/main i386 Packages [14.8 kB]
Get:35 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/restricted i386 Packages [40 B]
Get:36 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/universe i386 Packages [52.5 kB]
Get:37 http://asia-east1.gce.clouds.archive.ubuntu.com trusty-backports/multiverse i386 Packages [1381 B]
Get:38 http://asia-east1.gce.clouds.archive.ubuntu.com trusty Release [58.5 kB]
Get:39 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/main Sources [1335 kB]
Get:40 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/restricted Sources [5335 B]
Get:41 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/universe Sources [7926 kB]
Get:42 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse Sources [211 kB]
Get:43 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/main amd64 Packages [1743 kB]
Get:44 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/restricted amd64 Packages [16.0 kB]
Get:45 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/universe amd64 Packages [7589 kB]
Get:46 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse amd64 Packages [169 kB]
Get:47 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/main i386 Packages [1739 kB]
Get:48 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/restricted i386 Packages [16.4 kB]
Get:49 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/universe i386 Packages [7597 kB]
Get:50 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse i386 Packages [172 kB]
Fetched 34.7 MB in 17s (2040 kB/s)
Reading package lists... Done
libmcrypt-devのインストール
cloud9:~/workspace $ sudo apt-get install libmcrypt-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libmcrypt-dev
0 upgraded, 1 newly installed, 0 to remove and 82 not upgraded.
Need to get 83.1 kB of archives.
After this operation, 434 kB of additional disk space will be used.
Get:1 http://asia-east1.gce.clouds.archive.ubuntu.com/ubuntu/ trusty/universe libmcrypt-dev amd64 2.5.8-3.1ubuntu1 [83.1 kB]
Fetched 83.1 kB in 1s (78.5 kB/s)
Selecting previously unselected package libmcrypt-dev.
(Reading database ... 75375 files and directories currently installed.)
Preparing to unpack .../libmcrypt-dev_2.5.8-3.1ubuntu1_amd64.deb ...
Unpacking libmcrypt-dev (2.5.8-3.1ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libmcrypt-dev (2.5.8-3.1ubuntu1) ...
phpbrewのインストール
cloud9:~/workspace $ curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
						Dload  Upload   Total   Spent    Left  Speed
100   130  100   130    0     0    160      0 --:--:-- --:--:-- --:--:--   160
100 2076k  100 2076k    0     0   885k      0  0:00:02  0:00:02 --:--:-- 9982k
cloud9:~/workspace $ ls -la
total 2168
drwxrwxr-x  3 ubuntu ubuntu    4096 Sep 23 06:14 ./
drwxr-xr-x 21 ubuntu ubuntu    4096 Sep 23 05:39 ../
drwxr-xr-x  3 ubuntu ubuntu    4096 Sep 23 05:39 .c9/
-rw-r--r--  1 ubuntu ubuntu 2126299 Sep 23 06:14 phpbrew
実行出来るように権限、パスの変更をする
cloud9:~/workspace $ chmod +x phpbrew
cloud9:~/workspace $ sudo mv phpbrew /usr/local/bin/
cloud9:~/workspace $ ls -la
total 88
drwxrwxr-x  3 ubuntu ubuntu  4096 Sep 23 06:14 ./
drwxr-xr-x 21 ubuntu ubuntu  4096 Sep 23 05:39 ../
drwxr-xr-x  3 ubuntu ubuntu  4096 Sep 23 05:39 .c9/
phpbrewの初期化
cloud9:~/workspace $ phpbrew init
Using root: /home/ubuntu/.phpbrew
Initialization successfully finished!
<=====================================================>
Phpbrew environment is initialized, required directories are created under
/home/ubuntu/.phpbrew
Paste the following line(s) to the end of your ~/.bashrc and start a
new shell, phpbrew should be up and fully functional from there:
source /home/ubuntu/.phpbrew/bashrc
To enable PHP version info in your shell prompt, please set PHPBREW_SET_PROMPT=1
in your ~/.bashrc before you source ~/.phpbrew/bashrc
export PHPBREW_SET_PROMPT=1
To enable .phpbrewrc file searching, please export the following variable:
export PHPBREW_RC_ENABLE=1
For further instructions, simply run phpbrew to see the help message.
Enjoy phpbrew at $HOME!!
<=====================================================>
phpbrew 環境変数設定
cloud9:~/workspace $ [[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc
phpbrew ubuntuに合わせた設定
cloud9:~/workspace $ phpbrew lookup-prefix ubuntu
/usr
phpbrew でPHP7と関連モジュールをインストール
cloud9:~/workspace $ phpbrew install 7.0.11 +default +mysql +pdo +fpm +opcache +intl
===> phpbrew will now build 7.0.11
===> Loading and resolving variants...
Checking distribution checksum...
Checksum matched: daec0bee2e5cbec4b25535b9556f38bd
===> Distribution file was successfully extracted, skipping...
===> Checking patches...
Checking patch for replace apache php module name with custom version name
Found existing build.log, renaming it to /home/ubuntu/.phpbrew/build/php-7.0.11/build.log.1474617159
===> Configuring 7.0.11...

Use tail command to see whats going on:
$ tail -F /home/ubuntu/.phpbrew/build/php-7.0.11/build.log

===> Checking patches...
Checking patch for php5.3.29 multi-sapi patch.
Checking patch for php5.3.x on 64bit machine when intl is enabled.
Checking patch for openssl dso linking patch
===> Building...
Build finished: 29.2 minutes.
Installing...
---> Creating php-fpm.conf
---> Found /home/ubuntu/.phpbrew/php/php-7.0.11/etc/php-fpm.d/www.conf
---> Patching default fpm pool listen path to /home/ubuntu/.phpbrew/php/php-7.0.11/var/run/php-fpm.sock
---> Creating php.ini
---> Copying /home/ubuntu/.phpbrew/build/php-7.0.11/php.ini-development
---> Found date.timezone is not set, patching...
---> Found date.timezone, patching config timezone with UTC
Congratulations! Now you have PHP with 7.0.11 as php-7.0.11

We found that you enabled 'mysql' variant, you might need to setup your
'pdo_mysql.default_socket' or 'mysqli.default_socket' in your php.ini file.

To configure your installed PHP further, you can edit the config file at
/home/ubuntu/.phpbrew/php/php-7.0.11/etc/php.ini

To use the newly built PHP, try the line(s) below:

$ phpbrew use php-7.0.11

Or you can use switch command to switch your default php to php-7.0.11:

$ phpbrew switch php-7.0.11

Enjoy!


[PR]php7対応レンタルサーバー

phpbrew を使い、PHPのバージョンを切り替える
cloud9:~/workspace $ phpbrew switch php-7.0.11
cloud9:~/workspace $ phpbrew use php-7.0.11
cloud9:~/workspace $ php -v
PHP 7.0.11 (cli) (built: Sep 23 2016 08:20:53) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies


コマンドライン上でのPHP7の使用は可能になる
phpinfo()で確認するとphp5のままなのでweb経由でのPHP7設定を続ける

phpbrew で拡張モジュールなどを確認する
cloud9:~/workspace $ phpbrew variants
WARNING: curl extension might be required for fetching data.
Variants:
all, apxs2, bcmath, bz2, calendar, cgi, cli, ctype, curl, dba, debug, dom,
dtrace, editline, embed, exif, fileinfo, filter, fpm, ftp, gcov, gd,
gettext, gmp, hash, iconv, icu, imap, inifile, inline, intl, ipc, ipv6,
json, kerberos, libgcc, mbregex, mbstring, mcrypt, mhash, mysql, opcache,
openssl, pcntl, pcre, pdo, pgsql, phar, phpdbg, posix, readline, session,
soap, sockets, sqlite, static, tidy, tokenizer, wddx, xml, xml_all, xmlrpc,
zip, zlib, zts

Virtual variants:
dbs: sqlite, mysql, pgsql, pdo
mb: mbstring, mbregex
neutral:
small: bz2, cli, dom, filter, ipc, json, mbregex, mbstring, pcre, phar,
posix, readline, xml, curl, openssl
default: bcmath, bz2, calendar, cli, ctype, dom, fileinfo, filter, ipc,
json, mbregex, mbstring, mhash, mcrypt, pcntl, pcre, pdo, phar, posix,
readline, sockets, tokenizer, xml, curl, openssl, zip
everything: dba, ipv6, dom, calendar, wddx, static, inifile, inline, cli,
ftp, filter, gcov, zts, json, hash, exif, mbstring, mbregex, libgcc,
pdo, posix, embed, sockets, debug, phpdbg, zip, bcmath, fileinfo, ctype,
cgi, soap, pcntl, phar, session, tokenizer, opcache, imap, tidy, kerberos,
xmlrpc, fpm, dtrace, pcre, mhash, mcrypt, zlib, curl, readline, editline,
gd, intl, icu, openssl, mysql, sqlite, pgsql, xml, xml_all, gettext,
iconv, bz2, ipc, gmp

Using variants to build PHP:

phpbrew install php-5.3.10 +default
phpbrew install php-5.3.10 +mysql +pdo
phpbrew install php-5.3.10 +mysql +pdo +apxs2
phpbrew install php-5.3.10 +mysql +pdo +apxs2=/usr/bin/apxs2


cURL エクステンションが必要だと警告が出た

cURL エクステンションをインストール
cloud9:~/workspace $ phpbrew ext install curl
WARNING: curl extension might be required for fetching data.
Warning: Some extension won t be able to be built with php7. If the extension
supports php7 in another branch or new major version, you will need to specify
the branch name or version name explicitly.

For example, to install memcached extension for php7, use:

phpbrew ext install github:php-memcached-dev/php-memcached php7 -- --disable-memcached-sasl

===> Installing curl extension...
Log stored at: /home/ubuntu/.phpbrew/build/php-7.0.11/ext/curl/build.log
Changing directory to /home/ubuntu/.phpbrew/build/php-7.0.11/ext/curl
===> Phpize...
===> Configuring...
Error: Command failed: ./configure --with-php-config=/home/ubuntu/.phpbrew/php/php-7.0.11/bin/php-config >> /home/ubuntu/.phpbrew/build/php-7.0.11/ext/curl/build.log 2>&1 returns:


Error: Command failedが出てうまくインストールできない、原因がわからないのでapt updateを試す

再度、パッケージ更新
cloud9:~/workspace $ sudo apt-get update
:
(省略)
:
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse i386 Packages
Fetched 5893 kB in 10s (551 kB/s)                                              
Reading package lists... Done
W: Size of file /var/lib/apt/lists/asia-east1.gce.clouds.archive.ubuntu.com_ubuntu_dists_trusty-updates_main_binary-i386_Packages.gz
 is not what the server reported 1074754 1074756
エクステンション確認
cloud9:~/workspace $ phpbrew ext
WARNING: curl extension might be required for fetching data.
Loaded extensions:
[*] bcmath       7.0.11
[*] bz2          7.0.11
[*] calendar     7.0.11
[*] ctype        7.0.11
[*] date         7.0.11
[*] dom          20031129
[*] fileinfo     1.0.5
[*] filter       7.0.11
[*] hash         1.0
[*] intl         1.1.0
[*] json         1.4.0
[*] libxml       7.0.11
[*] mbstring     7.0.11
[*] mcrypt       7.0.11
[*] mysqli       7.0.11
[*] mysqlnd      mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $
[*] openssl      7.0.11
[*] pcntl        7.0.11
[*] pcre         7.0.11
[*] pdo          7.0.11
[*] pdo_mysql    7.0.11
[*] phar         2.0.2
[*] posix        7.0.11
[*] readline     7.0.11
[*] reflection   7.0.11
[*] session      7.0.11
[*] shmop        7.0.11
[*] simplexml    7.0.11
[*] sockets      7.0.11
[*] spl          7.0.11
[*] standard     7.0.11
[*] sysvmsg      7.0.11
[*] sysvsem      7.0.11
[*] sysvshm      7.0.11
[*] tokenizer    7.0.11
[*] xml          7.0.11
[*] xmlreader    7.0.11
[*] xmlwriter    7.0.11
[*] xsl          7.0.11
[*] zip          1.13.4
[*] zlib         7.0.11
Available local extensions:
[ ] curl
[ ] dba
[ ] enchant
[ ] exif
[ ] ftp
[ ] gd
[ ] gettext
[ ] gmp
[ ] iconv
[ ] imap
[ ] interbase
[ ] ldap
[ ] oci8
[ ] odbc
[ ] opcache
[ ] pdo_dblib
[ ] pdo_firebird
[ ] pdo_oci
[ ] pdo_odbc
[ ] pdo_pgsql
[ ] pdo_sqlite
[ ] pgsql
[ ] pspell
[ ] recode
[ ] snmp
[ ] soap
[ ] sqlite3
[ ] tidy
[ ] wddx
[ ] xmlrpc
再度cURL エクステンションを入れる
WARNING: curl extension might be required for fetching data.
Warning: Some extension won t be able to be built with php7. If the extension
supports php7 in another branch or new major version, you will need to specify
the branch name or version name explicitly.

For example, to install memcached extension for php7, use:

phpbrew ext install github:php-memcached-dev/php-memcached php7 -- --disable-memcached-sasl

===> Installing curl extension...
Log stored at: /home/ubuntu/.phpbrew/build/php-7.0.11/ext/curl/build.log
Changing directory to /home/ubuntu/.phpbrew/build/php-7.0.11/ext/curl
===> Phpize...
===> Configuring...
===> Building...
===> Running make all: /usr/bin/make -C '/home/ubuntu/.phpbrew/build/php-7.0.11/ext/curl' 'all'  >> '/home/ubuntu/.phpbrew/build/php-7.0.11/ext/curl/build.log' 2>&1
===> Installing...
===> Running make install: /usr/bin/make -C '/home/ubuntu/.phpbrew/build/php-7.0.11/ext/curl' 'install'  >> '/home/ubuntu/.phpbrew/build/php-7.0.11/ext/curl/build.log' 2>&1
===> Extension is installed.
===> Creating config file /home/ubuntu/.phpbrew/php/php-7.0.11/var/db/curl.ini.disabled
===> Enabling extension curl
[*] curl extension is enabled.
Done.
エクステンション確認
cloud9:~/workspace $ phpbrew ext
Loaded extensions:
[*] bcmath       7.0.11
[*] bz2          7.0.11
[*] calendar     7.0.11
[*] ctype        7.0.11
[*] curl         7.0.11
[*] date         7.0.11
[*] dom          20031129
[*] fileinfo     1.0.5
[*] filter       7.0.11
:
(省略)
:


cURLが確認できた
試しにXdebugも追加

Xdebugを入れる
cloud9:~/.phpbrew/php $ phpbrew ext install xdebug
PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'xml.so' in Unknown on line 0

Warning: PHP Startup: Invalid library (maybe not a PHP library) 'xml.so' in Unknown on line 0
Warning: Some extension won t be able to be built with php7. If the extension
supports php7 in another branch or new major version, you will need to specify
the branch name or version name explicitly.

For example, to install memcached extension for php7, use:
phpbrew ext install github:php-memcached-dev/php-memcached php7 -- --disable-memcached-sasl

Downloading https://pecl.php.net/rest/r/xdebug/stable.txt via curl extension
[==================================================================] 5.00/5.00B 100%
Downloading https://pecl.php.net/rest/r/xdebug/2.4.1.xml via curl extension
[==================================================================] 2.07/2.07KB 100%
Downloading https://pecl.php.net/rest/r/xdebug/stable.txt via curl extension
[==================================================================] 5.00/5.00B 100%
Downloading https://pecl.php.net/rest/r/xdebug/2.4.1.xml via curl extension
[==================================================================] 2.07/2.07KB 100%
Downloading http://pecl.php.net/get/xdebug-2.4.1.tgz via curl extension
[==================================================================] 259.32/259.32KB 100%
===> Extracting to /home/ubuntu/.phpbrew/build/php-7.0.11/ext...
===> Installing xdebug extension...
Log stored at: /home/ubuntu/.phpbrew/build/php-7.0.11/ext/xdebug/build.log
Changing directory to /home/ubuntu/.phpbrew/build/php-7.0.11/ext/xdebug
===> Phpize...
===> Configuring...
===> Building...
===> Running make all: /usr/bin/make -C '/home/ubuntu/.phpbrew/build/php-7.0.11/ext/xdebug' 'all'  >> '/home/ubuntu/.phpbrew/build/php-7.0.11/ext/xdebug/build.log' 2>&1
===> Installing...
===> Running make install: /usr/bin/make -C '/home/ubuntu/.phpbrew/build/php-7.0.11/ext/xdebug' 'install'  >> '/home/ubuntu/.phpbrew/build/php-7.0.11/ext/xdebug/build.log' 2>&1
===> Extension is installed.
===> Creating config file /home/ubuntu/.phpbrew/php/php-7.0.11/var/db/xdebug.ini.disabled
===> Enabling extension xdebug
[*] xdebug extension is enabled.
Done.
ppa:ondrej/php リポジトリを追加
cloud9:~/workspace $  sudo add-apt-repository ppa:ondrej/php
Co-installable PHP versions: PHP 5.5, 5.6, PHP 7.0 and batteries included.

You can get more information about the packages at https://deb.sury.org

For PHP 5.4 on Ubuntu 12.04 use: ppa:ondrej/php5-oldstable

BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting

PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/

WARNING: add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:
LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
More info: https://launchpad.net/~ondrej/+archive/ubuntu/php
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmpm3cfn7qo/secring.gpg' created
gpg: keyring `/tmp/tmpm3cfn7qo/pubring.gpg' created
gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpm3cfn7qo/trustdb.gpg: trustdb created
gpg: key E5267A6C: public key "Launchpad PPA for Ondřej Surý" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK
再度、パッケージ更新
cloud9:~/workspace $ sudo apt-get update
:
(省略)
:
Hit http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse i386 Packages
Fetched 6027 kB in 14s (430 kB/s)
Reading package lists... Done
W: Size of file /var/lib/apt/lists/asia-east1.gce.clouds.archive.ubuntu.com_ubuntu_dists_trusty-updates_main_binary-i386_Packages.gz
 is not what the server reported 1074753 1074754
libapache2-mod-php7.0をインストール
cloud9:~/workspace $ sudo apt-get install libapache2-mod-php7.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libssl1.0.2 php-common php7.0-cli php7.0-common php7.0-json php7.0-opcache
php7.0-readline
The following NEW packages will be installed:
libapache2-mod-php7.0 libssl1.0.2 php-common php7.0-cli php7.0-common
php7.0-json php7.0-opcache php7.0-readline
0 upgraded, 8 newly installed, 0 to remove and 83 not upgraded.
Need to get 4692 kB of archives.
After this operation, 17.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main libssl1.0.2 amd64 1.0.2h-1+deb.sury.org~trusty+1 [1263 kB]
Get:2 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php-common all 1:44+deb.sury.org~trusty+1 [12.9 kB]
Get:3 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.0-common amd64 7.0.11-1+deb.sury.org~trusty+1 [866 kB]
Get:4 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.0-json amd64 7.0.11-1+deb.sury.org~trusty+1 [17.2 kB]
Get:5 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.0-opcache amd64 7.0.11-1+deb.sury.org~trusty+1 [76.3 kB]
Get:6 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.0-readline amd64 7.0.11-1+deb.sury.org~trusty+1 [12.2 kB]
Get:7 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main php7.0-cli amd64 7.0.11-1+deb.sury.org~trusty+1 [1251 kB]
Get:8 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main libapache2-mod-php7.0 amd64 7.0.11-1+deb.sury.org~trusty+1 [1193 kB]
Fetched 4692 kB in 10s (457 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libssl1.0.2:amd64.
(Reading database ... 75974 files and directories currently installed.)
Preparing to unpack .../libssl1.0.2_1.0.2h-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking libssl1.0.2:amd64 (1.0.2h-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php-common.
Preparing to unpack .../php-common_1%3a44+deb.sury.org~trusty+1_all.deb ...
Unpacking php-common (1:44+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.0-common.
Preparing to unpack .../php7.0-common_7.0.11-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.0-common (7.0.11-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.0-json.
Preparing to unpack .../php7.0-json_7.0.11-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.0-json (7.0.11-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.0-opcache.
Preparing to unpack .../php7.0-opcache_7.0.11-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.0-opcache (7.0.11-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.0-readline.
Preparing to unpack .../php7.0-readline_7.0.11-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.0-readline (7.0.11-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package php7.0-cli.
Preparing to unpack .../php7.0-cli_7.0.11-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking php7.0-cli (7.0.11-1+deb.sury.org~trusty+1) ...
Selecting previously unselected package libapache2-mod-php7.0.
Preparing to unpack .../libapache2-mod-php7.0_7.0.11-1+deb.sury.org~trusty+1_amd64.deb ...
Unpacking libapache2-mod-php7.0 (7.0.11-1+deb.sury.org~trusty+1) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libssl1.0.2:amd64 (1.0.2h-1+deb.sury.org~trusty+1) ...
Setting up php-common (1:44+deb.sury.org~trusty+1) ...
Setting up php7.0-common (7.0.11-1+deb.sury.org~trusty+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
Setting up php7.0-json (7.0.11-1+deb.sury.org~trusty+1) ...

Creating config file /etc/php/7.0/mods-available/json.ini with new version
Setting up php7.0-opcache (7.0.11-1+deb.sury.org~trusty+1) ...

Creating config file /etc/php/7.0/mods-available/opcache.ini with new version
Setting up php7.0-readline (7.0.11-1+deb.sury.org~trusty+1) ...

Creating config file /etc/php/7.0/mods-available/readline.ini with new version
Setting up php7.0-cli (7.0.11-1+deb.sury.org~trusty+1) ...
update-alternatives: using /usr/bin/php7.0 to provide /usr/bin/php (php) in auto mode
update-alternatives: using /usr/bin/phar7.0 to provide /usr/bin/phar (phar) in auto mode
update-alternatives: using /usr/bin/phar.phar7.0 to provide /usr/bin/phar.phar (phar.phar) in auto mode

Creating config file /etc/php/7.0/cli/php.ini with new version
Setting up libapache2-mod-php7.0 (7.0.11-1+deb.sury.org~trusty+1) ...

Creating config file /etc/php/7.0/apache2/php.ini with new version
apache2_invoke: Enable module php7.0
	Restarting web server apache2
...done.
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
PHP5モジュールを削除
cloud9:~/workspace $ sudo a2dismod php5
Module php5 disabled.
To activate the new configuration, you need to run:
  service apache2 restart
PHP7.0モジュールを追加
cloud9:~/workspace $ sudo a2enmod php7.0
Considering dependency mpm_prefork for php7.0:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php7.0:
Module php7.0 already enabled
phpInfo確認
cloud9:~/workspace $ php -i | grep 7.0
PHP Version => 7.0.11-1+deb.sury.org~trusty+1
Configuration File (php.ini) Path => /etc/php/7.0/cli
Scan this dir for additional .ini files => /etc/php/7.0/cli/conf.d
Additional .ini files parsed => /etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/10-pdo.ini,
/etc/php/7.0/cli/conf.d/20-calendar.ini,
/etc/php/7.0/cli/conf.d/20-ctype.ini,
/etc/php/7.0/cli/conf.d/20-exif.ini,
/etc/php/7.0/cli/conf.d/20-fileinfo.ini,
/etc/php/7.0/cli/conf.d/20-ftp.ini,
/etc/php/7.0/cli/conf.d/20-gettext.ini,
/etc/php/7.0/cli/conf.d/20-iconv.ini,
/etc/php/7.0/cli/conf.d/20-json.ini,
/etc/php/7.0/cli/conf.d/20-phar.ini,
/etc/php/7.0/cli/conf.d/20-posix.ini,
/etc/php/7.0/cli/conf.d/20-readline.ini,
/etc/php/7.0/cli/conf.d/20-shmop.ini,
/etc/php/7.0/cli/conf.d/20-sockets.ini,
/etc/php/7.0/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.0/cli/conf.d/20-sysvsem.ini,
/etc/php/7.0/cli/conf.d/20-sysvshm.ini,
/etc/php/7.0/cli/conf.d/20-tokenizer.ini
with Zend OPcache v7.0.11-1+deb.sury.org~trusty+1, Copyright (c) 1999-2016, by Zend Technologies
PHP Version => 7.0.11-1+deb.sury.org~trusty+1
PCRE Library Version => 8.31 2012-07-06
Version => 7.0.11-1+deb.sury.org~trusty+1
Version => 7.0.11-1+deb.sury.org~trusty+1
Add Comment


info.phpを作成してphpInfoを確認してもphp7であることが確認できた
以上、cloud9でphp7にする手順でした。

[PR]PHP 7を見逃すな!10年ぶりにメジャーアップデート!

広告を非表示にする