Amazon LinuxでPHPのバージョンを7.0→7.3にアップグレードする覚え書き

(事前準備メモ)

新しいEC2インスタンスを立ち上げ、そこで検証する。

① 稼働中のEC2からAMIを作成

② AMI→起動を選択。その際、セキュリティーグループやVPCなどは、起動中のEC2と合わせる

③ インスタンス起動後、既存のインスタンスIPv4パブリックIPをクリック→さらに表示されたIPをクリック

④ Elastic IP アドレスの画面で、IPをチェックし、「アクション」→ElasticIPアドレスの関連付けを選択

⑤ 「インスタンス」「プライベートIPアドレス」を既存のものに合わせる
(「再度関連付け」はチェックしなかった)

⑥ 「ロードバランサー」を開け、「インスタンスの編集」でインスタンスを切り替える

⑦ マウントが切れるので再マウントする
sudo umount /var/www/html/app/laravel/storage/app/public/mount
sudo mount -a

⑧ WorkbenchでRDSに繋がらなくなった。

C:\Users\tsuch\AppData\Roaming\MySQL\Workbench\ssh\known_hostsを開け、

該当IPの行を削除し、SSHホスト名を新インスタンスに変更して接続する

ーーーーーー 事前準備ここまで ーーーーーーー

 

基本的には以下のサイトを見ながら進める

https://blog.katsubemakito.net/php/upgrade-php71-to-73

 

① $ cat /etc/os-release

NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

 

② $ php -v

PHP 7.0.33 (cli) (built: Jan 9 2019 22:04:26) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies 

③ $ yum list installed | grep php

php70.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-cli.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-common.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-devel.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-gd.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-json.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-mbstring.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-mcrypt.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-mysqlnd.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-pdo.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-process.x86_64 7.0.33-1.32.amzn1 @amzn-updates
php70-xml.x86_64 7.0.33-1.32.amzn1 @amzn-updates

 

④ 追加手順

# yumからインストール可能なものを確認

$ sudo yum list available | grep php73

