さくらのVPSでPHP、MySQLのバージョンを上げる

現在パティオでは運営サービスにさくらのVPSを利用しています。
とても便利でいつも使わせて貰っているのですが、CentOS6.4のこのサーバにはデフォルトでPHP、MySQLは5.1という低いバージョンが入っています。
今回運営サービスで新たに位置情報やinnodbの全文日本語検索を利用しようと思ったのですが、MySQLで位置情報を効率よく扱う為の空間情報インデックスやフルテキストインデックスを使えるようになるのは5.6からという事らしいです。そんな訳でサーバにインストールされているMySQLとついでにPHPのバージョンをアップグレードする事にしました。
※以下はあくまで要所のメモであり、色々な試行錯誤で実際は時系列がグチャグチャなので再現性は保証できません。

# cat /etc/redhat-release

centosのバージョン確認。

# service mysqld stop

mysqlデーモン停止。私はやるの忘れてました;場合によってはmysql-server,mysql-clientをアンインストールしてから臨んだ方が良いかもしれません。

★以下の複雑な手順を介さなくても環境とアップグレード対象のバージョンによっては簡単な幾つかのコマンドで済むようです(引用:https://colo-ri.jp/develop/2011/10/update-php-and-mysql-on-sakura-vps-server.html)。

# yum install https://dev.mysql.com/get/mysql57-community-release-el6-11.noarch.rpm          
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: mirrors.mediatemple.net
 * updates: ftp.iij.ad.jp
Setting up Install Process
mysql57-community-release-el6-11.noarch.rpm                                             |  25 kB     00:00     
Examining /var/tmp/yum-root-vubl2M/mysql57-community-release-el6-11.noarch.rpm: mysql57-community-release-el6-11.noarch
Marking /var/tmp/yum-root-vubl2M/mysql57-community-release-el6-11.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql57-community-release.noarch 0:el6-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                        Arch        Version        Repository                                     Size
===============================================================================================================
Installing:
 mysql57-community-release      noarch      el6-11         /mysql57-community-release-el6-11.noarch       31 k

Transaction Summary
===============================================================================================================
Install       1 Package(s)

Total size: 31 k
Installed size: 31 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql57-community-release-el6-11.noarch                                                     1/1 
  Verifying  : mysql57-community-release-el6-11.noarch                                                     1/1 

Installed:
  mysql57-community-release.noarch 0:el6-11                                                                    

Complete!

mysqlコミュニティのリポジトリをインストールします。https://dev.mysql.com/downloads/repo/yum/ここを参照してリンクをコピペ。CentOS6ならこのままのリンクでOK。

# yum install mysql-community-server                                                         
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: mirror.dmmlabs.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: mirror.bebout.net
 * updates: ftp.iij.ad.jp
mysql57-community                                                                       | 2.5 kB     00:00     
mysql57-community/primary_db                                                            | 130 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.7.20-1.el6 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 5.7.20-1.el6 for package: mysql-community-server-5.7.20-1.el6.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 5.7.9 for package: mysql-community-server-5.7.20-1.el6.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.7.20-1.el6 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) >= 5.7.9 for package: mysql-community-client-5.7.20-1.el6.x86_64
---> Package mysql-community-common.x86_64 0:5.7.20-1.el6 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.7.20-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                          Arch             Version                   Repository                   Size
===============================================================================================================
Installing:
 mysql-community-server           x86_64           5.7.20-1.el6              mysql57-community           152 M
Installing for dependencies:
 mysql-community-client           x86_64           5.7.20-1.el6              mysql57-community            23 M
 mysql-community-common           x86_64           5.7.20-1.el6              mysql57-community           329 k
 mysql-community-libs             x86_64           5.7.20-1.el6              mysql57-community           2.1 M

Transaction Summary
===============================================================================================================
Install       4 Package(s)

