2010年10月26日火曜日

さくらインターネット VPS980にPHP 5.3を入れる

今年の9月に正式サービスインしたさくらインターネットの仮想専用サーバー VPS980。
CentOS 5.5にyumでPHP 5.3を入れる方法についてメモしておきます。


さくらインターネットの仮想専用サーバー VPS980では、この都度Ubuntu、FreeBSDなど、5種、10バージョンのOSが選択できるようになりましたが、元々はCentOS 5.5の64ビット版のみの提供でしたし、私はCentOSでいいので、そのまま使うことにします。

CentOS 5.5で、yumを使ってPHPをインストールすると、5.1.6になります。これといって不便しなければいいのですが、独自ライブラリを入れるにあたり、5.2以上が必要だったため、どうせならと5.3にしてみました。(2010年10月11日時点で最新の5.3.3になりました)

参考資料


WordPressを入れるサーバーだったので、事前にApache 2.2、PHP 5.1.6、MySQL 5.1まではインストール済みの状態です。


yumにリポジトリを追加します。


$ sudo rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
$ sudo rpm --import http://download.fedora.redhat.com/pub/epel/RPM-GPG-KEY-EPEL


リポジトリの設定をインストールします。

$ sudo rpm -ivh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
$ sudo rpm -ivh  http://rpms.famillecollet.com/enterprise/remi-release-5.rpm


リポジトリを一時的に有効にして、PHP 5.3をインストールします。
ここで、MySQLのアップデートを行えば、おそらくエラーは出ずに、PHPも5.3にアップデートできたと思いますが、PHPを指定したため、次のエラーが発生してしましました。

$ sudo yum install --enablerepo remi php php-pear php-mbstring
Transaction Check Error:
  file /etc/my.cnf from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/charsets/Index.xml from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/charsets/cp1250.xml from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/czech/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/danish/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/dutch/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/english/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/estonian/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/french/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/german/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/greek/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/hungarian/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/italian/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/japanese/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/korean/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/norwegian-ny/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/norwegian/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/polish/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/portuguese/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/romanian/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/russian/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/serbian/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/slovak/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/spanish/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/swedish/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64
  file /usr/share/mysql/ukrainian/errmsg.sys from install of mysql-libs-5.1.51-1.el5.remi.x86_64 conflicts with file from package mysql-5.0.77-4.el5_5.3.x86_64


そこで、まずは、MySQLをアップデート。先に書いた通り、はじめにこちらの手順を行っておけば、コンフリクトのエラーも発生せず、MySQL、PHPともにアップデートできたものと思われます。

$ sudo yum --enablerepo=remi,epel update mysql*
これで、PHPも同時に最新の 5.3.3にアップデートできました。


念のためPEARのアップデートとmbstringがインストールされていないので、mbstringをインストール。

$ sudo yum update --enablerepo remi php-pear
$ sudo yum install --enablerepo remi php-mbstring


Apacheを再起動して、PHPの更新を反映します。

$ sudo /sbin/service httpd restart
phpinfo()を呼び出すファイルを作成し、バージョン等を確認します。

0 コメント:

コメントを投稿