一番簡単なPHP 7.1バージョンアップ方法(Ubuntu/Cloud9)
Laravel5.5を試してみようと思ったところ、Laravelの要件がPHP7以上となっていました。 Cloud9のPHP環境はデフォルトが5.6ですのでPHPのバージョンアップを行う必要があります。
少し調べるとかなり簡単な方法がみつかりました。 そのサイトを参考にUbuntu(Cloud9)にパパっとPHP7.1を導入する手順を載せていきます。
参考にしたサイト
- 手順も載っています。
How To Use Step 1 Create a new C9.io Workspace with PHP as the template
Step 2 Open created Workspace then go to terminal
Step 3 Get the install-laravel.sh
Step 4 Run The Install
- composerは使えなかったので直接gitから取得し実行しました。
Cloud9でphp7.0に上げる方法は以前書きましたが、 今回の手順の方が数回のコマンド実行のみで完了できるので「簡単」で「早い」です。 soudan.hatenablog.jp
スクリプトをGitHubからクローンして取得する
$ git clone https://github.com/svpernova09/cloud9-php71.git
- cloud9-php71というフォルダが作られ、その中に「install-laravel.sh」というファイルが生成されています。
install-laravel.shを実行
$ cd cloud9-php71 $ ./install-laravel.sh gpg: keyring `/tmp/tmpcsoedh1f/secring.gpg' created gpg: keyring `/tmp/tmpcsoedh1f/pubring.gpg' created gpg: requesting key E5267A6C from hkp server keyserver.ubuntu.com gpg: /tmp/tmpcsoedh1f/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 Ign http://downloads-distro.mongodb.org dist InRelease Get:1 http://security.ubuntu.com trusty-security InRelease [65.9 kB] : Get:53 http://asia-east1.gce.clouds.archive.ubuntu.com trusty/multiverse i386 Packages [172 kB] Fetched 36.0 MB in 15s (2255 kB/s) Reading package lists... Done W: Size of file /var/lib/apt/lists/ppa.launchpad.net_git-core_ppa_ubuntu_dists_trusty_main_binary-amd64_Packages.gz is not what the server reported 3451 3460 W: Size of file /var/lib/apt/lists/ppa.launchpad.net_git-core_ppa_ubuntu_dists_trusty_main_binary-i386_Packages.gz is not what the server reported 3452 3464 Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libvpx1 Use 'apt-get autoremove' to remove it. The following extra packages will be installed: dh-php libgd3 libssl1.1 libwebp5 libzip4 php-common php7.1-common php7.1-readline xml2 Suggested packages: libgd-tools The following NEW packages will be installed: dh-php libssl1.1 libwebp5 libzip4 php-common php7.1-bcmath php7.1-cli php7.1-common php7.1-curl php7.1-dev php7.1-gd php7.1-intl php7.1-json php7.1-mbstring php7.1-mcrypt php7.1-mysql php7.1-opcache php7.1-readline php7.1-soap php7.1-xml php7.1-zip xml2 The following packages will be upgraded: libgd3 1 upgraded, 22 newly installed, 0 to remove and 107 not upgraded. Need to get 5620 kB of archives. After this operation, 23.8 MB of additional disk space will be used. Get:1 http://asia-east1.gce.clouds.archive.ubuntu.com/ubuntu/ trusty/universe xml2 amd64 0.4-3.1 [15.8 kB] : Get:23 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main dh-php all 0.28+ubuntu14.04.1+deb.sury.org+1 [13.4 kB] Fetched 5620 kB in 57s (98.2 kB/s) Preconfiguring packages ... Selecting previously unselected package libssl1.1:amd64. (Reading database ... 73634 files and directories currently installed.) Preparing to unpack .../libssl1.1_1.1.0g-2.1+ubuntu14.04.1+deb.sury.org+1_amd64.deb ... U : Setting up php7.1-common (7.1.11-1+ubuntu14.04.1+deb.sury.org+1) ... Creating config file /etc/php/7.1/mods-available/calendar.ini with new version Creating config file /etc/php/7.1/mods-available/ctype.ini with new version Creating config file /etc/php/7.1/mods-available/exif.ini with new version : Creating config file /etc/php/7.1/mods-available/xsl.ini with new version Setting up php7.1-zip (7.1.11-1+ubuntu14.04.1+deb.sury.org+1) ... Creating config file /etc/php/7.1/mods-available/zip.ini with new version Setting up xml2 (0.4-3.1) ... Setting up dh-php (0.28+ubuntu14.04.1+deb.sury.org+1) ... Processing triggers for libc-bin (2.19-0ubuntu6.11) ... Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libvpx1 Use 'apt-get autoremove' to remove it. The following extra packages will be installed: php5-cgi The following packages will be REMOVED: libapache2-mod-php5 phppgadmin The following NEW packages will be installed: php5-cgi 0 upgraded, 1 newly installed, 2 to remove and 107 not upgraded. Need to get 4265 kB of archives. After this operation, 5201 kB of additional disk space will be used. Get:1 http://asia-east1.gce.clouds.archive.ubuntu.com/ubuntu/ trusty-updates/main php5-cgi amd64 5.5.9+dfsg-1ubuntu4.22 [4265 kB] Fetched 4265 kB in 2s (1803 kB/s) (Reading database ... 74255 files and directories currently installed.) Removing phppgadmin (5.1-1) ... Removing libapache2-mod-php5 (5.5.9+dfsg-1ubuntu4.22) ... php5_invoke prerm: Disable module pgsql for apache2 SAPI : php5_invoke prerm: Disable module pdo_mysql for apache2 SAPI Module php5 disabled. apache2_invoke prerm: Disable module php5 Action 'configtest' failed. The Apache error log may have more information. apache2_reload: Your configuration is broken. Not restarting Apache 2 Selecting previously unselected package php5-cgi. (Reading database ... 73859 files and directories currently installed.) Preparing to unpack .../php5-cgi_5.5.9+dfsg-1ubuntu4.22_amd64.deb ... Unpacking php5-cgi (5.5.9+dfsg-1ubuntu4.22) ... Processing triggers for man-db (2.6.7.1-1ubuntu1) ... Setting up php5-cgi (5.5.9+dfsg-1ubuntu4.22) ... update-alternatives: using /usr/bin/php5-cgi to provide /usr/bin/php-cgi (php-cgi) in auto mode update-alternatives: using /usr/lib/cgi-bin/php5 to provide /usr/lib/cgi-bin/php (php-cgi-bin) in auto mode Creating config file /etc/php5/cgi/php.ini with new version php5_invoke: Enable module pgsql for cgi SAPI : php5_invoke: Enable module pdo_mysql for cgi SAPI Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libvpx1 Use 'apt-get autoremove' to remove it. The following NEW packages will be installed: libapache2-mod-php7.1 0 upgraded, 1 newly installed, 0 to remove and 107 not upgraded. Need to get 1243 kB of archives. After this operation, 4426 kB of additional disk space will be used. Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu/ trusty/main libapache2-mod-php7.1 amd64 7.1.11-1+ubuntu14.04.1+deb.sury.org+1 [1243 kB] Fetched 1243 kB in 8s (147 kB/s) Selecting previously unselected package libapache2-mod-php7.1. (Reading database ... 73871 files and directories currently installed.) Preparing to unpack .../libapache2-mod-php7.1_7.1.11-1+ubuntu14.04.1+deb.sury.org+1_amd64.deb ... Unpacking libapache2-mod-php7.1 (7.1.11-1+ubuntu14.04.1+deb.sury.org+1) ... Setting up libapache2-mod-php7.1 (7.1.11-1+ubuntu14.04.1+deb.sury.org+1) ... Creating config file /etc/php/7.1/apache2/php.ini with new version php_invoke: Enabled module pdo_mysql for apache2 sapi php_invoke: Enabled module bcmath for apache2 sapi : php_invoke: Enabled module phar for apache2 sapi apache2_invoke: Enable module php7.1 Action 'configtest' failed. The Apache error log may have more information. apache2_reload: Your configuration is broken. Not restarting Apache 2 Module php5 already disabled Considering dependency mpm_prefork for php7.1: Considering conflict mpm_event for mpm_prefork: Considering conflict mpm_worker for mpm_prefork: Module mpm_prefork already enabled Considering conflict php5 for php7.1: Module php7.1 already enabled * Restarting web server apache2 [ OK ] Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: libvpx1 Use 'apt-get autoremove' to remove it. The following packages will be upgraded: mysql-server 1 upgraded, 0 newly installed, 0 to remove and 106 not upgraded. Need to get 11.3 kB of archives. After this operation, 5120 B disk space will be freed. Get:1 http://asia-east1.gce.clouds.archive.ubuntu.com/ubuntu/ trusty-updates/main mysql-server all 5.5.58-0ubuntu0.14.04.1 [11.3 kB] Fetched 11.3 kB in 0s (22.0 kB/s) (Reading database ... 73882 files and directories currently installed.) Preparing to unpack .../mysql-server_5.5.58-0ubuntu0.14.04.1_all.deb ... Unpacking mysql-server (5.5.58-0ubuntu0.14.04.1) over (5.5.57-0ubuntu0.14.04.1) ... Setting up mysql-server (5.5.58-0ubuntu0.14.04.1) ... ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (111) * Stopping MySQL database server mysqld [ OK ] * Starting MySQL database server mysqld [ OK ] * Checking for tables which need an upgrade, are corrupt or were not closed cleanly. * Stopping MySQL database server mysqld ERROR 1053 (08S01) at line 1: Server shutdown in progress ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) : [ OK ] * Starting MySQL database server mysqld [ OK ] * Checking for tables which need an upgrade, are corrupt or were not closed cleanly. Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
- Warningやら出ますが無視でOKです。
PHP7インストール確認
- cloud9-php71フォルダ内にinfo.phpがありますので、そちらをウェブブラウザで表示します。
$ php -v PHP 7.1.11-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Oct 27 2017 14:28:45) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.1.11-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies
正常にPHP7がインストールされました。
ダウンロードして実行だけでPHP5からPHP7へアップグレードできてとても簡単です。