Total download size: 177 M
Installed size: 882 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): mysql-community-client-5.7.20-1.el6.x86_64.rpm                                   |  23 MB     00:02     
(2/4): mysql-community-common-5.7.20-1.el6.x86_64.rpm                                   | 329 kB     00:00     
(3/4): mysql-community-libs-5.7.20-1.el6.x86_64.rpm                                     | 2.1 MB     00:00     
(4/4): mysql-community-server-5.7.20-1.el6.x86_64.rpm                                   | 152 MB     00:14     
---------------------------------------------------------------------------------------------------------------
Total                                                                           11 MB/s | 177 MB     00:16     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-common-5.7.20-1.el6.x86_64                                                  1/4 
  Installing : mysql-community-libs-5.7.20-1.el6.x86_64                                                    2/4 
  Installing : mysql-community-client-5.7.20-1.el6.x86_64                                                  3/4 
  Installing : mysql-community-server-5.7.20-1.el6.x86_64                                                  4/4 
  Verifying  : mysql-community-common-5.7.20-1.el6.x86_64                                                  1/4 
  Verifying  : mysql-community-libs-5.7.20-1.el6.x86_64                                                    2/4 
  Verifying  : mysql-community-client-5.7.20-1.el6.x86_64                                                  3/4 
  Verifying  : mysql-community-server-5.7.20-1.el6.x86_64                                                  4/4 

Installed:
  mysql-community-server.x86_64 0:5.7.20-1.el6                                                                 

Dependency Installed:
  mysql-community-client.x86_64 0:5.7.20-1.el6           mysql-community-common.x86_64 0:5.7.20-1.el6          
  mysql-community-libs.x86_64 0:5.7.20-1.el6            

Complete!

その後、mysqlコミュニティ版のサーバパッケージをインストールします。上では漏れてますが、mysql-community-develも後でインストールしました。
既存のmysql-***というパッケージがmysql-community-***という名前の物に置き換わったという事です。

# rpm -import http://rpms.famillecollet.com/RPM-GPG-KEY-remi

Remiパッケージ用のGPGキーインストール。

またここで、yumで何かと[14: problem making ssl connection]というメッセージが出ていたのでnssパッケージをインストールしておきました。
(参考:https://qiita.com/nagais/items/6a6431ca5137f18bf054)

sudo yum install -y nss
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Could not get metalink https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=x86_64 error was
14: problem making ssl connection
 * base: ftp.iij.ad.jp
 * epel: ftp.riken.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: mirrors.thzhost.com
 * updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nss.x86_64 0:3.14.0.0-12.el6 will be updated
--> Processing Dependency: nss = 3.14.0.0-12.el6 for package: nss-tools-3.14.0.0-12.el6.x86_64
--> Processing Dependency: nss = 3.14.0.0-12.el6 for package: nss-sysinit-3.14.0.0-12.el6.x86_64
---> Package nss.x86_64 0:3.28.4-4.el6_9 will be an update
--> Processing Dependency: nss-util >= 3.28.3 for package: nss-3.28.4-4.el6_9.x86_64
--> Processing Dependency: nss-softokn(x86-64) >= 3.14.3-22 for package: nss-3.28.4-4.el6_9.x86_64
--> Processing Dependency: nspr >= 4.13.0 for package: nss-3.28.4-4.el6_9.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.24)(64bit) for package: nss-3.28.4-4.el6_9.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.21)(64bit) for package: nss-3.28.4-4.el6_9.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.17.1)(64bit) for package: nss-3.28.4-4.el6_9.x86_64
--> Processing Dependency: libnssutil3.so(NSSUTIL_3.15)(64bit) for package: nss-3.28.4-4.el6_9.x86_64
--> Running transaction check
---> Package nspr.x86_64 0:4.9.2-1.el6 will be updated
---> Package nspr.x86_64 0:4.13.1-1.el6 will be an update
---> Package nss-softokn.x86_64 0:3.12.9-11.el6 will be updated
---> Package nss-softokn.x86_64 0:3.14.3-23.3.el6_8 will be an update
--> Processing Dependency: nss-softokn-freebl(x86-64) >= 3.14.3-23.3.el6_8 for package: nss-softokn-3.14.3-23.3.el6_8.x86_64
---> Package nss-sysinit.x86_64 0:3.14.0.0-12.el6 will be updated
---> Package nss-sysinit.x86_64 0:3.28.4-4.el6_9 will be an update
---> Package nss-tools.x86_64 0:3.14.0.0-12.el6 will be updated
---> Package nss-tools.x86_64 0:3.28.4-4.el6_9 will be an update
---> Package nss-util.x86_64 0:3.14.0.0-2.el6 will be updated
---> Package nss-util.x86_64 0:3.28.4-1.el6_9 will be an update
--> Running transaction check
---> Package nss-softokn-freebl.x86_64 0:3.12.9-11.el6 will be updated
---> Package nss-softokn-freebl.x86_64 0:3.14.3-23.3.el6_8 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================
 Package                         Arch                Version                        Repository            Size
