スタッフブログ

  • 最新配信
  • RSS

CentOSのPHP5.1をPHP5.2にアップグレードする方法

suin : PHP 2011/2/22 16:03

Blogger's Avatar

CentOSのPHPのデフォルトバージョンは5.1です。なので、PHP5.2にアップデートすることがよくあるので備忘録として手順をまとめておきます。

手順

とりあえずサーバを停止

sudo /etc/init.d/httpd stop
sudo /etc/init.d/mysqld stop

リポジトリを追加する。

sudo vi /etc/yum.repos.d/utterramblings.repo
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

アップデートをかける。

sudo yum update php -y

実際はここではまりました。ハマった詳細は後述。

リポジトリをOFFにする。enabledを0に書き換えます。

sudo vi /etc/yum.repos.d/utterramblings.repo
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=0
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

サーバを起動する。

sudo /etc/init.d/httpd start
sudo /etc/init.d/mysqld start

はまったところ

yum update phpで次のようなエラーが出てアップデートできずはまりました。

$ sudo yum update php
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.yz.yamagata-u.ac.jp
 * base: ftp.yz.yamagata-u.ac.jp
 * extras: ftp.yz.yamagata-u.ac.jp
 * updates: ftp.yz.yamagata-u.ac.jp
Excluding Packages from CentOS-5 - Base
Finished
Setting up Update Process
Resolving Dependencies
--> Running transaction check
--> Processing Dependency: php = 5.1.6-27.el5_5.3 for package: php-devel
---> Package php.x86_64 0:5.2.16-jason.1 set to be updated
--> Processing Dependency: php-common = 5.2.16-jason.1 for package: php
--> Processing Dependency: php-cli = 5.2.16-jason.1 for package: php
--> Running transaction check
---> Package php-cli.x86_64 0:5.2.16-jason.1 set to be updated
--> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-pdo
--> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-ldap
--> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-mbstring
--> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-gd
--> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php-mysql
---> Package php-common.x86_64 0:5.2.16-jason.1 set to be updated
---> Package php-devel.x86_64 0:5.2.16-jason.1 set to be updated
--> Running transaction check
---> Package php-gd.x86_64 0:5.2.16-jason.1 set to be updated
---> Package php-ldap.x86_64 0:5.2.16-jason.1 set to be updated
---> Package php-mbstring.x86_64 0:5.2.16-jason.1 set to be updated
---> Package php-mysql.x86_64 0:5.2.16-jason.1 set to be updated
--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16)(64bit) for package: php-mysql
--> Processing Dependency: libmysqlclient.so.16()(64bit) for package: php-mysql
---> Package php-pdo.x86_64 0:5.2.16-jason.1 set to be updated
--> Running transaction check
--> Processing Dependency: libmysqlclient.so.15()(64bit) for package: mysql-connector-odbc
--> Processing Dependency: libmysqlclient.so.15()(64bit) for package: perl-DBD-MySQL
--> Processing Dependency: libmysqlclient.so.15()(64bit) for package: mysql-server
--> Processing Dependency: libmysqlclient.so.15()(64bit) for package: libdbi-dbd-mysql
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: mysql-connector-odbc
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: perl-DBD-MySQL
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: mysql-server
--> Processing Dependency: libmysqlclient.so.15(libmysqlclient_15)(64bit) for package: libdbi-dbd-mysql
--> Processing Dependency: libmysqlclient_r.so.15()(64bit) for package: mysql-connector-odbc
--> Processing Dependency: libmysqlclient_r.so.15()(64bit) for package: mysql-server
--> Processing Dependency: libmysqlclient_r.so.15()(64bit) for package: MySQL-python
--> Processing Dependency: libmysqlclient_r.so.15(libmysqlclient_15)(64bit) for package: mysql-connector-odbc
--> Processing Dependency: libmysqlclient_r.so.15(libmysqlclient_15)(64bit) for package: mysql-server
--> Processing Dependency: libmysqlclient_r.so.15(libmysqlclient_15)(64bit) for package: MySQL-python
---> Package mysql.x86_64 0:5.1.52-jason.1 set to be updated
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.52-jason.1 set to be updated
---> Package mysqlclient15.x86_64 0:5.0.91-1.jason.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================================================
 Package                                          Arch                                      Version                                             Repository                                         Size
========================================================================================================================================================================================================
Updating:
 php                                              x86_64                                    5.2.16-jason.1                                      utterramblings                                    3.8 M
Installing for dependencies:
 mysqlclient15                                    x86_64                                    5.0.91-1.jason.1                                    utterramblings                                    2.0 M
