アーカイブ

2014 年 12 月 12 日 のアーカイブ

phpを最新バージョンにアップデート その1

2014 年 12 月 12 日 Comments off

mysqlが古いと怒られたのですがとりあえずデータベースのほうをバージョンアップするのは、まだ怖いのでphpをはじめにバージョンアップします。
まず現在のPHPのバージョン確認


# php -version
PHP 5.3.3 (cli) (built: Oct 30 2014 20:12:53)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

インストールされているバージョンは、5.3.3です。

では、yumで今最新のPHPを確認してみます。

# yum list php
読み込んだプラグイン:downloadonly, fastestmirror, priorities, security
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* rpmforge: ftp.riken.jp
* updates: ftp.iij.ad.jp
29 packages excluded due to repository priority protections
インストール済みパッケージ
php.x86_64 5.3.3-40.el6_6 @updates

ということで上記は、インストール済みが最新のようです。

通常のレポジトリでは、5.3.3ですがPHPのサイトで確認すると5.6.3が最新のようです。
5.5以上にしないと動作しないので最新のバージョンが手に入るレポジトリからダウンロード、インストールします。

他のサイトを参考にするとrepoforge,remi,EPELのレポジトリを入れると依存関係の不具合も少なくいいようなので入れてみます。

とりあえず自分のサーバのアーキテクチャの確認

[root@local~]# arch
x86_64

64bitなのでx86_64のものをwgetしてきます。

[root@local~]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[root@local~]# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
[root@local~]# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

それぞれダウンロードしてカレントディレクトリに以下のようにあるはずです。

[root@local~]# ls -la *rpm
-rw-r--r-- 1 root root 14540 11月  6 00:31 2012 epel-release-6-8.noarch.rpm
-rw-r--r-- 1 root root  5688  3月  1 19:55 2014 remi-release-6.rpm
-rw-r--r-- 1 root root 12640  3月 21 00:59 2013 rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

これをレポジトリにセットアップします。
以前に入れていた場合、下記のrpmコマンドですでにインストールされている旨が表示されるはず。
下の場合2つは、以前にインストールしていた模様。

[root@local ~]# rpm -Uvh epel-release-6-8.noarch.rpm
パッケージ epel-release-6-8.noarch は既にインストールされています。
[root@local ~]# rpm -Uvh remi-release-6.rpm
警告: remi-release-6.rpm: ヘッダ V3 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
準備中...                ########################################### [100%]
[root@local ~]# rpm -Uvh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
パッケージ rpmforge-release-0.5.3-1.el6.rf.x86_64 は既にインストールされています。

レポジトリが入ったかを確認する。
epel.repo、rpmforge.repo、remi.repoがあるかを確認する。

[root@local ~]# ls -la /etc/yum.repos.d/
合計 64
drwxr-xr-x.  2 root root 4096 12月 10 15:50 2014 .
drwxr-xr-x. 83 root root 4096 12月 11 04:48 2014 ..
-rw-r--r--   1 root root 1958 10月 11 04:01 2014 CentOS-Base.repo
-rw-r--r--   1 root root 1991 10月 23 20:41 2014 CentOS-Base.repo.rpmnew
-rw-r--r--   1 root root  647 10月 23 20:41 2014 CentOS-Debuginfo.repo
-rw-r--r--   1 root root  630 10月 23 20:41 2014 CentOS-Media.repo
-rw-r--r--   1 root root 5394 10月 23 20:41 2014 CentOS-Vault.repo
-rw-r--r--   1 root root  289 10月 23 20:41 2014 CentOS-fasttrack.repo
-rw-r--r--.  1 root root 1056 11月  5 12:52 2012 epel-testing.repo
-rw-r--r--   1 root root  957 10月 11 03:55 2014 epel.repo
-rw-r--r--   1 root root  739  3月 20 23:24 2013 mirrors-rpmforge
-rw-r--r--   1 root root  717  3月 20 23:24 2013 mirrors-rpmforge-extras
-rw-r--r--   1 root root  728  3月 20 23:24 2013 mirrors-rpmforge-testing
-rw-r--r--   1 root root 2298  3月  1 19:47 2014 remi.repo
-rw-r--r--   1 root root 1128 12月 10 15:47 2014 rpmforge.repo

それぞれのファイルのenable=1をenable=0に変更して通常のyum installでこのレポジトリを使用しないようにしておく。
このリポジトリを使用するときは、–enablerepo=remiなどとオプションをつければ使用できる。

[root@local ~]# vi /etc/yum.repos.d/rpmforge.repo
### Name: RPMforge RPM Repository for RHEL 6 - dag
### URL: http://rpmforge.net/
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/rpmforge
mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 0    <------enable=1からenable=0に変更する
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

[rpmforge-extras]
name = RHEL $releasever - RPMforge.net - extras
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/extras
mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge-extras
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-extras
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1

