かぴぶろぐ

またかぴったかと思った・・・(´A`;)

PHP環境のインストール

カテゴリ[ PHP ]
やる事はまさにこれなんだが↓
[unix][php][postgresql]apach2+postgresql8+php5の環境を作る。

一応、PHPソースからインストールのメモ。
必要なもの
  • Apache2.*(今回はhttpd-2.2.4)
  • PHP5.*(今回はphp-5.2.6)
  • PostgreSQL8.3.*(今回は8.3.0)
apacheインストール--enable-soを忘れず入れる
./configure --enable-shared=so --enable-so --enable-module=all --enable-proxy --enable-rewrite --prefix=/opt/apache2.2
ちゃんとapxs等入ったかテストするには
ここが詳しい。↓
apxsでapacheにモジュールを追加する
[apache home]/bin/httpd -M
でテストできるみたい。

httpd.confの
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
も忘れずに
php環境のインストールconfigureはこんなん。
./configure --with-apxs2=/opt/apache2.2/bin/apxs --with-pgsql \
--enable-mbstring --with-mcrypt --with-gd --with-zlib --with-jpeg-dir \
--with-png-dir --with-tidy
apxsがちゃんと入ってない場合や、apxsのパスが違うと以下のように言われる。
Configuring SAPI modules
checking for AOLserver support... no
checking for Apache 1.x module support via DSO through APXS... no
checking for Apache 1.x module support... no
checking whether to enable Apache charset compatibility option... no
checking for Apache 2.0 filter-module support via DSO through APXS... no
checking for Apache 2.0 handler-module support via DSO through APXS...

Sorry, I cannot run apxs.  Possible reasons follow:

1. Perl is not installed
2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page is displayed)

The output of /usr/local/sbin/apxs follows:
./configure: line 6669: /usr/local/sbin/apxs: No such file or directory
configure: error: Aborting

上記configureで
mcryptやlibtidyが無いと突っ込まれたらyumから足す。
mcryptとかは標準のyumのrepoじゃ見つからないかもしれない。
yum list |grep mcryptで見つからなければ
/etc/yum.repos.d/の下の.repoに以下を足す。
名前はdag.repoとかつけて
[dag]
name=Dag RPM Repository for Fedora Core
baseurl=http://ftp.riken.jp/Linux/dag/redhat/el$releasever/en/$basearch/dag
enabled=1
gpgcheck=1
これでrekenさんを探しに行く。
yum install mcrypt
yum install libtidy

(develも入れとく)
KEYを取得
rpm --import http://ftp.riken.jp/Linux/dag/packages/RPM-GPG-KEY.dag.txt
開いてみたら Not Found. orz

RPM-GPG-KEY.dag.txtでぐぐってみたら以下のURLがあった。
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

次にPEARを入れる。今回は、とあるサービス環境の移行だったのでそっくり同じに。
>pear list

Archive_Tar          1.3.2   stable
Calendar             0.5.3   beta
Console_Getopt       1.2.3   stable
DB                   1.7.13  stable
Date                 1.4.7   stable
HTML_Common          1.2.4   stable
HTML_QuickForm       3.2.10  stable
HTML_Template_IT     1.1     stable
HTTP_Request         1.4.3   stable
Log                  1.11.1  stable
MDB2                 2.4.1   stable
Mail                 1.1.14  stable
Mail_Mime            1.5.2   stable
Mail_mimeDecode      1.5.0   stable
Net_POP3             1.3.6   stable
Net_Socket           1.0.9   stable
Net_URL              1.0.15  stable
Net_UserAgent_Detect 2.0.1   stable
PEAR                 1.7.1   stable
Pager                2.4.6   stable
Structures_Graph     1.0.2   stable
XML_HTMLSax3         3.0.0   stable
XML_Parser           1.2.8   stable
XML_Serializer       0.18.0  beta
XML_Util             1.2.0   stable

pear install で必要なものを入れていく
pear install DB
pear listでbetaと出てるものは「名前-beta」でinstallすると見つかる。

後はPostgreSQL
PostgreSQLのインストール
PostgreSQLは予めrpmで入れてた。
しかし、いつもutf-8の環境だったのでcreatedb時にencoding utf-8で問題なかったが、今回はEUC_JPの環境。
そこでcreatedb -U postgres --encoding=EUC_JP mydb
を行ったところ、以下のエラー。
bash-3.00$ createdb -U postgres --encoding=EUC_JP magmydb
createdb: database creation failed: ERROR:  encoding EUC_JP does not match server's locale ja_JP.UTF-8
DETAIL:  The server's LC_CTYPE setting requires encoding UTF8.
調べたら以下にinitdbしなおすよう書いてあった。
サーバー構築覚書 手探りです。
最初のinitdb時に--no-localeを付け忘れたのが失敗だったぽい・・・。
既存のデータをダンプ
>pg_dumpall > dumpall.dmp
Postgresを止める。
>/etc/init.d/postgres stop
posgresユーザーになる。
>su postgres
postgres homeに移動
cd /var/lib/pgsql
>ls
data  data.back  pgstartup.log
既存データをどかす。
>mv data data.back
で、initdb
>initdb -D /var/lib/pgsql/data --encoding=utf-8 --no-locale
これでエンコード指定でcreatedb問題なし。
>createdb -U postgres --encoding=UTF8 mydb1
>createdb -U postgres --encoding=EUC_JP mydb2
終了~。

参考URL

http://kapi.jp/kapi_blog/160

2008年08月08日

関連カテゴリ PHP

この記事のコメント

この記事にコメントする