2009.06.10 Wednesday
CentOS 5.3 に php-5.2.9, mysql-5.1.35 をインストール(remi レポジットリより)
JUGEMテーマ:コンピュータ
PHPとMySQLの最新RPMのレポジトリがRemiによって提供されている。
http://blog.famillecollet.com/pages/Config-en
これは、fedora 用に作られているため、CentOS(RHEL)では、EPELを必要とする。EPEL(Extra Packages for Enterprise Linux)は、Fedora用のパッケージをRedHat Enterprise Linuxにインストールするためのリポジットリである。
http://fedoraproject.org/wiki/EPEL
これらを使ってCentOSに最新版のRPMをインストールすることができる。Remiが提供しているパッケージには、memcachedやphpMyAdminも含まれている。
http://rpms.famillecollet.com/enterprise/5/remi/i386/repoview/
php-5.2.xとmysql-5.1.3xのインストールは以下の手順で行える。
# 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
# http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
# rpm -Uvh epel-release-5* remi-release-5*
# wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm
# yum -y --enablerepo=remi,epel,rpmforge update php* mysql*
# yum -y --enablerepo=remi,epel,rpmforge install php-gd php-mbstring php-mysql php-odbc php-pdo php-pear mysql-server mysql-bench
CLI(コマンドライン・インターフェース)版のphpのバージョンは-vオプションで実行すると表示される。
[root@capri pgdg]# php -v
PHP 5.2.9 (cli) (built: Feb 27 2009 14:42:58)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
ついでに、phpMyAdminもインストールしてみた。
# yum -y --enablerepo=remi,epel,rpmforge install phpMyAdmin
なお、mysql のデフォルトの文字エンコーディングシステムを utf-8 として運用したい場合は、/etc/my.conf の[mysqld]スタンザと[mysql]スタンザのそれぞれのセクションに次の設定をしておく。
[mysqld]
default-character-set=utf8
skip-character-set-client-handshake
[mysql]
default-character-set = utf8
※このdefault-character-setの設定を運用中のデータベースに対して行うと既存データの文字化けを発生させる恐れがあるので要注意。
MySQLのデータベースの初期化は最初にサービスを開始したときに行われる。
[root@capri php-mysql]# /etc/init.d/mysqld start
MySQL データベースを初期化中: Installing MySQL system tables...
090609 23:48:52 [Warning] Forcing shutdown of 3 plugins
OK
Filling help tables...
090609 23:48:53 [Warning] Forcing shutdown of 3 plugins
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h capri.linet.gr.jp password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/
[ OK ]
MySQL を起動中: [ OK ]
[root@capri php-mysql]#
ログに指示されたようにパスワードの設定をしておく。(パスワードは、管理アカウントへの不特定のアクセスを避けるために十分な、推測できないものとする。)
[root@capri php-mysql]# /usr/bin/mysqladmin -u root password 'xxxxxxxxxx'
さきにインストールした、phpMyAdminへは、
http://サーバ名/phpmyadmin/
から、このユーザ名とパスワードを利用してログインできる(しなければログインできない)ことを確認する。
mysqlのバージョンの確認は mysql コマンドを -V オプションで実行すると表示される。
[root@capri php-mysql]# mysql -V
mysql Ver 14.14 Distrib 5.1.35, for redhat-linux-gnu (i686) using readline 5.1
参照記事
- http://www.multiburst.net/ElectricBrain/2009/05/centos-53-php-529-mysql-5134
- http://memorandum.yamasnet.com/archives/Post-165.html
- http://blog.famillecollet.com/post/2005/10/02/8-telechargement-installation-et-yum
- http://bluhaloit.wordpress.com/2008/03/13/installing-php-52x-on-redhat-es5-centos-5-etc/
- http://blog.famillecollet.com/post/2005/10/02/8-telechargement-installation-et-yum