[rpmforge-testing]
name = RHEL $releasever - RPMforge.net - testing
baseurl = http://apt.sw.be/redhat/el6/en/$basearch/testing
mirrorlist = http://mirrorlist.repoforge.org/el6/mirrors-rpmforge-testing
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-testing
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
[root@local ~]# vi /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled = 0    <------enable=1からenable=0に変更する
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

remiリポジトリは、デフォルトでenable=0なので変更しなくて良い。
ですが一応確認。

[root@local ~]# vi /etc/yum.repos.d/remi.repo
[remi]
name=Les RPM de remi pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror
enabled=0  <------ デフォルトでenable=0になっている
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php55]
name=Les RPM de remi de PHP 5.5 pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/php55/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/php55/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php56]
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/php56/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/php56/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-test]
name=Les RPM de remi en test pour Enterprise Linux 6 - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/6/test/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/6/test/mirror
# WARNING: If you enable this repository, you must also enable "remi"
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-debuginfo]
name=Les RPM de remi pour Enterprise Linux 6 - $basearch - debuginfo
baseurl=http://rpms.famillecollet.com/enterprise/6/debug-remi/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php55-debuginfo]
name=Les RPM de remi de PHP 5.5 pour Enterprise Linux 6 - $basearch - debuginfo
baseurl=http://rpms.famillecollet.com/enterprise/6/debug-php55/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-php56-debuginfo]
name=Les RPM de remi de PHP 5.6 pour Enterprise Linux 6 - $basearch - debuginfo
baseurl=http://rpms.famillecollet.com/enterprise/6/debug-php56/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

[remi-test-debuginfo]
name=Les RPM de remi en test pour Enterprise Linux 6 - $basearch - debuginfo
baseurl=http://rpms.famillecollet.com/enterprise/6/debug-test/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

以上の設定で使用したいレポジトリを指定してインストールできるようになる。

まずこのリポジトリに登録されている最新バージョンを調べる。

[root@local ~]# yum list --enablerepo=remi-php55 |grep php
 * remi-php55: remi.kazukioishi.net
php.x86_64                                5.3.3-40.el6_6              @updates
php-cli.x86_64                            5.3.3-40.el6_6              @updates
php-common.x86_64                         5.3.3-40.el6_6              @updates
php-gd.x86_64                             5.3.3-40.el6_6              @updates
php-mbstring.x86_64                       5.3.3-40.el6_6              @updates
php-mcrypt.x86_64                         5.3.3-1.el6.rf              @rpmforge
php-mysql.x86_64                          5.3.3-40.el6_6              @updates
php-pdo.x86_64                            5.3.3-40.el6_6              @updates
phpmyadmin.noarch                         2.11.11.3-2.el6.rf          @rpmforge
                                                                      remi-php55
apcu-panel.noarch                         4.0.7-1.el6.remi.5.5        remi-php55
cups-php.x86_64                           1:1.4.2-67.el6              base
graphviz-php.x86_64                       2.26.0-10.el6               base
mysqlnd-qc-panel.noarch                   1.2.0-4.el6.remi.5.5        remi-php55
php-bcmath.x86_64                         5.3.3-40.el6_6              updates
php-dba.x86_64                            5.3.3-40.el6_6              updates
php-devel.x86_64                          5.3.3-40.el6_6              updates
php-eaccelerator.x86_64                   1:1.0-0.6.git42067ac.el6.remi
                                                                      remi-php55
php-eaccelerator-httpd.x86_64             1:1.0-0.6.git42067ac.el6.remi
                                                                      remi-php55
php-embedded.x86_64                       5.3.3-40.el6_6              updates
php-enchant.x86_64                        5.3.3-40.el6_6              updates
php-ffmpeg.x86_64                         0.7.0-0.2.svn678.el6.remi.2 remi-php55
php-fpm.x86_64                            5.3.3-40.el6_6              updates
php-gmp.x86_64                            5.5.19-2.el6.remi           remi-php55
php-horde-horde-lz4.x86_64                1.0.7-1.el6.remi.5.5        remi-php55
php-idn.x86_64                            1.2c-6.el6.remi.1           remi-php55
php-imap.x86_64                           5.3.3-40.el6_6              updates
php-interbase.x86_64                      5.5.19-2.el6.remi           remi-php55
php-intl.x86_64                           5.3.3-40.el6_6              updates
php-ioncube-loader.x86_64                 4.7.2-1.el6.remi.5.5        remi-php55
php-ldap.x86_64                           5.3.3-40.el6_6              updates
・
・
・
省略

このコマンド” yum list –enablerepo=remi-php55 ”だと通常使用するレポジトリと一時的に使用するレポジトリが混在しているので通常のレポジトリを一時的に使用しないようにします。

[root@local~]# yum repolist
読み込んだプラグイン:downloadonly, fastestmirror, priorities, security
Loading mirror speeds from cached hostfile
 * base: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