===============================================================================================================
Updating:
 nss                             x86_64              3.28.4-4.el6_9                 updates              879 k
Updating for dependencies:
 nspr                            x86_64              4.13.1-1.el6                   base                 114 k
 nss-softokn                     x86_64              3.14.3-23.3.el6_8              base                 262 k
 nss-softokn-freebl              x86_64              3.14.3-23.3.el6_8              base                 168 k
 nss-sysinit                     x86_64              3.28.4-4.el6_9                 updates               51 k
 nss-tools                       x86_64              3.28.4-4.el6_9                 updates              447 k
 nss-util                        x86_64              3.28.4-1.el6_9                 updates               68 k

Transaction Summary
===============================================================================================================
Upgrade       7 Package(s)

Total download size: 1.9 M
Downloading Packages:
(1/7): nspr-4.13.1-1.el6.x86_64.rpm                                                     | 114 kB     00:00     
(2/7): nss-3.28.4-4.el6_9.x86_64.rpm                                                    | 879 kB     00:00     
(3/7): nss-softokn-3.14.3-23.3.el6_8.x86_64.rpm                                         | 262 kB     00:00     
(4/7): nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64.rpm                                  | 168 kB     00:00     
(5/7): nss-sysinit-3.28.4-4.el6_9.x86_64.rpm                                            |  51 kB     00:00     
(6/7): nss-tools-3.28.4-4.el6_9.x86_64.rpm                                              | 447 kB     00:00     
(7/7): nss-util-3.28.4-1.el6_9.x86_64.rpm                                               |  68 kB     00:00     
---------------------------------------------------------------------------------------------------------------
Total                                                                          2.2 MB/s | 1.9 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : nspr-4.13.1-1.el6.x86_64                                                                   1/14 
  Updating   : nss-util-3.28.4-1.el6_9.x86_64                                                             2/14 
  Updating   : nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64                                                3/14 
  Updating   : nss-softokn-3.14.3-23.3.el6_8.x86_64                                                       4/14 
  Updating   : nss-sysinit-3.28.4-4.el6_9.x86_64                                                          5/14 
  Updating   : nss-3.28.4-4.el6_9.x86_64                                                                  6/14 
  Updating   : nss-tools-3.28.4-4.el6_9.x86_64                                                            7/14 
  Cleanup    : nss-tools-3.14.0.0-12.el6.x86_64                                                           8/14 
  Cleanup    : nss-sysinit-3.14.0.0-12.el6.x86_64                                                         9/14 
  Cleanup    : nss-3.14.0.0-12.el6.x86_64                                                                10/14 
  Cleanup    : nss-softokn-3.12.9-11.el6.x86_64                                                          11/14 
  Cleanup    : nss-util-3.14.0.0-2.el6.x86_64                                                            12/14 
  Cleanup    : nspr-4.9.2-1.el6.x86_64                                                                   13/14 
  Cleanup    : nss-softokn-freebl-3.12.9-11.el6.x86_64                                                   14/14 
  Verifying  : nss-tools-3.28.4-4.el6_9.x86_64                                                            1/14 
  Verifying  : nss-3.28.4-4.el6_9.x86_64                                                                  2/14 
  Verifying  : nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64                                                3/14 
  Verifying  : nss-softokn-3.14.3-23.3.el6_8.x86_64                                                       4/14 
  Verifying  : nspr-4.13.1-1.el6.x86_64                                                                   5/14 
  Verifying  : nss-util-3.28.4-1.el6_9.x86_64                                                             6/14 
  Verifying  : nss-sysinit-3.28.4-4.el6_9.x86_64                                                          7/14 
  Verifying  : nss-tools-3.14.0.0-12.el6.x86_64                                                           8/14 
  Verifying  : nss-3.14.0.0-12.el6.x86_64                                                                 9/14 
  Verifying  : nss-util-3.14.0.0-2.el6.x86_64                                                            10/14 
  Verifying  : nss-sysinit-3.14.0.0-12.el6.x86_64                                                        11/14 
  Verifying  : nspr-4.9.2-1.el6.x86_64                                                                   12/14 
  Verifying  : nss-softokn-3.12.9-11.el6.x86_64                                                          13/14 
  Verifying  : nss-softokn-freebl-3.12.9-11.el6.x86_64                                                   14/14 

