PHP5.6にアップデート
以前PHP5.5にアップデートしましたが、php-xmlをインストールしようとしたところ、
依存関係でエラーが発生してしまい、色々と試したのですが結局はPHPをアンインストールして再度入れなおす事にしました。
ついでなので、5.6にアップデートしてしまいたいと思います。
インストールされているphp関連ファイルを確認
[root@test]# rpm -qa | grep php←rpmコマンドでバージョンの確認
php-pecl-jsonc-1.3.9-1.el6.remi.5.5.x86_64
php-common-5.5.30-1.el6.remi.x86_64
php-pdo-5.5.30-1.el6.remi.x86_64
php-5.5.30-1.el6.remi.x86_64
php-pecl-zip-1.13.1-1.el6.remi.5.5.x86_64
php-cli-5.5.30-1.el6.remi.x86_64
php-mysqlnd-5.5.30-1.el6.remi.x86_64
php-mbstring-5.5.30-1.el6.remi.x86_64
どこのリポジトリからインストールしたかを調べる
[root@test]# yum info php
インストール済みパッケージ
名前 : php
アーキテクチャ : x86_64
バージョン : 5.5.30
リリース : 1.el6.remi
容量 : 9.0 M
リポジトリー : installed
提供元リポジトリー : remi-php55←remiからと分かる
要約 : PHP scripting language for creating dynamic web sites
URL : http://www.php.net/
ライセンス : PHP and Zend and BSD
説明 : PHP is an HTML-embedded scripting language. PHP attempts to make it
: easy for developers to write dynamically generated web pages. PHP also
: offers built-in database integration for several commercial and
: non-commercial database management systems, so writing a
: database-enabled webpage with PHP is fairly simple. The most common
: use of PHP coding is probably as a replacement for CGI scripts.
:
: The php package contains the module (often referred to as mod_php)
: which adds support for the PHP language to Apache HTTP Server.
現在登録されているリポジトリを確認
[root@test]# yum repolist リポジトリー ID リポジトリー名 状態 base CentOS-6 - Base 6,575 extras CentOS-6 - Extras 48 mysql-connectors-community MySQL Connectors Community 17 mysql-tools-community MySQL Tools Community 33 mysql56-community MySQL 5.6 Community Server 214 remi-safe Safe Remi's RPM repository for Enterprise Linux 6 - x86_64 543 updates CentOS-6 - Updates 958 repolist: 8,388
yum repolist allを実行すると、無効になっているものも含めて全て表示されます。
また、/etc/yum.repos.dの中のファイルでも確認できます。
リポジトリの更新(削除→再インストール)
おかしな挙動になることもあるので、一旦消して再度インストールします。
今回は、remiとepelがインストールされていたので、それぞれのパッケージ名を調べます。
[root@test]# rpm -qa | grep epel←epelのパッケージ名調査 epel-release-6-8.noarch [root@test]# rpm -qa | grep remi←remiのパッケージ名調査 php-pecl-jsonc-1.3.9-1.el6.remi.5.5.x86_64 php-common-5.5.30-1.el6.remi.x86_64 php-pdo-5.5.30-1.el6.remi.x86_64 php-5.5.30-1.el6.remi.x86_64 remi-release-6.6-2.el6.remi.noarch←remiのパッケージ名調査 libzip-last-1.0.1-1.el6.remi.x86_64 php-pecl-zip-1.13.1-1.el6.remi.5.5.x86_64 php-cli-5.5.30-1.el6.remi.x86_64 php-mysqlnd-5.5.30-1.el6.remi.x86_64 php-mbstring-5.5.30-1.el6.remi.x86_64
消しても大丈夫か–testオプションをつけて調べます。
[root@test]# rpm -e --test epel-release-6-8.noarch
エラー: 依存性の欠如:
epel-release >= 6 は (インストール済み)remi-release-6.6-2.el6.remi.noarch に必要とされています
[root@test]# rpm -e remi-release-6.6-2.el6.remi.noarch
[root@test]# ←何もない
以上の結果から、epelはremiに依存しているので、remiから削除します。
[root@test]# rpm -e remi-release-6.6-2.el6.remi.noarch
エラー: 依存性の欠如:
epel-release >= 6 は (インストール済み)remi-release-6.6-2.el6.remi.noarch に必要とされています
[root@test]# rpm -e remi-release-6.6-2.el6.remi.noarch
[root@test]# rpm -e epel-release-6-8.noarch
警告: /etc/yum.repos.d/epel.repo は /etc/yum.repos.d/epel.repo.rpmsave として保存されました。
[root@test]# rm -rf /etc/yum.repos.d/epel.repo.rpmsave再インストールするので、epel.repo.rpmsaveは削除してしまって大丈夫です。
再インストールを行います。
[root@test]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm←32bit版の場合はx86_64をi386に変更してください
[root@test]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
epelは標準でenable=1になっているので、このままではepelが優先されてしまいます。
必要に応じて–enablerepo=epelでインストールすれば良いので、設定を変更します。
[root@test]# 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←0に変更 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
phpの削除とインストール
まずは既存のものを削除します。
[root@test]# yum remove php*←php関連ファイル削除
利用できる最新のものを調べます。
[root@test]# yum --enablerepo=epel,remi,remi-php56 info php
利用可能なパッケージ
名前 : php
アーキテクチャ : x86_64
バージョン : 5.6.16
リリース : 1.el6.remi
容量 : 2.7 M
リポジトリー : remi-php56←remi-php56にある事が分かる
要約 : PHP scripting language for creating dynamic web sites
URL : http://www.php.net/
ライセンス : PHP and Zend and BSD
説明 : PHP is an HTML-embedded scripting language. PHP attempts to make it
: easy for developers to write dynamically generated web pages. PHP also
: offers built-in database integration for several commercial and
: non-commercial database management systems, so writing a
: database-enabled webpage with PHP is fairly simple. The most common
: use of PHP coding is probably as a replacement for CGI scripts.
:
: The php package contains the module (often referred to as mod_php)
: which adds support for the PHP language to Apache HTTP Server.
remi-php56からインストールを行います。
[root@test]# yum install php php-common --enablerepo=remi,remi-php56←phpインストール [root@test]# yum install php-mysqlnd php-mbstring php-gd php-pdo php-gd php-xml --enablerepo=remi,remi-php56←php-xmlなど、他に使うものも入れておきます [root@test]# service httpd restart←Apache再起動
バージョン確認
最後にバージョンを確認します。
[root@test]# php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/ssh2.so' - /usr/lib64/php/modules/ssh2.so: undefined symbol: php_checkuid in Unknown on line 0←エラーが出ている(解消方法はこちら) PHP 5.6.16 (cli) (built: Nov 26 2015 08:01:30)←5.6になっていることを確認 Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies