WWWサーバApacheの作成(PHP/FI付)

はじめに

Apacheを作成します。通常のApacheでしたらpkg_add一発なのですが、PHP/FIを組み込む必要があるため少々面倒です。

必要なファイル

php-2.0.1.tar.gz
kanji2.0.1.patch.gz

1. Apacheのソースの展開

packagesからgdbm-1.7.3.tgzをインストールして下さい。

ports-currentからapacheを取って来て、/usr/ports/www以下に展開して下さい。
% tar xvzf apache.tar.gz

ディレクトリを移動して、パッチを当てます。
% cd apache
% make patch

パッチがあたったソースをコピーします。
% cp -R work/apache_1.2.5 /root

Apacheを仮にインストールしておきます。
% make install

2. PHP/FIのインストール

php-2.0.1.tar.gzを~/に展開してパッチを当てます。
% tar xvzf php-2.0.1.tar.gz
% gzip -d kanji2.0.1.patch.gz
% cd php-2.0.1
% patch -p1 < ../kanji2.0.1.patch

デフォルトの出力漢字コードはEUCなのでJISに変更します。
src/kanjiconv.cを以下のように変更します。
int output_kanji_code=EUC;

int output_kanji_code=JIS;

installスクリプトを実行して質問に答えます。
% ./install

PHP/FI Installation

If you do not understand any of the following questions,
then the default should be safe - simply hit 'Return'.

Do you have mSQL installed on this system? [yN] 
Do you have Sybase libraries installed on this system [yN] 
Do you have Postgres installed in this system? [Yn] 
Top of your Postgres install tree? [/usr/local/pgsql] 
Do you have mysql installed on this system? [yN] 
Do you have Adabas installed in this system? [yN] 
Do you have Solid installed in this system? [yN] 
Do you have Oracle installed in this system? [yN] 
Do you have filePro installed in this system? [yN] 
Do you have ODBC installed in this system? [yN] 
Would you like to compile PHP/FI as an Apache module? [yN] y
Are you compiling for an Apache 1.1 or later server? [Yn] 
Are you using Apache-Stronghold? [yN] 
Does your Apache server support ELF dynamic loading? [yN] 
Apache source directory (which has httpd.h)? [/usr/local/etc/httpd/src] /root/apache_1.2.5/src
Would you like to include access control support? [yN] 
Would you like to include page logging support? [Yn] 

You need to choose a page logging directory.
This directory must be readable and writable by the
user id under which your http server runs.

Page logging directory? [/usr/local/etc/httpd/cgi-data] /usr/local/www/cgi-data
Would you like to include file upload support? [Yn] n
Would you like to build an ELF shared library? [yN] 
Additional directories to search for .h files []: /usr/local/include
Additional directories to search for library files []: /usr/local/lib

略

Do you want to use multi-byte extension for regex library? [y/N] y
Using multi-byte extension for regular expression library
makeします。
% cd src
% make

無事makeが終了したら以下を実行します。
% cp -R jp.regex /root/apache_1.2.5/src

3. Apacheのインストール

Apacheのソースに移動します。
% cd /root/apache_1.2.5/src

Cinfugyrationを以下のように修正します。
EXTRA_CFLAGS= \

PREFIX=/usr/local
EXTRA_CFLAGS= -I./jp.regex -DSERVER_SUBVERSION=\"PHP/FI-2.0.1\" \

EXTRA_LIBS=-lmd

EXTRA_LIBS=-lmd -L. -lphp -L/usr/local/lib -lgdbm -L/usr/local/pgsql/lib -lpq -L./jp.regex -lregex -lm

# Module example_module modules/example/mod_example.o

# Module example_module modules/example/mod_example.o
Module php_module mod_php.o

makeしてインストールします。
% ./Configure
% make
% cp httpd /usr/local/sbin

ディレクトリを作成します。
% mkdir /usr/local/www/cgi-data
% chown nobody.nogroup /usr/local/www/cgi-data

4. 各種設定

/usr/local/etc/apacheに移動して設定ファイルを作成します。
% cd /usr/local/etc/apache
% cp access.conf-dist access.conf
% cp httpd.conf-dist httpd.conf
% cp mime.types-dist mime.types
% cp srm.conf-dist srm.conf

srm.confを以下のように修正します。
DirectoryIndex index.html

DirectoryIndex index.html index.phtml

srm.confに以下を追加します。
# To use PHP/FI
AddType application/x-httpd-php .phtml

各ファイルをコメントに従って編集します。
私の所の設定はここを御覧下さい。

5. 起動

OSを再起動するか、以下のように実行します。
% /usr/local/etc/rc.d/apache.sh

6. 動作確認

/usr/local/www/data/index.phtmlを作成します。
% touch /usr/local/www/data/index.phtml

ブラウザで見て、以下のようになれば成功です。

0 total hits since Saturday March 14. 0 hits today.
No Previous Access to this page
Page was last updated on Saturday March 14, 1998 at 15:15:45

関連ページ

JAPANIZED APACHE SERVER PROJECT
PHP


元へ戻る