Updating for dependencies:
 mysql                                            x86_64                                    5.1.52-jason.1                                      utterramblings                                    3.5 M
 mysql-server                                     x86_64                                    5.1.52-jason.1                                      utterramblings                                     13 M
 php-cli                                          x86_64                                    5.2.16-jason.1                                      utterramblings                                    2.6 M
 php-common                                       x86_64                                    5.2.16-jason.1                                      utterramblings                                    522 k
 php-devel                                        x86_64                                    5.2.16-jason.1                                      utterramblings                                    557 k
 php-gd                                           x86_64                                    5.2.16-jason.1                                      utterramblings                                    348 k
 php-ldap                                         x86_64                                    5.2.16-jason.1                                      utterramblings                                     63 k
 php-mbstring                                     x86_64                                    5.2.16-jason.1                                      utterramblings                                    1.4 M
 php-mysql                                        x86_64                                    5.2.16-jason.1                                      utterramblings                                    280 k
 php-pdo                                          x86_64                                    5.2.16-jason.1                                      utterramblings                                    169 k

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

Total size: 28 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test


Transaction Check Error:
  file /etc/my.cnf from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/man/man1/my_print_defaults.1.gz from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/man/man1/mysql.1.gz from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/man/man1/mysql_config.1.gz from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/man/man1/mysql_find_rows.1.gz from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/man/man1/mysql_waitpid.1.gz from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/man/man1/mysqlaccess.1.gz from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/man/man1/mysqladmin.1.gz from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/man/man1/mysqldump.1.gz from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/man/man1/mysqlshow.1.gz from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/charsets/Index.xml from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/charsets/cp1250.xml from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/czech/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/danish/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/dutch/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/english/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/estonian/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/french/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/german/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/greek/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/italian/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/japanese/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/korean/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/polish/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/romanian/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/russian/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/serbian/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/slovak/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/spanish/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/swedish/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386
  file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-5.1.52-jason.1.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.4.i386

Error Summary
-------------

どうやらこれは、mysql.x86_64とmysql.i386がコンフリクトしているとのことのようです。 mysql.i386を使ってない場合、yum removeしていいとのことでした。

mysqlのどもパッケージは入っているか確認します。

$ yum list installed | grep mysql
libdbi-dbd-mysql.x86_64                   0.8.1a-1.2.2                 installed
mysql.i386                                5.0.77-4.el5_5.4             installed
mysql.x86_64                              5.0.77-4.el5_5.4             installed
mysql-connector-odbc.x86_64               3.51.26r1127-1.el5           installed
mysql-server.x86_64                       5.0.77-4.el5_5.4             installed
php-mysql.x86_64                          5.1.6-27.el5_5.3             installed

.i386なのはmysql.i386だけでした。次に、yum remove(アンインストール)するまえに本当に、使ってないか確認します。

$ mysql --version
mysql  Ver 14.14 Distrib 5.1.52, for redhat-linux-gnu (x86_64) using readline 5.1

i386は使われていなく、x86_64が使われていることが分かりましたので、yum removeします。

$ sudo yum remove mysql.i386
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.i386 0:5.0.77-4.el5_5.4 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================================================
 Package                                     Arch                                       Version                                                   Repository                                       Size
========================================================================================================================================================================================================
Removing:
 mysql                                       i386                                       5.0.77-4.el5_5.4                                          installed                                       7.9 M

Transaction Summary
========================================================================================================================================================================================================
Remove        1 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing        : mysql                                                                                                                                                                            1/1 

Removed:
  mysql.i386 0:5.0.77-4.el5_5.4    

アンインストールされたようです。

一応、yum list installedでremoveされたか確認します。

$ yum list installed | grep mysql
libdbi-dbd-mysql.x86_64                   0.8.1a-1.2.2                 installed
mysql.i386                                5.0.77-4.el5_5.4             installed
mysql.x86_64                              5.0.77-4.el5_5.4             installed
mysql-connector-odbc.x86_64               3.51.26r1127-1.el5           installed
mysql-server.x86_64                       5.0.77-4.el5_5.4             installed
php-mysql.x86_64                          5.1.6-27.el5_5.3             installed

この後、再度 yum update phpをしたらうまくPHPがアップデートされました。

トラックバック

スタッフブログ最新
カテゴリ一覧

〒104-0061 東京都中央区銀座1丁目3番3号 G1ビル7階
お問い合わせ TEL 03-3524-8860

Copyright(c) 2012 RYUS.All Rights Reserved.