Updated:
  nss.x86_64 0:3.28.4-4.el6_9                                                                                  

Dependency Updated:
  nspr.x86_64 0:4.13.1-1.el6                                nss-softokn.x86_64 0:3.14.3-23.3.el6_8            
  nss-softokn-freebl.x86_64 0:3.14.3-23.3.el6_8             nss-sysinit.x86_64 0:3.28.4-4.el6_9               
  nss-tools.x86_64 0:3.28.4-4.el6_9                         nss-util.x86_64 0:3.28.4-1.el6_9                  

Complete!
# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
http://rpms.famillecollet.com/enterprise/remi-release-6.rpm を取得中
警告: /var/tmp/rpm-tmp.iYHigB: ヘッダ V4 DSA/SHA1 Signature, key ID : NOKEY
準備中...                ########################################### [100%]
   1:remi-release           ########################################### [100%]

Remiリポジトリをインストール。
cd /etc/yum.repos.d;wget http://rpms.famillecollet.com/remi-enterprise.repo でも可?

ちなみにmysql関係パッケージのプレフィックスがmysql-community-***になったように、
php関係パッケージのプレフィクスも通常のphpパッケージに関するもの(関連パッケージのプレフィクスはphp-***)の他にPHP5.4ならphp54パッケージとそれに関連する(プレフィクスはphp54-***)バージョン別のパッケージのシリーズがあり、バージョン別のPHPを共存させる事ができます(参照:https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q14146889884)。
私は作業中はその辺りを知らなかったので、色んなサイトのやり方を色々試した結果php54のシリーズを無駄にインストールしてしまっていました。実際どのパッケージを利用するかはお好みでどうぞ。

yum update --enablerepo=remi php*

とするか、

yum erase php*
yum update --enablerepo=remi php*

と一旦綺麗に消して入れ直します。

# yum install mysql-community-libs-compat                                                                                                            
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: mirrors.thzhost.com
 * updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-libs-compat.x86_64 0:5.7.20-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package                                            Arch                          Version                               Repository                                Size
=======================================================================================================================================================================
Installing:
 mysql-community-libs-compat                        x86_64                        5.7.20-1.el6                          mysql57-community                        1.6 M

Transaction Summary
=======================================================================================================================================================================
Install       1 Package(s)

Total download size: 1.6 M
Installed size: 5.4 M
Is this ok [y/N]: y
Downloading Packages:
mysql-community-libs-compat-5.7.20-1.el6.x86_64.rpm                                                                                             | 1.6 MB     00:00     
Running rpm_check_debug
Running Transaction Test


