LAMP(Linux Apache MySQL PHP)と言われているが、これらのセットアップがなかなかのくせ者!
つまり、何がくせ者かというと、同じレベルでインストールする場合は良いが、ソースとバイナリが混在するとかなりやっかいになる。全てソースインストールもしくは、全てバイナリインストール。が理想だけど、混在を余儀なくされた場合はの対応が出来るのかに挑戦したい。
今回は、以下の条件の場合のインストールを説明したい。
インストールモジュール:
1)RedHat Linux Enterpise Linux 5.5
2)MySQL 5.2.14 i86_64 RPM
3)httpd-2.2.16.tar.gz
4)php-5.2.13.tar.gz
ただし、MySQL 5.2.14 i86_64は、RPMコマンドにより、インストール済みとするので説明は割愛する。
1.Apacheのインストール(mod_ssl有りの場合も説明する)
1)Apache2のコンパイル&リンク
2010-0930現在の最新 httpd-2.2.16.tar.gz (サイト http://httpd.apache.org/download.cgi からソースをダウンロード)
# wget http://www.meisei-u.ac.jp/mirror/apache/dist/httpd/httpd-2.2.16.tar.gz
# tar zxvf httpd-2.2.16.tar.gz
# chown -R root.root httpd-2.2.16
# cd httpd-2.2.16
# ./configure –with-mpm=worker –enable-rewrite
# make
# make install
2)Apache2 mod_sslのコンパイル&リンク(httpsを使う場合)
# ./configure –enable-so –enable-ssl –with-mpm=worker –enable-rewrite
# make
# make install
2.PHPのインストール
1)zlibのインストール
2010-0930現在の最新 zlib-1.2.5.tar.gz (サイトからソースをダウンロード)
# wget http://zlib.net/zlib-1.2.5.tar.gz
# tar zxvf zlib-1.2.5.tar.gz
# chown -R root.root zlib-1.2.5
# cd zlib-1.2.5
# ./configure
# make
# make install
2)libxmlのインストール
2010-0930現在の最新 libxml2-2.7.7.tar.gz (サイトからソースをダウンロード)
# wget ftp://xmlsoft.org/libxml2/libxml2-2.7.7.tar.gz
# tar zxvf libxml2-2.7.7.tar.gz
# chown -R root.root libxml2-2.7.7
# ./configure
# make
# make install
3)PHP本体のインストール
少々事情があり、ソースを少し古いのをチョイス php-5.2.13.tar.gz (サイトからソースをダウンロード)
# wget http://jp.php.net/get/php-5.2.13.tar.gz/from/jp2.php.net/mirror
# tar zxvf php-5.2.13.tar.gz
# chown -R root.root php-5.2.13
# cd php-5.2.13
# ./configure –with-apxs2=/usr/local/apache2/bin/apxs \
–with-mysql=/usr –with-libdir=lib64 –with-dom –with-xml \
–with-zlib –enable-mbstring –enable-mbregex –enable-versioning \
–enable-zend-multibyte
記事:
–with-mysql=/usr –with-libdir=lib64のパラメータでphp-mysqlのモジュールを関係付けを行う。
# make
# make install
4)php.iniの修正
# cp php.ini-dist /usr/local/lib/php.ini
# vi /usr/local/lib/php.ini
省略
magic_quotes_gpc = Off
output_buffering = On
output_handler = mb_output_handler
default_charset = Shift_JIS
extension = php_mbstring.dll ← コメントアウト
mbstring.language = Japanese
mbstring.internal_encoding = EUC-JP
mbstring.http_input = auto
mbstring.http_output = SJIS
mbstring.encoding_translation = On
mbstring.detect_order = auto
mbstring.substitute_character = none
※以下ファイルUPLOADの設定(アップロードしなければ関係なし)
post_max_size = 2G
upload_max_filesize = 2G
max_execution_time = 0
max_input_time = -1
省略
3.httpd.confの修正
# vi /usr/local/apache2/conf/httpd.conf
省略
ServerName xxxxxxxx ←ServerNameを書かないと起動時エラーがでる
<Directory “/usr/local/apache/htdocs”>タブを編集(ディレクトリを変えたいときとか、オプションを変えたいときなど)
DirectoryIndexを編集
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
省略
4.Apacheの起動スクリプトの作成
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
# vi /etc/rc.d/init.d/httpd
「#!/bin/sh」の下に次の行を追加。
#!/bin/bash
# chkconfig: 2345 30 30
# description: Apache2 Starting Script
# chkconfig –add httpd
5.MySQLのmy.cnfの修正
省略
[mysqld]
skip-character-set-client-handshake ← 追加
省略
6.各サーバの起動
# /etc/init.d/mysql start
# /etc/init.d/httpd start
以上
コメント