php73.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-bcmath.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-build.x86_64 2.0-1.el6.remi remi-safe
php73-cli.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-common.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-dba.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-dbg.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-devel.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-embedded.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-enchant.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-fpm.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-gd.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-gmp.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-imap.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-intl.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-json.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-ldap.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-mbstring.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-mysqlnd.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-odbc.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-opcache.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-pdo.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-pdo-dblib.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-pgsql.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-php.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-ast.x86_64 1.0.5-1.el6.remi remi-safe
php73-php-bcmath.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-brotli.x86_64 0.7.0-1.el6.remi remi-safe
php73-php-cli.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-common.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-componere.x86_64 3.1.1-1.el6.remi remi-safe
php73-php-dba.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-dbg.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-devel.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-embedded.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-enchant.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-fpm.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-gd.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-gmp.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-horde-horde-lz4.x86_64 1.0.10-6.el6.remi remi-safe
php73-php-imap.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-interbase.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-intl.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-ioncube-loader.x86_64 10.3.9-1.el6.remi remi-safe
php73-php-json.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-ldap.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-litespeed.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-lz4.x86_64 0.3.6-1.el6.remi remi-safe
php73-php-maxminddb.x86_64 1.6.0-1.el6.remi remi-safe
php73-php-mbstring.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-mysqlnd.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-oci8.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-odbc.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-opcache.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-pdo.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-pdo-dblib.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-pear.noarch 1:1.10.10-4.el6.remi remi-safe
php73-php-pecl-ahocorasick.x86_64 0.0.7-1.el6.remi remi-safe
php73-php-pecl-amqp.x86_64 1.9.4-6.el6.remi remi-safe
php73-php-pecl-apcu.x86_64 5.1.18-1.el6.remi remi-safe
php73-php-pecl-apcu-bc.x86_64 1.0.5-1.el6.remi remi-safe
php73-php-pecl-apcu-devel.x86_64 5.1.18-1.el6.remi remi-safe
php73-php-pecl-apfd.x86_64 1.0.1-12.el6.remi remi-safe
php73-php-pecl-base58.x86_64 0.1.4-1.el6.remi remi-safe
php73-php-pecl-bitset.x86_64 3.0.1-3.el6.remi remi-safe
php73-php-pecl-cassandra.x86_64 1.3.2-4.el6.remi remi-safe
php73-php-pecl-cmark.x86_64 1.2.0-1.el6.remi remi-safe
php73-php-pecl-couchbase2.x86_64 2.6.1-1.el6.remi remi-safe
php73-php-pecl-crypto.x86_64 0.3.1-5.el6.remi remi-safe
php73-php-pecl-datadog-trace.x86_64 0.36.0-1.el6.remi remi-safe
php73-php-pecl-dbase.x86_64 7.0.1-1.el6.remi remi-safe
php73-php-pecl-dio.x86_64 0.1.0-6.el6.remi remi-safe
php73-php-pecl-druid.x86_64 1.0.0-3.el6.remi remi-safe
php73-php-pecl-ds.x86_64 1.2.9-1.el6.remi remi-safe
php73-php-pecl-eio.x86_64 2.0.4-4.el6.remi remi-safe
php73-php-pecl-env.x86_64 0.2.1-7.el6.remi remi-safe
php73-php-pecl-ev.x86_64 1.0.8-1.el6.remi remi-safe
php73-php-pecl-event.x86_64 2.5.3-1.el6.remi remi-safe
php73-php-pecl-fann.x86_64 1.1.1-6.el6.remi remi-safe
php73-php-pecl-gearman.x86_64 2.0.6-1.el6.remi remi-safe
php73-php-pecl-gender.x86_64 1.1.0-13.el6.remi remi-safe
php73-php-pecl-geoip.x86_64 1.1.1-6.el6.remi remi-safe
php73-php-pecl-geospatial.x86_64 0.2.1-1.el6.remi remi-safe
php73-php-pecl-gmagick.x86_64 2.0.5~RC1-3.el6.remi remi-safe
php73-php-pecl-gnupg.x86_64 1.4.0-6.el6.remi remi-safe
php73-php-pecl-hprose.x86_64 1.6.8-1.el6.remi remi-safe
php73-php-pecl-hrtime.x86_64 0.6.0-5.el6.remi remi-safe
php73-php-pecl-http.x86_64 3.2.3-1.el6.remi remi-safe
php73-php-pecl-http-devel.x86_64 3.2.3-1.el6.remi remi-safe
php73-php-pecl-http-message.x86_64 0.2.1-1.el6.remi remi-safe
php73-php-pecl-http-message-devel.x86_64
php73-php-pecl-igbinary.x86_64 3.0.1-1.el6.remi remi-safe
php73-php-pecl-igbinary-devel.x86_64 3.0.1-1.el6.remi remi-safe
php73-php-pecl-imagick.x86_64 3.4.4-1.el6.remi remi-safe
php73-php-pecl-imagick-devel.x86_64 3.4.4-1.el6.remi remi-safe
php73-php-pecl-inotify.x86_64 2.0.0-8.el6.remi remi-safe
php73-php-pecl-ip2location.x86_64 8.0.1-3.el6.remi remi-safe
php73-php-pecl-json-post.x86_64 1.0.1-11.el6.remi remi-safe
php73-php-pecl-krb5.x86_64 1.1.2-6.el6.remi remi-safe
php73-php-pecl-krb5-devel.x86_64 1.1.2-6.el6.remi remi-safe
php73-php-pecl-leveldb.x86_64 0.2.1-4.el6.remi remi-safe
php73-php-pecl-lua.x86_64 2.0.6-1.el6.remi remi-safe
php73-php-pecl-luasandbox.x86_64 3.0.3-1.el6.remi remi-safe
php73-php-pecl-lzf.x86_64 1.6.7-1.el6.remi remi-safe
php73-php-pecl-mailparse.x86_64 3.0.4-1.el6.remi remi-safe
php73-php-pecl-mcrypt.x86_64 1.0.3-1.el6.remi remi-safe
php73-php-pecl-memcache.x86_64 4.0.5.2-1.el6.remi remi-safe
php73-php-pecl-memcached.x86_64 3.1.5-1.el6.remi remi-safe
php73-php-pecl-memprof.x86_64 2.0.0-5.el6.remi remi-safe
php73-php-pecl-mogilefs.x86_64 0.9.3.1-8.el6.remi remi-safe
php73-php-pecl-molten.x86_64 0.1.2~beta-5.el6.remi remi-safe
php73-php-pecl-mongodb.x86_64 1.6.1-1.el6.remi remi-safe
php73-php-pecl-msgpack.x86_64 2.0.3-1.el6.remi remi-safe
php73-php-pecl-msgpack-devel.x86_64 2.0.3-1.el6.remi remi-safe
php73-php-pecl-mustache.x86_64 0.7.4-5.el6.remi remi-safe
php73-php-pecl-mysql.x86_64 1.0.0-0.20.20180226.647c933.el6.remi
php73-php-pecl-mysqlnd-azure.x86_64 1.0.2-1.el6.remi remi-safe
php73-php-pecl-nsq.x86_64 3.5.0-1.el6.remi remi-safe
php73-php-pecl-oauth.x86_64 2.0.4-1.el6.remi remi-safe
php73-php-pecl-oci8.x86_64 2.2.0-1.el6.remi remi-safe
php73-php-pecl-opencensus.x86_64 0.2.2-3.el6.remi remi-safe
php73-php-pecl-parle.x86_64 0.8.1-4.el6.remi remi-safe
php73-php-pecl-pcov.x86_64 1.0.6-1.el6.remi remi-safe
php73-php-pecl-pdflib.x86_64 4.1.3-1.el6.remi remi-safe
php73-php-pecl-propro.x86_64 2.1.0-3.el6.remi remi-safe
php73-php-pecl-propro-devel.x86_64 2.1.0-3.el6.remi remi-safe
php73-php-pecl-protobuf.x86_64 3.11.2-1.el6.remi remi-safe
php73-php-pecl-psr.x86_64 0.7.0-1.el6.remi remi-safe
php73-php-pecl-psr-devel.x86_64 0.7.0-1.el6.remi remi-safe
php73-php-pecl-radius.x86_64 1.4.0-0.6.b1.el6.remi remi-safe
php73-php-pecl-raphf.x86_64 2.0.1-1.el6.remi remi-safe
php73-php-pecl-raphf-devel.x86_64 2.0.1-1.el6.remi remi-safe
php73-php-pecl-rar.x86_64 4.0.0-4.el6.remi remi-safe
php73-php-pecl-rdkafka.x86_64 3.1.3-1.el6.remi remi-safe
php73-php-pecl-rdkafka4.x86_64 4.0.2-1.el6.remi remi-safe
php73-php-pecl-redis4.x86_64 4.3.0-1.el6.remi remi-safe
php73-php-pecl-redis5.x86_64 5.1.1-1.el6.remi remi-safe
php73-php-pecl-request.x86_64 1.0.0-0.10.b2.el6.remi remi-safe
php73-php-pecl-rrd.x86_64 2.0.1-6.el6.remi remi-safe
php73-php-pecl-runkit7.x86_64 3.0.0-1.el6.remi remi-safe
php73-php-pecl-scoutapm.x86_64 1.0.2-1.el6.remi remi-safe
php73-php-pecl-scrypt.x86_64 1.4.2-6.el6.remi remi-safe
php73-php-pecl-seasclick.x86_64 0.1.0-1.el6.remi remi-safe
php73-php-pecl-seaslog.x86_64 2.0.2-1.el6.remi remi-safe
php73-php-pecl-selinux.x86_64 0.4.2-1.el6.remi remi-safe
php73-php-pecl-skywalking.x86_64 3.2.4-1.el6.remi remi-safe
php73-php-pecl-solr2.x86_64 2.5.0-1.el6.remi remi-safe
php73-php-pecl-sphinx.x86_64 1.4.0-0.6.20181116.d958afb.el6.remi
php73-php-pecl-ssdeep.x86_64 1.1.0-4.el6.remi remi-safe
php73-php-pecl-ssh2.x86_64 1.2-1.el6.remi remi-safe
php73-php-pecl-stats.x86_64 2.0.3-6.el6.remi remi-safe
php73-php-pecl-stomp.x86_64 2.0.2-3.el6.remi remi-safe
php73-php-pecl-svm.x86_64 0.2.3-1.el6.remi remi-safe
php73-php-pecl-svn.x86_64 2.0.3-1.el6.remi remi-safe
php73-php-pecl-swoole4.x86_64 4.4.13-1.el6.remi remi-safe
php73-php-pecl-sync.x86_64 1.1.1-5.el6.remi remi-safe
php73-php-pecl-taint.x86_64 2.0.5-1.el6.remi remi-safe
php73-php-pecl-tcpwrap.x86_64 1.2.0-5.el6.remi remi-safe
php73-php-pecl-termbox.x86_64 0.1.3-7.el6.remi remi-safe
php73-php-pecl-timecop.x86_64 1.2.10-9.el6.remi remi-safe
php73-php-pecl-trace.x86_64 1.0.1-0.5.beta.el6.remi remi-safe
php73-php-pecl-trader.x86_64 0.5.0-3.el6.remi remi-safe
php73-php-pecl-translit.x86_64 0.6.3-1.el6.remi remi-safe
php73-php-pecl-uopz.x86_64 6.1.1-1.el6.remi remi-safe
php73-php-pecl-uploadprogress.x86_64 1.0.3.1-18.el6.remi remi-safe
php73-php-pecl-uuid.x86_64 1.1.0-1.el6.remi remi-safe
php73-php-pecl-vld.x86_64 0.16.0-1.el6.remi remi-safe
php73-php-pecl-xattr.x86_64 1.3.0-7.el6.remi remi-safe
php73-php-pecl-xdebug.x86_64 2.9.0-1.el6.remi remi-safe
php73-php-pecl-xdiff.x86_64 2.0.1-5.el6.remi remi-safe
php73-php-pecl-xhprof.x86_64 2.1.4-1.el6.remi remi-safe
php73-php-pecl-xlswriter.x86_64 1.3.2-2.el6.remi remi-safe
php73-php-pecl-xmldiff.x86_64 1.1.2-13.el6.remi remi-safe
php73-php-pecl-xmldiff-devel.x86_64 1.1.2-13.el6.remi remi-safe
php73-php-pecl-xxtea.x86_64 1.0.11-7.el6.remi remi-safe
php73-php-pecl-yac.x86_64 2.0.2-4.el6.remi remi-safe
php73-php-pecl-yaconf.x86_64 1.0.8-0.3.20180622.d5f267a.el6.remi
php73-php-pecl-yaconf-devel.x86_64 1.0.8-0.3.20180622.d5f267a.el6.remi
php73-php-pecl-yaf.x86_64 3.0.9-1.el6.remi remi-safe
php73-php-pecl-yaml.x86_64 2.0.4-1.el6.remi remi-safe
php73-php-pecl-yar.x86_64 2.0.5-1.el6.remi remi-safe
php73-php-pecl-yaz.x86_64 1.2.3-1.el6.remi remi-safe
php73-php-pecl-zip.x86_64 1.15.5-1.el6.remi remi-safe
php73-php-pecl-zmq.x86_64 1.1.3-8.el6.remi remi-safe
php73-php-pgsql.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-phalcon3.x86_64 3.4.5-1.el6.remi remi-safe
php73-php-phalcon4.x86_64 4.0.0-1.el6.remi remi-safe
php73-php-phpiredis.x86_64 1.0.0-10.el6.remi remi-safe
php73-php-pinba.x86_64 1.1.1-4.el6.remi remi-safe
php73-php-process.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-pspell.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-recode.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-smbclient.x86_64 1.0.0-1.el6.remi remi-safe
php73-php-snappy.x86_64 0.1.9-3.el6.remi remi-safe
php73-php-snmp.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-snuffleupagus.x86_64 0.5.0-1.el6.remi remi-safe
php73-php-soap.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-sodium.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-tidy.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-wkhtmltox.x86_64 0.3.2-0.4.20171112.fecc9af.el6.remi
php73-php-xml.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-xmlrpc.x86_64 7.3.13-1.el6.remi remi-safe
php73-php-zephir-parser.x86_64 1.3.3-1.el6.remi remi-safe
php73-php-zephir-parser-devel.x86_64 1.3.3-1.el6.remi remi-safe
php73-php-zstd.x86_64 0.7.5-1.el6.remi remi-safe
php73-process.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-pspell.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-recode.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-runtime.x86_64 2.0-1.el6.remi remi-safe
php73-scldevel.x86_64 2.0-1.el6.remi remi-safe
php73-snmp.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-soap.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-tidy.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-unit-php.x86_64 1.13.0-1.el6.remi remi-safe
php73-uwsgi-plugin-php.x86_64 2.0.17.1-2.el6.remi remi-safe
php73-xhprof.noarch 2.1.4-1.el6.remi remi-safe
php73-xml.x86_64 7.3.11-1.21.amzn1 amzn-updates ←★自分に必要
php73-xmlrpc.x86_64 7.3.11-1.21.amzn1 amzn-updates
php73-zephir.noarch 0.10.16-1.el6.remi remi-safe
 

 ※php70-mcryptがphp73に見つからなかったが、調べるとphp72で無くなったようだ

 

