カテゴリー
Linux

CentOSにPHP最新版をインストールしようと思ったら一筋縄ではいきませんでした

WordPressの最新版とか入れたいです!!!でもそのためには5.2.4以上のPHPをインストールしなければなりません。せっかくだから、最新版にしたいです!yumを使えばすぐなんでしょう?と思っていました、甘かったです。試行錯誤の記録を残します。

まとめ

PHP最新版をインストールするには、yumのRemiリポジトリを使用する!!!

早速PHPをインストールします♪

[root@vps ~]# yum install php
Loaded plugins: fastestmirror
Repository 'vz-base' is missing name in configuration, using id
Repository 'vz-updates' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* rpmforge: apt.sw.be
* updates: ftp.iij.ad.jp
base                                                                      | 1.1 kB     00:00
extras                                                                    | 2.1 kB     00:00
rpmforge                                                                  | 1.1 kB     00:00
updates                                                                   | 1.9 kB     00:00
updates/primary_db                                                        | 436 kB     00:00
vz-base                                                                   |  951 B     00:00
vz-updates                                                                |  951 B     00:00
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php.i386 0:5.1.6-27.el5_5.3 set to be updated
--> Processing Dependency: php-common = 5.1.6-27.el5_5.3 for package: php
--> Processing Dependency: php-cli = 5.1.6-27.el5_5.3 for package: php
--> Processing Dependency: libgmp.so.3 for package: php
--> Running transaction check
---> Package gmp.i386 0:4.1.4-10.el5 set to be updated
---> Package php-cli.i386 0:5.1.6-27.el5_5.3 set to be updated
---> Package php-common.i386 0:5.1.6-27.el5_5.3 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
Package                 Arch              Version                       Repository         Size
=================================================================================================
Installing:
php                     i386              5.1.6-27.el5_5.3              base              2.3 M
Installing for dependencies:
gmp                     i386              4.1.4-10.el5                  base              664 k
php-cli                 i386              5.1.6-27.el5_5.3              base              2.1 M
php-common              i386              5.1.6-27.el5_5.3              base              153 k

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

Total download size: 5.2 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): php-common-5.1.6-27.el5_5.3.i386.rpm                               | 153 kB     00:00
(2/4): gmp-4.1.4-10.el5.i386.rpm                                          | 664 kB     00:00
(3/4): php-cli-5.1.6-27.el5_5.3.i386.rpm                                  | 2.1 MB     00:00
(4/4): php-5.1.6-27.el5_5.3.i386.rpm                                      | 2.3 MB     00:00
-------------------------------------------------------------------------------------------------
Total                                                            4.7 MB/s | 5.2 MB     00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : php-common                                                                1/4
  Installing     : gmp                                                                       2/4
  Installing     : php-cli                                                                   3/4
  Installing     : php                                                                       4/4

Installed:
  php.i386 0:5.1.6-27.el5_5.3

Dependency Installed:
  gmp.i386 0:4.1.4-10.el5  php-cli.i386 0:5.1.6-27.el5_5.3  php-common.i386 0:5.1.6-27.el5_5.3

Complete!

はい、以上です。。。。あれ?バージョン5.1.6ですって。あわわ。

試行錯誤始まるよ~

お、落ち着きましょう。バージョン確認ですっ!

[root@vps ~]# php -v
PHP 5.1.6 (cli) (built: Nov 29 2010 16:47:37)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

あわわ。やっぱり古いです。yumのアップデート確認したら何かわからないでしょうか。。。

[root@vps ~]# yum check-update
Loaded plugins: fastestmirror
Repository 'vz-base' is missing name in configuration, using id
Repository 'vz-updates' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* rpmforge: apt.sw.be
* updates: ftp.iij.ad.jp

rpmforge-release.i386                           0.5.2-2.el5.rf                           rpmforge

RPMforge?

rpmforge?なんですかこれは?次のサイトが参考になりました。・・・なるほど、rpmforgeを入れれば標準リポジトリで提供されないパッケージをyumでインストールできるようになるのですね!これはよさそうです。

これらの参考ページに従えばできるのでしょうけど、あえて書いていないことをやってみます。そう、yum updateでrpmforgeをアップデートすれば、もしかして自動的に標準リポジトリで提供されないパッケージであるPHP5.2.4以上がインストールできるようになるのでは?ワクワクしてきました。やってみます。

