Webサーバ PHP バージョンアップ
CentOS5.5のPHPバージョンを5.3にアップグレードする
やりたいこと
CentOS5.5インストールで設定されるPHPバージョンは5.1.6であう。
最新のサービスアプリの動作条件として「PHP5.2以上」であるものも多く、同アプリを利用する場合PHPを上位バージョンにアップグレードする必要がる。
今回、yumを利用し、PHPのアップグレードを行う。
★最新版はバグもそれなりに発生するため、バージョンアップは必要な場合のみにとどめておくこと
条件
使用OS | CentOS5.5 64bit |
アプリ | Apache+PHP+MySQL (CentOS付属) |
文字コード | utf-8 |
設定(yumで外部にアクセス可能な場合)
(1)リポジトリ登録
【telnet】
- rootでログイン
$ su パスワード:
- phpのバージョン確認
# php -v
PHP 5.1.6 (cli) (built: Nov 29 2010 16:47:46) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
- ディレクトリ変更
# cd /etc/yum.repos.d/
- リポジトリ登録
# wget http://wing-net.ddo.jp/wing/wing.repo
--2010-12-12 13:53:15-- http://wing-net.ddo.jp/wing/wing.repo wing-net.ddo.jp をDNSに問いあわせています... 182.171.13.175 wing-net.ddo.jp|182.171.13.175|:80 に接続しています... 接続しました。
:
# wget http://wing-net.ddo.jp/wing/wing-extras.repo
--2010-12-12 13:54:12-- http://wing-net.ddo.jp/wing/wing-extras.repo wing-net.ddo.jp をDNSに問いあわせています... 182.171.13.175 wing-net.ddo.jp|182.171.13.175|:80 に接続しています... 接続しました。
:
(2)新PHPパッケージインストール
※一旦 wing(PHP5.2)でアップデートしてからwing-extras(PHP5.3)にしないとエラーとなる。
※PHPアップデート時の依存関係エラー回避のためMySQLのアップデートも実施する
- MySQLアップデート(wing)
# yum --enablerepo=wing update mysql
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile :
- PHPアップデート (wing)
# yum --enablerepo=wing update php
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile :
- MySQLアップデート (wing-extras)
# yum --enablerepo=wing-extras update mysql
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile :
- PHPアップデート (wing-extras)
# yum --enablerepo=wing-extras update php Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile :
(4)Apache再起動
- MySQL再起動
# /etc/rc.d/init.d/mysqld restart
MySQL を停止中: [ OK ] MySQL を起動中: [ OK ]
- Apache再起動
# /etc/rc.d/init.d/httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ]
- PHPバージョン確認
# php -v PHP 5.3.4 (cli) (built: Dec 11 2010 23:37:02) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
- 終了
# exit exit $
設定(yumで外部にアクセス不可な場合)
(1)phpバージョン確認
【telnet】
- rootでログイン
$ su パスワード:
- phpのバージョン確認
# php -v
PHP 5.1.6 (cli) (built: Nov 29 2010 16:47:46) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
(2)createrepoインストール
# yum install createrepo
(3)rpmパッケージのダウンロード
- rpmを保管するディレクトリ作成
# mkdir rpm
# cd rpm
- 以下ファイルをrpm内にUP
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/libtalloc-1.3.1-0.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/apr-util-ldap-1.3.9-2.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/libdbi-dbd-mysql-0.8.3-4.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/php-ldap-5.2.17-1.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/libtdb-1.2.1-2.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/MySQL-python-1.2.2-10.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/httpd-tools-2.2.17-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/mysql-connector-odbc-5.1.5r1144-4.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/php-pdo-5.2.17-1.el5_0.wing.x86_64.rpm
wget http://ftp.iij.ad.jp/pub/linux/centos/5.5/os/x86_64/CentOS/cups-libs-1.3.7-18.el5.x86_64.rpm
wget http://ftp.iij.ad.jp/pub/linux/centos/5.5/os/x86_64/CentOS/cups-libs-1.3.7-18.el5.i386.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/apr-util-1.3.9-2.el5_1.wing.i386.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/t1lib-5.1.2-2.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/apr-util-1.3.9-2.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/perl-DBD-MySQL-4.010-1.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/php-mysql-5.2.17-1.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/mod_ssl-2.2.17-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/php-gd-5.2.17-1.el5_0.wing.x86_64.rpm
wget http://repo.cloudlinux.com/cloudlinux/5/os/x86_64/RPMS/nfs-utils-1.0.9-47.el5_5.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/libdbi-drivers-0.8.3-4.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/php-common-5.2.17-1.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/compat-openldap-2.4.23_2.3.43-2.el5_1.wing.i386.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/compat-openldap-2.4.23_2.3.43-2.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/openldap-2.4.23-2.el5_1.wing.i386.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/openldap-2.4.23-2.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/httpd-manual-2.2.17-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/php-mbstring-5.2.17-1.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/php-cli-5.2.17-1.el5_0.wing.x86_64.rpm
wget http://ftp.iij.ad.jp/pub/linux/centos/5.5/os/x86_64/CentOS/cups-1.3.7-18.el5.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/httpd-2.2.17-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/php-5.2.17-1.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/mysql-libs-5.1.54-1.el5_2.wing.i386.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/mysql-libs-5.1.54-1.el5_2.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/mysql-5.1.54-1.el5_2.wing.i386.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/mysql-5.1.54-1.el5_2.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/libsmbclient-3.4.9-0.56.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/samba-winbind-3.4.9-0.56.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/mysql-server-5.1.54-1.el5_2.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/samba-3.4.9-0.56.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/redhat/el5/x86_64/samba-common-3.4.9-0.56.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/extras/el5/x86_64/php-ldap-5.3.5-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/extras/el5/x86_64/libedit-3.0-2.20090905cvs.el5_0.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/extras/el5/x86_64/php-pdo-5.3.5-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/extras/el5/x86_64/php-mysql-5.3.5-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/extras/el5/x86_64/php-gd-5.3.5-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/extras/el5/x86_64/php-common-5.3.5-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/extras/el5/x86_64/php-mbstring-5.3.5-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/extras/el5/x86_64/php-cli-5.3.5-1.el5_1.wing.x86_64.rpm
wget http://wing-net.ddo.jp/wing/extras/el5/x86_64/php-5.3.5-1.el5_1.wing.x86_64.rpm
★wget使用不可の場合、上記ファイルをダウンロード後rpmフォルダにアップ
- ファイルを確認
# cd ..
# ls rpm MySQL-python-1.2.2-10.el5_0.wing.x86_64.rpm apr-util-1.3.9-2.el5_1.wing.i386.rpm
:
(4)ダウンrpmのリポジトリ作成
- リポジトリ作成
# createrepo -v rpm 1/40 - mysql-libs-5.1.54-1.el5_2.wing.x86_64.rpm 2/40 - apr-util-1.3.9-2.el5_1.wing.x86_64.rpm
:
- リポジトリが出来たか確認
# ls rpm repodata
# ls -l rpm/repodata/ -rw-r--r-- 1 root root 19550 1月 29 01:42 filelists.xml.gz -rw-r--r-- 1 root root 273772 1月 29 01:42 other.xml.gz -rw-r--r-- 1 root root 18585 1月 29 01:42 primary.xml.gz -rw-r--r-- 1 root root 951 1月 29 01:42 repomd.xml
- リポジトリ登録
# vi /etc/yum.repos.d/hogehoge.repo
以下新規追加
[local] name=CentOS-5 - Local baseurl=file:///home/hogehoge/rpm/ gpgcheck=0 enabled=1
(5)新PHPパッケージインストール
- MySQLアップデート
# yum update mysql
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile :
- PHPアップデート
# yum update php Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile :
(6)Apache再起動
- MySQL再起動
# /etc/rc.d/init.d/mysqld restart
MySQL を停止中: [ OK ] MySQL を起動中: [ OK ]
- Apache再起動
# /etc/rc.d/init.d/httpd restart httpd を停止中: [ OK ] httpd を起動中: [ OK ]
- PHPバージョン確認
# php -v PHP 5.3.4 (cli) (built: Dec 11 2010 23:37:02) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
- 終了
# exit
遭遇したトラブル
リポジトリ登録でエラーとなる
問題:
今回と別手順であるが、rpmでリポジトリ登録時「転送に失敗」が出る
[例]
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm を取得中 エラー: http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm をスキップします - 転送に失敗 - 不明または予期せぬエラー
原因:%
指定アドレスにrpmがない。
※上記の場合だと「epel-release-5-3.noarch.rpm」が「epel-release-5-4.noarch.rpm」に変更になっている。
該当アドレスhttp://download.fedora.redhat.com/pub/epel/5/i386/にアクセスし該当ファイルが
あるか確認すること。
PHPバージョンアップ後MySQLが起動しない
問題:
今回と別リポジトリ利用時であるが、yumでMySQLアップデート後MYSQLが起動に失敗する
原因:%
リポジトリでx64未対応のリポジトリを引き込んでいる。
[例]
# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm # wget http://rpms.famillecollet.com/el5.i386/remi-release-5-6.el5.remi.noarch.rpm
このため、「MySQL」がi386版のみ引き込みとなりx86_64版が引き込まれないためエラーとなる模様。
※i386とx86_64の両方が必要となる模様
謝辞
テキスト作成に当たり、以下サイトを参考にさせて頂きました。ありがとうございます。
http://wingse.blog57.fc2.com/blog-entry-227.html
http://www.proustcafe.com/2006/01/createrepoyum.html