Transaction Check Error:
  file /usr/lib64/mysql/libmysqlclient.so.16.0.0 from install of mysql-community-libs-compat-5.7.20-1.el6.x86_64 conflicts with file from package compat-mysql51-5.1.73-1.el6.remi.x86_64
  file /usr/lib64/mysql/libmysqlclient_r.so.16.0.0 from install of mysql-community-libs-compat-5.7.20-1.el6.x86_64 conflicts with file from package compat-mysql51-5.1.73-1.el6.remi.x86_64

mysql絡みの依存性を色々解決してくれるというmysql-community-libs-compatパッケージをインストールしようとすると既存のcompat-mysql51と衝突してしまいインストールできません。
compat-mysql51をアンインストールしようとすると・・・

# yum erase compat-mysql*
Loaded plugins: fastestmirror, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package compat-mysql51.x86_64 0:5.1.73-1.el6.remi will be erased
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: 2:postfix-2.6.6-8.el6.x86_64
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: 2:postfix-2.6.6-8.el6.x86_64
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: perl-DBD-MySQL-4.013-3.el6.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be erased
---> Package postfix.x86_64 2:2.6.6-8.el6 will be erased
--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-16.el6_8.2.x86_64
--> Running transaction check
---> Package cronie.x86_64 0:1.4.4-16.el6_8.2 will be erased
--> Processing Dependency: cronie = 1.4.4-16.el6_8.2 for package: cronie-anacron-1.4.4-16.el6_8.2.x86_64
--> Running transaction check
---> Package cronie-anacron.x86_64 0:1.4.4-16.el6_8.2 will be erased
--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch
--> Restarting Dependency Resolution with new changes.
--> Running transaction check
---> Package crontabs.noarch 0:1.10-33.el6 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package                                    Arch                               Version                                         Repository                         Size
=======================================================================================================================================================================
Removing:
 compat-mysql51                             x86_64                             5.1.73-1.el6.remi                               @remi                             4.1 M
Removing for dependencies:
 cronie                                     x86_64                             1.4.4-16.el6_8.2                                @base                             174 k
 cronie-anacron                             x86_64                             1.4.4-16.el6_8.2                                @base                              43 k
 crontabs                                   noarch                             1.10-33.el6                                     @base                             2.4 k
 perl-DBD-MySQL                             x86_64                             4.013-3.el6                                     @base                             338 k
 postfix                                    x86_64                             2:2.6.6-8.el6                                   @base                             9.7 M

Transaction Summary
=======================================================================================================================================================================
Remove        6 Package(s)