[root@vps ~]# yum update
Loaded plugins: fastestmirror
Repository 'vz-base' is missing name in configuration, using id
Repository 'vz-updates' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* rpmforge: fr2.rpmfind.net
* updates: ftp.iij.ad.jp
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package rpmforge-release.i386 0:0.5.2-2.el5.rf set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
Package                     Arch            Version                   Repository           Size
=================================================================================================
Updating:
rpmforge-release            i386            0.5.2-2.el5.rf            rpmforge             12 k

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

Total download size: 12 k
Is this ok [y/N]: y
Downloading Packages:
rpmforge-release-0.5.2-2.el5.rf.i386.rpm                                  |  12 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : rpmforge-release                                                          1/2
  Cleanup        : rpmforge-release                                                          2/2

Updated:
  rpmforge-release.i386 0:0.5.2-2.el5.rf

Complete!

rpmforgeはアップデートされました。が、ダメッ!・・・ダメでした。yum check-update でPHPは出てきませんでした。rpmforgeは放置します。

Remi、EPEL!?

またもやいろいろとググてみて、次のサイトを参考にして、PHPをアップデートしてみます

Remi、EPELというリポジトリを入れます。
[root@vps ~]# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
--2012-01-11 21:00:02--  http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Resolving download.fedora.redhat.com... 209.132.181.26, 209.132.181.27, 209.132.181.23, ...
Connecting to download.fedora.redhat.com|209.132.181.26|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12232 (12K) [application/x-rpm]
Saving to: `epel-release-5-4.noarch.rpm'

100%[=======================================================>] 12,232      --.-K/s   in 0.1s

2012-01-11 21:00:02 (83.5 KB/s) - `epel-release-5-4.noarch.rpm' saved [12232/12232]

[root@vps ~]# wget http://rpms.famillecollet.com/el5.i386/remi-release-5-8.el5.remi.noarch.rpm
--2012-01-11 21:03:13--  http://rpms.famillecollet.com/el5.i386/remi-release-5-8.el5.remi.noarch.rpm
Resolving rpms.famillecollet.com... 88.191.74.232, 2a01:e0b:1:74:2e0:f4ff:fe1b:b827
Connecting to rpms.famillecollet.com|88.191.74.232|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4974 (4.9K) [application/x-rpm]
Saving to: `remi-release-5-8.el5.remi.noarch.rpm'

100%[========================================================================>] 4,974       18.3K/s   in 0.3s

2012-01-11 21:03:14 (18.3 KB/s) - `remi-release-5-8.el5.remi.noarch.rpm' saved [4974/4974]

[root@vps ~]# rpm -Uvh remi-release-5-8.el5.remi.noarch.rpm epel-release-5-4.noarch.rpm
warning: remi-release-5-8.el5.remi.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 00f97f56
warning: epel-release-5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing...                ########################################### [100%]
   1:epel-release           ########################################### [ 50%]
   2:remi-release           ########################################### [100%]

Remiを有効化します。14行目の[remi-test]の部分はenabled=0であることを確認します。

[root@vps ~]# vim /etc/yum.repos.d/remi.repo
[remi]
name=Les RPM de remi pour Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
failovermethod=priority

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

[remi]
name=Les RPM de remi pour Enterprise Linux $releasever - $basearch
#baseurl=http://rpms.famillecollet.com/enterprise/$releasever/remi/$basearch/
mirrorlist=http://rpms.famillecollet.com/enterprise/$releasever/remi/mirror
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi
failovermethod=priority

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

PHP5.3.9!!!!!

さて、再度PHPの利用できるバージョンを確認します。今度はyum info を使ってみます。

[root@vps ~]# yum info php
Loaded plugins: fastestmirror
Repository 'vz-base' is missing name in configuration, using id
Repository 'vz-updates' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* remi: rpms.famillecollet.com
* rpmforge: fr2.rpmfind.net
* updates: ftp.iij.ad.jp
epel                                                                                       | 3.7 kB     00:00
epel/primary_db                                                                            | 3.2 MB     00:00
remi                                                                                       | 2.5 kB     00:00
remi/primary_db                                                                            | 267 kB     00:02
Installed Packages
Name       : php
Arch       : i386
Version    : 5.1.6
Release    : 27.el5_5.3
Size       : 5.9 M
Repo       : installed
Summary    : The PHP HTML-embedded scripting language. (PHP: Hypertext Preprocessor)
URL        : http://www.php.net/
License    : The PHP License v3.01
Description: PHP is an HTML-embedded scripting language. PHP attempts to make it
           : easy for developers to write dynamically generated webpages. 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 which adds support for the PHP
           : language to Apache HTTP Server.

