PHPインストールの前に、Mysqlをインストールしておくこと

■MySQLインストール

[root@centos ~]# yum -y install mysql-server ← mysql-serverインストール

■MySQL設定

[root@centos ~]# vi /etc/my.cnf ← MySQL設定ファイル編集 [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock

# Default to using old password format for compatibility with mysql 3.x # clients

old_passwords=1 default-character-set = utf8 ← 追加(MySQLサーバーの文字コードをUTF-8にする)

以下を追加(MySQLクライアントの文字コードをUTF-8にする) [mysql] default-character-set = utf8

■MySQL起動

[root@centos ~]# /etc/rc.d/init.d/mysqld start ← MySQL起動 MySQL データベースを初期化中: Installing all prepared tables Fill help tables

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 centos.centossrv.com password 'new-password' 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 the benchmarks in the 'sql-bench' directory: cd sql-bench ; perl run-all-tests

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at http://www.mysql.com Support MySQL by buying support/licenses at http://shop.mysql.com

                                                          [  OK  ]

MySQL を起動中: [ OK ]

[root@centos ~]# chkconfig mysqld on ← MySQL自動起動設定

[root@centos ~]# chkconfig --list mysqld ← MySQL自動起動設定確認 mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← ランレベル2~5のonを確認

#wget php-5.2.12.tar.gz #tar zxvf php-5.2.12.tar.gz #cd php-5.2.12 #./configure --prefix=/usr/local/php --enable-mbstring --with-apxs2=/usr/sbin/apxs --with-config-file-path=/usr/local/php/lib/ --enable-zend-multibyte --enable-mbregex --with-mime-magic --enable-exif --with-zlib --with-mysql=/usr/local/mysql/ --with-libdir=lib64

 ※無いと言われるライブラリはその都度インストール   例:# wget http://www.ijg.org/files/jpegsrc.v6b.tar.gz     # tar zxvf jpegsrc.v6b.tar.gz     # cd jpeg-6b     # ./configure --prefix=/usr/local     # make     # make install    参考:http://greenonions.blog5.fc2.com/blog-entry-36.html

# make # make install

PHP5設定ファイルコピー

# cp php.ini-dist /usr/local/lib/php.ini

PHP5利用のためApacheの設定

# vi /etc/httpd/conf.d/php.conf

以下をコピペ

   LoadModule php5_module modules/libphp5.so
   AddHandler php5-script .php
   AddType application/x-httpd-php .php
   AddType application/x-httpd-php-source .phps
   DirectoryIndex index.php

Apacheをリスタート

#/usr/local/apache2/bin/apachectl restart

 ※この際、「libphp5.so」が存在しないというエラーが出たら、

  LoadModule php5_module modules/libphp5.so

  この部分を変更しなければならない。   今回は「Makefile」を見たところ、「/home/ota/php-5.2.12/libs/libphp5.so」こんなところにありやがった。   ので、

  LoadModule php5_module /home/ota/php-5.2.12/libs/libphp5.so

  こんな感じになった。

phpinfo();を作成して動作確認

#vi phpinfo.php
 <?
 phpinfo();
 ?>

参考ページ

http://centossrv.com/mysql.shtml http://www.makizou.com/archives/1270 http://greenonions.blog5.fc2.com/blog-entry-36.html http://www.oklab.org/language_c/php5_0_2_install_bug.htm http://tonby.sakura.ne.jp/?p=45 http://d.hatena.ne.jp/kyart/20081020/1224480952 http://www.trekdevel.net/archives/14 http://d.hatena.ne.jp/sotarok/20070618/1182174722 http://wassr.jp/user/umq/statuses/n2F7w0id26 http://oshiete1.goo.ne.jp/qa5118360.html

最終更新:2010年01月06日 19:37