*PostgreSQL8+PHP5+Apache2インストール [#k562d2b8]
#contents

[[PostgreSQL8.0の解説:http://itpro.nikkeibp.co.jp/members/ITPro/oss/20050124/155152/]]

*PostgreSQLのインストール [#rb7a0383]

PostgreSQL,PHP,ApacheのRPMは全て削除おきます~
バージョンアップする場合はバックアップを取って止めておきましょう

postgres ユーザーの作成

 # /usr/sbin/useradd -d /usr/local/pgsql postgres
 # chmod 755 /usr/local/pgsql

作業ディレクトリ作成

 # mkdir /usr/local/src/postgresql-8.1.0
 # chown postgres /usr/local/src/postgresql-8.1.0

ソース取得 http://www.postgresql.jp/

 # su postgres
 $ tar xvzf postgresql-8.1.0.tar.gz
 $ cd postgresql-8.1.0
 $ ./configure
 $ gmake
 $ gmake check
 $ gmake install

**パスの設定 [#p07099bd]
postgresとPostgreSQLを使用するユーザー全ての.bashrcに以下を追加

 PATH="$PATH":/usr/local/pgsql/bin
 export POSTGRES_HOME=/usr/local/pgsql
 export PGLIB=$POSTGRES_HOME/lib
 export PGDATA=$POSTGRES_HOME/data
 export MANPATH="$MANPATH":$POSTGRES_HOME/man
 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PGLIB"

設定の反映

 $ source ~/.bashrc

データベース初期化

 $ initdb --encoding=EUC_JP --no-locale

一行追加
 # vi /etc/ld.so.conf
 /usr/local/pgsql/lib
 # /sbin/ldconfig

**自動起動の設定 [#bbdee3b2]

 # cp /usr/local/src/postgresql-8.1.0/contrib/start-scripts/linux /etc/rc.d/init.d/postgresql
 # chmod 755 /etc/rc.d/init.d/postgresql
 # /sbin/chkconfig --add postgresql
 # /etc/rc.d/init.d/postgresql start

*Apacheのインストール [#ye12defa]
http://www.apache.or.jp/

 # tar xvzf httpd-2.0.55.tar.gz
 # cd httpd-2.0.55
 # ./configure --with-mpm=worker --enable-rewrite
 # make
 # make install

Apacheのバージョンなどを表示させないようにするには httpd.conf において

 ServerSignature Off
 ServerTokens Prod

**自動起動の設定 [#b486844c]

 # cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
 # chmod 755 /etc/rc.d/init.d/httpd

 # vi /etc/rc.d/init.d/httpd

以下を追加
 #!/bin/sh
 # chkconfig: - 85 15
 # description: Apache is a World Wide Web server.  It is used to serve \
 #              HTML files and CGI.
 # processname: httpd
 # pidfile: /usr/local/apache2/logs/httpd.pid
 # config: /usr/local/apache2/conf/httpd.conf

 # /sbin/chkconfig --add httpd
 # /etc/rc.d/init.d/httpd start

**ログのローテーション設定 [#u509434c]

 # vi /etc/logrotate.d/apache

 /usr/local/apache2/logs/*_log
 {
   rotate 4
   compress # ZIP圧縮する場合
   weekly
   sharedscripts
   postrotate
   /usr/local/apache2/bin/apachectl restart
   endscript
 }

 # /usr/sbin/logrotate -f /etc/logrotate.d/apache
コマンドにて /usr/local/apache2/logs 内に access_log.1 error_log.1 が作成されていればOK

*PHP5のインストール [#ffe23a4b]

[[PHPめも]]も参考にして下さい :D

Amazon ECSなどを利用する場合はSimpleXML関数を有効にしておく~
&color(black){--enable-simplexml};

[[cURL:http://curl.haxx.se/]]を利用する場合は先にインストールしておく~
RPMで入っていればOK~
&color(black){--with-curl};

 # tar xvzf php-5.0.5.tar.gz
 # cd php-5.0.5
 # ./configure --with-pgsql --with-apxs2=/usr/local/apache2/bin/apxs \
 --enable-zend-multibyte --enable-mbstring --with-gd \
 --with-zlib-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr \
 --with-freetype-dir=/usr --with-ttf --enable-gd-native-ttf \
 --enable-gd-jis-conv --enable-simplexml --with-curl

**php.iniの設定 [#b8122ccd]
 # cp /usr/local/src/php-5.0.5/php.ini-dist /usr/local/lib/php.ini

 ;; 出力バッファリングを有効にする
 output_buffering = On 
 
 ;; mb_output_handlerによる出力変換を有効にする 
 output_handler = mb_output_handler
 
 ;; HTTPヘッダ charset を設定
 default_charset = Shift_JIS
 
 ;;日本語主体で使用
 mbstring.language = Japanese
 
 ;; 内部エンコーディングをEUC-JPに設定
 mbstring.internal_encoding = EUC-JP 
 
 ;; HTTP入力エンコーディング変換をautoに設定
 mbstring.http_input = auto 
 
 ;; SJISに変換
 mbstring.http_output = SJIS
 
 mbstring.encoding_translation = On
 mbstring.detect_order = auto
  
 ;; 無効な文字を出力しない
 mbstring.substitute_character = none;
 
 mbstring.func_overload = 0

 # make
 # make install

**httpd.confの書き換え [#o315704c]

 AddType application/x-httpd-php .php
を追加してApache再起動
#exlink

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS