CentOS6にPHP5.6をインストール
あるWeb制作の案件で、サイトにログイン機能を実装することになりました。
動いているサーバはCentOS6、ほぼソフトウェアはデフォルトということなので、PHPのバージョンは5.3ということになります。
パスワードハッシュとして推奨されているアルゴリズムである、Blowfishを簡単に実装するため、PHP5.5以上をインストールすることになりました。
先方への説明を兼ねて、メモみたいなイメージで残しておきます。
【手順.1】現在のPHPの確認と削除
現在のPHPバージョンを取得
[html]
#rpm -qa | grep php
php-common-5.3.3-27.el6_5.x86_64
php-gd-5.3.3-27.el6_5.x86_64
php-cli-5.3.3-27.el6_5.x86_64
php-mbstring-5.3.3-27.el6_5.x86_64
php-pdo-5.3.3-27.el6_5.x86_64
php-mysql-5.3.3-27.el6_5.x86_64
php-5.3.3-27.el6_5.x86_64
php-devel-5.3.3-27.el6_5.x86_64
[/html]
#rpm -qa | grep php
php-common-5.3.3-27.el6_5.x86_64
php-gd-5.3.3-27.el6_5.x86_64
php-cli-5.3.3-27.el6_5.x86_64
php-mbstring-5.3.3-27.el6_5.x86_64
php-pdo-5.3.3-27.el6_5.x86_64
php-mysql-5.3.3-27.el6_5.x86_64
php-5.3.3-27.el6_5.x86_64
php-devel-5.3.3-27.el6_5.x86_64
[/html]
そしてそれらを削除
[html]
#yum remove php-*
[/html]
#yum remove php-*
[/html]
【手順.2】リポジトリの追加
epelリポジトリとremiリポジトリを追加
epelリポジトリ
[html]
#rpm –import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
#rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[/html]
#rpm –import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
#rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
[/html]
remi リポジトリ
[html]
#rpm –import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
#rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
[/html]
#rpm –import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
#rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
[/html]
【手順.3】PHPのインストール
[html]
#yum –enablerepo=remi-php56 install php php-common php-cli php-pdo php-mysql php-devel php-gd
[/html]
#yum –enablerepo=remi-php56 install php php-common php-cli php-pdo php-mysql php-devel php-gd
[/html]
php-gd でインストールが失敗するため、gd-lastをインストール
参考: CentOSにPHP5.5とphpMyAdminをインストール
[html]
#yum –enablerepo=remi install gd-last
#yum –enablerepo=remi-php56 install php-gd
[/html]
#yum –enablerepo=remi install gd-last
#yum –enablerepo=remi-php56 install php-gd
[/html]
以上で完了となります。
基本的にまったく難しいことはありませんが、php-gdで一瞬戸惑いました。