前提として、HTTPDはapache2 / DBはPostgersqlを使用する事とします。
1.解凍
tar xvfz php-5.2.4.tar.gz
cd php-5.2.4.tar.gz
2.コンパイル&インストール
# ./configure --disable-debug --with-apxs2=/usr/local/apache2/bin/apxs --with-iconv --enable-mbstring --enable-zend-multibyte --with-pgsql=/usr/local/pgsql --with-zlib
※「--with-zlib」はFPDFを利用する場合に必要となります。
「libxml2」ってのが引っかかった.
インストール直後の状態だと”./configure”の時にlibxml2のバージョンが古いとかで以下のようなエラーが表示された.
>>>
Configuring extensions
checking whether to enable LIBXML support... yes
checking libxml2 install dir... no
configure: error: libxml2 version 2.5.10 or greater required.
<<<
libxml2最新版のrpmは”ftp://xmlsoft.org/”で入手可能.
必要なパッケージは
・libxml2-2.6.11-1.i386.rpm
・libxml2-devel-2.6.11-1.i386.rpm
・libxml2-python-2.6.11-1.i386.rpm
です。その時によってバージョンは違いますので、都度、最適バージョンを選択下さい。
>>> パッケージのアップデート
# rpm -Uvh libxml2-*
警告: libxml2-2.6.11-1.i386.rpm: V3 DSA signature: NOKEY, key ID de95bc1f
Preparing... ########################################### [100%]
1:libxml2 ########################################### [ 33%]
2:libxml2-devel ########################################### [ 67%]
3:libxml2-python ########################################### [100%]
<<<
これさえ気をつければインストールに関しては4系と同じなんじゃないかと.
以下のメッセージが表示されればOK
--------------------------------------------------------------------------------------
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
--------------------------------------------------------------------------------------
# make <--- 結構時間がかかります。
# make test <--- 結構時間がかかります。
# make install
3.PHPの設定ファイルをコピーします。
# cp php.ini-dist /usr/local/lib/php.ini
# cp /usr/local/src/php-5.3.1/php.ini-production /usr/local/lib/php.ini <-- 5.3.1の場合
4.ApacheでPHPを使用する設定をします
#vi /usr/local/apache2/conf/httpd.conf
自動的に追加されている箇所もあります。
LoadModule php5_module libexec/libphp5.so ←LoadModuleの最後に追記する。
--------------------------------------------------------------------------------------
DirectoryIndex index.html index.php index.html.var ←index.phpを追記する。
--------------------------------------------------------------------------------------
<IfModule mod_php5.c> ←以下の三行を追加
AddType application/x-httpd-php .phtml .php
</IfModule>
--------------------------------------------------------------------------------------
5.apache2の設定テスト
# /usr/local/apache2/bin/apachectl configtest
5-1.fedora7にてconfigtestでSyntax errorが発生
[エラー内容は]
Cannot load /.../libphp5.so into server: /.../libphp5.so: cannot restore segment prot after reloc: Permission denied
[原因]
SELinuxのセキュリティ制限にてエラーとなっている模様
[対策方法]
/etc/sysconfig/selinuxの修正
-----------------------------------------
SELINUX=enforcing <--修正前
SELINUX=disabled <--修正後
-----------------------------------------
修正後にサーバを再起動してapacheのテストを実行したら成功しました。
6.apache2の再起動
# /usr/local/apache2/bin/apachectl stop
# /usr/local/apache2/bin/apachectl start
※ apachectl restartだと設定が反映しない場合がありましたので、他への影響がなければ
stop & start で再起動したほうがよい。
7.テスト
下記PHPソース作成・起動し、Infomationが表示されれぱOKです。
<? phpinfo(); ?>
---------------------------
最終更新:2010年04月03日 16:59