リポジトリー ID     リポジトリー名            状態
base                 CentOS-6 - Base          6,510+8
extras               CentOS-6 - Extras        35
updates              CentOS-6 - Updates       469+8
repolist: 7,014

このリポジトリIDをdisableに指定すればよい

[root@local ~]# yum list --disablerepo=base,extras,updates --enablerepo=remi-php55 |grep php
 * remi-php55: remi.kazukioishi.net
php.x86_64                         5.3.3-40.el6_6                     @updates
php-cli.x86_64                     5.3.3-40.el6_6                     @updates
php-common.x86_64                  5.3.3-40.el6_6                     @updates
php-gd.x86_64                      5.3.3-40.el6_6                     @updates
php-mbstring.x86_64                5.3.3-40.el6_6                     @updates
php-mcrypt.x86_64                  5.3.3-1.el6.rf                     @rpmforge
php-mysql.x86_64                   5.3.3-40.el6_6                     @updates
php-pdo.x86_64                     5.3.3-40.el6_6                     @updates
phpmyadmin.noarch                  2.11.11.3-2.el6.rf                 @rpmforge
apc-panel.noarch                   3.1.15-0.4.20130912.el6.remi.5.5   remi-php55
apcu-panel.noarch                  4.0.7-1.el6.remi.5.5               remi-php55
mysqlnd-qc-panel.noarch            1.2.0-4.el6.remi.5.5               remi-php55
php.x86_64                         5.5.19-2.el6.remi                  remi-php55
php-bcmath.x86_64                  5.5.19-2.el6.remi                  remi-php55
php-cli.x86_64                     5.5.19-2.el6.remi                  remi-php55
php-common.x86_64                  5.5.19-2.el6.remi                  remi-php55
php-dba.x86_64                     5.5.19-2.el6.remi                  remi-php55
php-devel.x86_64                   5.5.19-2.el6.remi                  remi-php55
中略
・
・
phpMyAdmin.noarch                  4.0.0-0.5.rc4.el6.remi             remi-php55
xcache-admin.noarch                3.1.1-1.el6.remi.5.5               remi-php55
xhprof.noarch                      0.9.4-2.el6.remi.5.5               remi-php55

@updatesと@rpmforgeがありますがこれについては、現在インストールされているものとして表示されているのでしょうか?

大体remi-php55のレポジトリになったのでここからphpバージョン5.5をインストールします。
現在php関連のものをリストアップしてみると以下があるのでそれもすべてバージョンアップします。

[root@local~ ]# rpm -qa | grep php
php-cli-5.3.3-40.el6_6.x86_64
php-gd-5.3.3-40.el6_6.x86_64
phpmyadmin-2.11.11.3-2.el6.rf.noarch
php-pdo-5.3.3-40.el6_6.x86_64
php-5.3.3-40.el6_6.x86_64
php-mbstring-5.3.3-40.el6_6.x86_64
php-common-5.3.3-40.el6_6.x86_64
php-mysql-5.3.3-40.el6_6.x86_64
php-mcrypt-5.3.3-1.el6.rf.x86_64

あと古いphpmyadminもまだあるので最初にこちらをアンインストールする。
(しなくてもいいと思いますが使わないものなので消します)

[root@local~]# yum erase phpmyadmin-2.11.11.3-2.el6.rf.noarch
読み込んだプラグイン:downloadonly, fastestmirror, priorities, security
削除処理の設定をしています
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package phpmyadmin.noarch 0:2.11.11.3-2.el6.rf will be 削除
--> 依存性解決を終了しました。

依存性を解決しました

=================================================================================================
 パッケージ       アーキテクチャ        バージョン       リポジトリー             容量
=================================================================================================
削除: phpmyadmin  noarch         2.11.11.3-2.el6.rf       @rpmforge               13 M

トランザクションの要約
=================================================================================================
削除                 1 パッケージ

インストール済み容量: 13 M
これでいいですか? [y/N]y
パッケージをダウンロードしています:
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
警告: RPMDB は yum 以外で変更されました。
削除中  : phpmyadmin-2.11.11.3-2.el6.rf.noarch                1/1
警告: /etc/httpd/conf.d/phpmyadmin.conf は /etc/httpd/conf.d/phpmyadmin.conf.rpmsave として保存されました。
 Verifying : phpmyadmin-2.11.11.3-2.el6.rf.noarch             1/1

削除しました:  phpmyadmin.noarch 0:2.11.11.3-2.el6.rf 完了しました!

ここで設定ファイルも削除されないがconf.rpmsaveとされてしまうので元通りに設定ファイルとしてrenameする。

[root@local]# mv /etc/httpd/conf.d/phpmyadmin.conf.rpmsave /etc/httpd/conf.d/phpmyadmin.conf

だんだんと確信に迫りつつ長くなったのでphpを最新バージョンにアップグレード その2に続く(笑)

カテゴリー: Linux, php タグ: , , ,