色々消すとヤバそうなものがずらずらと依存関係で出てきます。
設定ファイルが消えるわけでは無いでしょうから、このまま消して入れ直しても問題ないと思いますが、これを避けたい場合にはyumのシェルモードを使います。(参照:https://foxmaster.blog/blog/archives/157)

# yum shell
Loaded plugins: fastestmirror, security
Setting up Yum Shell
> install mysql-community-libs-compat
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * remi-safe: mirror.bebout.net
 * updates: ftp.iij.ad.jp
Setting up Install Process
> erase compat-mysql51-5.1.73-1.el6.remi.x86_64      
Setting up Remove Process
> transaction

=======================================================================================================================================================================
 Package                                           Arch                         Version                                  Repository                               Size
=======================================================================================================================================================================
Installing:
 mysql-community-libs-compat                       x86_64                       5.7.20-1.el6                             mysql57-community                       1.6 M
Removing:
 compat-mysql51                                    x86_64                       5.1.73-1.el6.remi                        @remi                                   4.1 M

Transaction Summary
=======================================================================================================================================================================
Install       1 Package(s)
Remove        1 Package(s)

> run
--> Running transaction check
---> Package compat-mysql51.x86_64 0:5.1.73-1.el6.remi will be erased
---> Package mysql-community-libs-compat.x86_64 0:5.7.20-1.el6 will be installed
--> Finished Dependency Resolution

=======================================================================================================================================================================
 Package                                           Arch                         Version                                  Repository                               Size
=======================================================================================================================================================================
Installing:
 mysql-community-libs-compat                       x86_64                       5.7.20-1.el6                             mysql57-community                       1.6 M
Removing:
 compat-mysql51                                    x86_64                       5.1.73-1.el6.remi                        @remi                                   4.1 M

Transaction Summary
=======================================================================================================================================================================
Install       1 Package(s)
Remove        1 Package(s)

Total size: 1.6 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : mysql-community-libs-compat-5.7.20-1.el6.x86_64                                                                                                     1/2 
  Erasing    : compat-mysql51-5.1.73-1.el6.remi.x86_64                                                                                                             2/2 
  Verifying  : mysql-community-libs-compat-5.7.20-1.el6.x86_64                                                                                                     1/2 
  Verifying  : compat-mysql51-5.1.73-1.el6.remi.x86_64                                                                                                             2/2 

Removed:
  compat-mysql51.x86_64 0:5.1.73-1.el6.remi                                                                                                                            

Installed:
  mysql-community-libs-compat.x86_64 0:5.7.20-1.el6                                                                                                                    

Finished Transaction
> exit
Leaving Shell

これでcompat-mysql51を消しつつmysql-community-libs-compatをインストールする事が出来、依存関係のあるパッケージはアンインストールせずに済みました。
同じようにシェルモードを利用してダウングレードもできるそうですよ。

# yum --enablerepo=remi install php-mysql                                                                                                            
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * remi: mirrors.thzhost.com
 * remi-safe: mirrors.thzhost.com
 * updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.x86_64 0:5.4.45-13.el6.remi will be installed
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: php-mysql-5.4.45-13.el6.remi.x86_64
Package mysql-libs-5.5.58-1.el6.remi.x86_64 is obsoleted by mysql-community-libs-5.7.20-1.el6.x86_64 which is already installed
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_16)(64bit) for package: php-mysql-5.4.45-13.el6.remi.x86_64
Package mysql-libs-5.5.58-1.el6.remi.x86_64 is obsoleted by mysql-community-libs-5.7.20-1.el6.x86_64 which is already installed
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: php-mysql-5.4.45-13.el6.remi.x86_64
Package mysql-libs-5.5.58-1.el6.remi.x86_64 is obsoleted by mysql-community-libs-5.7.20-1.el6.x86_64 which is already installed
--> Finished Dependency Resolution
Error: Package: php-mysql-5.4.45-13.el6.remi.x86_64 (remi)
           Requires: libmysqlclient.so.18()(64bit)
           Available: mysql-libs-5.5.57-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18()(64bit)
           Available: mysql-libs-5.5.58-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18()(64bit)
           Available: mysql-libs-5.1.73-8.el6_8.i686 (base)
               Not found
Error: Package: php-mysql-5.4.45-13.el6.remi.x86_64 (remi)
           Requires: libmysqlclient.so.18(libmysqlclient_16)(64bit)
           Available: mysql-libs-5.5.57-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18(libmysqlclient_16)(64bit)
           Available: mysql-libs-5.5.58-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18(libmysqlclient_16)(64bit)
           Available: mysql-libs-5.1.73-8.el6_8.i686 (base)
               Not found
Error: Package: php-mysql-5.4.45-13.el6.remi.x86_64 (remi)
           Requires: libmysqlclient.so.18(libmysqlclient_18)(64bit)
           Available: mysql-libs-5.5.57-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18(libmysqlclient_18)(64bit)
           Available: mysql-libs-5.5.58-1.el6.remi.x86_64 (remi)
               libmysqlclient.so.18(libmysqlclient_18)(64bit)
           Available: mysql-libs-5.1.73-8.el6_8.i686 (base)
               Not found
 You could try using --skip-broken to work around the problem

