- 追加された行はこの色です。
- 削除された行はこの色です。
*PostgreSQL8+PHP5+Apache2インストール [#k562d2b8]
#contents
[[PostgreSQL8.0の解説:http://itpro.nikkeibp.co.jp/members/ITPro/oss/20050124/155152/]]
[[PostgreSQL8.0の解説:http://itpro.nikkeibp.co.jp/members/ITPro/oss/20050124/155152/]]~
[[Apache2.2の解説:http://www.atmarkit.co.jp/flinux/special/apache22/apache01.html]]
*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.3
# chown postgres /usr/local/src/postgresql-8.1.3
ソース取得 http://www.postgresql.jp/~
常に最新バージョンを確認しましょう~
通信を暗号化する場合は ./configure --with-openssl とする
# su postgres
$ tar xvzf postgresql-8.1.3.tar.gz
$ cd postgresql-8.1.3
$ ./configure
$ gmake
$ gmake check
$ gmake install
**SSLの設定 [#a7c33acc]
$ cd
$ cd data
$ openssl req -new -text -out server.req
Generating a 1024 bit RSA private key
...++++++
.....++++++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:JP
State or Province Name (full name) [Berkshire]:Shiga
Locality Name (eg, city) [Newbury]:Otsu
Organization Name (eg, company) [My Company Ltd]:Self
Organizational Unit Name (eg, section) []:Engineer
Common Name (eg, your name or your server's hostname) []:example.com
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
パスフレーズの削除
$ openssl rsa -in privkey.pem -out server.key
$ rm -f privkey.pem
自己署名
$ openssl req -x509 -in server.req -text -key server.key -out server.crt
$ chmod og-rwx server.key
pg_hba.conf にhostsslを記述~
postgresql.conf のsslをonにする
クライアント側にもPostgreSQLを --with-openssl 付きでインストールしておく~
起動する必要は無し
**パスの設定 [#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.3/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.jp/
MPMはworkerもしくはperchildだとPHPが安定動作しないらしい~
[[参考:http://jp2.php.net/manual/ja/install.unix.apache2.php]]
SSLを有効にする場合は --enable-ssl
# tar xvzf httpd-2.2.0.tar.gz
# cd httpd-2.2.0
# ./configure --with-mpm=prefork --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]
ログをZIP圧縮する場合 compress
# vi /etc/logrotate.d/apache
/usr/local/apache2/logs/*_log
{
rotate 4
compress
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};
MySQLを使用する場合は~
&color(black){--with-mysql};
# tar xvzf php-5.1.2.tar.gz
# cd php-5.1.2
# ./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-sockets --enable-simplexml --with-curl \
--with-mysql
**php.iniの設定 [#b8122ccd]
# cp /usr/local/src/php-5.1.2/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