Available Packages
Name       : php
Arch       : i386
Version    : 5.3.9
Release    : 1.el5.remi
Size       : 2.7 M
Repo       : remi
Summary    : PHP scripting language for creating dynamic web sites
URL        : http://www.php.net/
License    : PHP
Description: 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 which adds support for the PHP
           : language to Apache HTTP Server.

やりました!PHP5.3.9にアップデートできそうです!早速いれます!

[root@dti-vps-srv57 ~]# yum update php
Loaded plugins: fastestmirror
Repository 'vz-base' is missing name in configuration, using id
Repository 'vz-updates' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
* base: ftp.iij.ad.jp
* epel: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* remi: rpms.famillecollet.com
* rpmforge: ftp-stud.fht-esslingen.de
* updates: ftp.iij.ad.jp
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package php.i386 0:5.3.9-1.el5.remi set to be updated
--> Processing Dependency: php-cli = 5.3.9-1.el5.remi for package: php
--> Processing Dependency: php-common = 5.3.9-1.el5.remi for package: php
--> Processing Dependency: libedit.so.0 for package: php
--> Running transaction check
---> Package libedit.i386 0:20090923-3.0_1.el5.rf set to be updated
---> Package php-cli.i386 0:5.3.9-1.el5.remi set to be updated
---> Package php-common.i386 0:5.3.9-1.el5.remi set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================
Package                   Arch                Version                              Repository               Size
==================================================================================================================
Updating:
php                       i386                5.3.9-1.el5.remi                     remi                    2.7 M
Installing for dependencies:
libedit                   i386                20090923-3.0_1.el5.rf                rpmforge                262 k
Updating for dependencies:
php-cli                   i386                5.3.9-1.el5.remi                     remi                    2.7 M
php-common                i386                5.3.9-1.el5.remi                     remi                    994 k

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

Total download size: 6.6 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): libedit-20090923-3.0_1.el5.rf.i386.rpm                                              | 262 kB     00:02
(2/4): php-common-5.3.9-1.el5.remi.i386.rpm                                                | 994 kB     00:06
(3/4): php-cli-5.3.9-1.el5.remi.i386.rpm                                                   | 2.7 MB     00:16
(4/4): php-5.3.9-1.el5.remi.i386.rpm                                                       | 2.7 MB     00:16
------------------------------------------------------------------------------------------------------------------
Total                                                                             153 kB/s | 6.6 MB     00:44
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 00f97f56
remi/gpgkey                                                                                | 1.3 kB     00:00
Importing GPG key 0x00F97F56 "Remi Collet <RPMS@FamilleCollet.com>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-remi
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : libedit                                                                                    1/7

WARNING : These php-* RPM are not official Fedora/Redhat build and
overrides the official ones. Don't file bugs on Fedora Project nor Redhat.

Use dedicated forums http://forums.famillecollet.com/

  Updating       : php-common                                                                                 2/7
  Updating       : php-cli                                                                                    3/7
  Updating       : php                                                                                        4/7
  Cleanup        : php-common                                                                                 5/7
  Cleanup        : php                                                                                        6/7
  Cleanup        : php-cli                                                                                    7/7

Dependency Installed:
  libedit.i386 0:20090923-3.0_1.el5.rf

Updated:
  php.i386 0:5.3.9-1.el5.remi

Dependency Updated:
  php-cli.i386 0:5.3.9-1.el5.remi                        php-common.i386 0:5.3.9-1.el5.remi

Complete!

これで、完了できそうです♪バージョンを確認してみましょう!!!

[root@vps ~]# php -v
PHP 5.3.9 (cli) (built: Jan 10 2012 22:05:12)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

おつかれさま!!!!!!!!!!

「CentOSにPHP最新版をインストールしようと思ったら一筋縄ではいきませんでした」への6件の返信

php-5.6.x.tar.gzをダウンロードし、tra zxfで解凍し, ./configureでmake用ファイルを作成し,makeをおこなった後,rootでmake installするとできます。
ただし、xが3以上の場合には, configureにパラメータを指定しないとエラーに
なります。
./configure –with-apxs=/usr/bin/apxs –enable-mbstring –enable-bcmath –enable-zip –enanle-wddx –enable-ftp –enable-phpdbg –with-mysqli=mysqlnd –with-mysql-soc/var/lib/mysql –with-zlib –disable-posix –diseble-fileinfo –with-mcrypt=static –wiyhout-mssql
これらは、今まで使ってた環境でphpinfo関数で表示されるものを参考にして
自分の好みで決めます。

コメントありがとうございます。
ご丁寧に、さらにポイントまで含めて。
ソースからビルドする際は、
是非参考にさせていただきたく存じます。

コメントを残す