php-mysqlというパッケージのアップデートでエラーが出ています(php-mysqlが無いとDBに関するドライバが無い状態なので、PHPからPDOを介してMySQLに接続してもConnection failed:could not find driverというエラーが出ます)。どういう内容かというと、libmysqlclient.so.18というライブラリがphp-mysqlに必要で、それはmysql-libsというパッケージに含まれているのですが、mysql-community-libs-compatというパッケージにも含まれており置き換えられているのですが、既存のmysql-libsの方じゃないと嫌だとゴネられてるようでうまくいかない?ようです。

で、色々やったのですが、なかなか上手く行かず・・・

(私の場合は試行錯誤するも面倒になり、ここで一度phpとmysql関連パッケージを削除し、php関連はremiリポジトリからクリーンインストールし、mysql-community版も入れ直しました。
※スムーズにmysql-community版mysqlインストールとremi版phpアップデートが上手く行くならこのような手順は必要ありません。
※削除して入れ直す場合は削除時に一覧表示されたパッケージのみ入れ直します。
※削除する場合、特別な依存関係のあるパッケージが削除候補に表示された場合は削除に気を付けて下さい。)

更にphp-mysqlを何とかインストールしようと頑張りますが、どうにも上手く行きません。
すると色々調べた結果、php-mysqlの現行版は推奨パッケージ名がphp-mysqlndになっていた(php54-***といったプレフィクス付きのものも同様にphp54-php-mysqlndという風になります)そうです。こちらを入れるとあっさり解決。

yum install --enablerepo=remi php-mysqlnd                                                                                                          
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * remi: mirrors.mediatemple.net
 * remi-safe: mirrors.mediatemple.net
 * updates: ftp.iij.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-mysqlnd.x86_64 0:5.4.45-13.el6.remi will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package                                  Arch                                Version                                          Repository                         Size
=======================================================================================================================================================================
Installing:
 php-mysqlnd                              x86_64                              5.4.45-13.el6.remi                               remi                              3.7 M

Transaction Summary
=======================================================================================================================================================================
Install       1 Package(s)

Total download size: 3.7 M
Installed size: 4.9 M
Is this ok [y/N]: y
Downloading Packages:
php-mysqlnd-5.4.45-13.el6.remi.x86_64.rpm                                                                                                       | 3.7 MB     00:01     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : php-mysqlnd-5.4.45-13.el6.remi.x86_64                                                                                                               1/1 
  Verifying  : php-mysqlnd-5.4.45-13.el6.remi.x86_64                                                                                                               1/1 

Installed:
  php-mysqlnd.x86_64 0:5.4.45-13.el6.remi                                                                                                                              

Complete!
# mysqld --version
mysqld  Ver 5.7.20 for Linux on x86_64 (MySQL Community Server (GPL))
# php -v
PHP 5.4.45 (cli) (built: Feb 18 2017 15:55:26) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

ちゃんとphpとmysqlのバージョンが上がった事を確認しましょう。

# vi /etc/php.ini.rpmsave 
# vi /etc/my.cnf.rpmsave

前バージョンの設定ファイルがバックアップされているので適宜編集します。phpの新verではAPCが廃止、mysqlでは複数のパラメータが廃止されていたので修正しました。
再起動時にmysqld.logファイルに廃止パラメータが原因で起動失敗した旨が出力されますので参照してください。

# service php-fpm restart
# service nginx restart
# service mysqld restart

サーバ再起動。

# /usr/bin/mysqld_safe --skip-grant-tables &
# mysql_upgrade -uroot -p

これはMySQLアップデート後にテーブル更新が必要というようなメッセージがログに出て起動出来ない人向け。テーブルを更新します(参照:https://qiita.com/riritea/items/31644f023ad0ab0dd0bb)。

こんな感じで無事にサーバ環境を更新する事ができました。システムは正常に動作しています。・・・php-mysqlは今もインストール出来ないままです。

大丈夫・・・かな?

meisiyou
VPS面倒だけどAWSより安いから使うにゃ!
この記事が役に立ったら★付けて欲しいにゃ。
1 Star2 Stars3 Stars4 Stars5 Stars (まだ投票されていません)
Loading...

    コメント