⑤ 古いバージョンを削除

sudo yum erase php70*

=======================
Package Arch Version Repository Size
=======================
Removing:
php70 x86_64 7.0.33-1.32.amzn1 @amzn-updates 9.4 M
php70-cli x86_64 7.0.33-1.32.amzn1 @amzn-updates 12 M
php70-common x86_64 7.0.33-1.32.amzn1 @amzn-updates 7.9 M
php70-devel x86_64 7.0.33-1.32.amzn1 @amzn-updates 9.1 M
php70-gd x86_64 7.0.33-1.32.amzn1 @amzn-updates 725 k
php70-json x86_64 7.0.33-1.32.amzn1 @amzn-updates 72 k
php70-mbstring x86_64 7.0.33-1.32.amzn1 @amzn-updates 2.7 M
php70-mcrypt x86_64 7.0.33-1.32.amzn1 @amzn-updates 79 k
php70-mysqlnd x86_64 7.0.33-1.32.amzn1 @amzn-updates 858 k
php70-pdo x86_64 7.0.33-1.32.amzn1 @amzn-updates 355 k
php70-process x86_64 7.0.33-1.32.amzn1 @amzn-updates 157 k
php70-xml x86_64 7.0.33-1.32.amzn1 @amzn-updates 787 k

Transaction Summary
============================================
Remove 12 Packages

 

⑥ 再インストール

sudo yum install php73 php73-cli php73-common php73-devel php73-gd php73-json php73-mbstring php73-mysqlnd php73-pdo php73-xml php73-process

 ⑦ 確認

php -v

PHP 7.3.11 (cli) (built: Oct 31 2019 18:30:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies 

 

⑧ /etc/php-7.3.iniを編集

$ sudo cp /etc/php-7.3.ini /etc/php-7.3.ini.org
$ sudo vi /etc/php-7.3.ini

以下の項目を/XXXで検索して、:wqで保存して終了
date.timezone = Asia/Tokyo
mbstring.language = Japanese
mbstring.internal_encoding = UTF-8
memory_limit = 1000M
expose_php = Off

 ⑨ sudo service httpd restart で再開して完了