PHP4 (+Apache)

参考文献

PHP4のインストールには、PHP国際化のページを参考にしました。

 

用意するもの

 

Apacheはそのまま使う

現在のApacheのバージョンチェック。

[root]# /usr/sbin/httpd -v
Server version: Apache/1.3.27 (Unix)
Server built: Oct 7 2002 10:55:56

 

ソースファイルの展開

/usr/local/src/ にソースファイルを用意し、tarで展開。

[root]# tar zxvf php-4.2.3-multibyte.tar.gz

 

(Apache版の) configure

PHP4 の configure。PotgreSQLとMySQLを使えるようにしています。

[root]# ./configure --enable-mbstring --enable-mbstr-enc-trans --enable-mbregex --enable-zend-multibyte --with-pgsql=/usr/local/pgsql --with-mysql=/usr/local/mysql --with-apxs=/usr/sbin/apxs --without-gd

 

(Apache版の) インストール

PHP4 をインストール。

[root]# make
[root]# make install

 

(コマンドライン版の) configure

私はコマンドライン版もインストールしています。コマンドライン版がいらなければ、ここは省略してください。

[root]# make distclean
[root]# ./configure --enable-mbstring --enable-mbstr-enc-trans --enable-mbregex --enable-zend-multibyte --with-pgsql=/usr/local/pgsql --with-mysql=/usr/local/mysql --enable-force-cgi-redirect --without-gd

 

(コマンドライン版の) インストール

PHP4 をインストール。

[root]# make
[root]# make install

 

/etc/httpd/conf/httpd.conf の編集

ServerNameのコメントを取る。

#ServerName server
    
ServerName server

以下の二つの設定を適当な位置へ追加。(似たような設定があるところに追加。)

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


DirectoryIndex index.html index.php

 

Apacheの再起動

[root]# /usr/sbin/apachectl stop
[root]# /usr/sbin/apachectl start

 

phpinfo()の実行

PHP4が正常にインストールされたかどうかを確認するために、/home/httpd/html/phpinfo.php というファイルを作成し、下記のプログラムを書く。

<?php phpinfo(); ?>

Webブラウザで、

http://OpenBlockS200のIPアドレス/phpinfo.php

を表示させ、PHPの設定内容が表示されたらインストールは成功です。
なにも表示されなかったり、プログラムがそのまま表示されたり、エラーが表示されたりした場合は、なにかが間違ってます。。。

 

設定ファイルのコピー

[root]# cd /usr/local/lib
[root]# cp /usr/local/src/php-4.2.3/php.ini-dist php.ini

 

php.iniの編集

php.iniに下記の設定をすればPHP4の設定は終了です。
php.iniの設定を有効にするためには、もう一度Apacheを再起動するか、OpenBlockS200を再起動してください。

;register_globals = Off
register_globals = On


[mbstring]
mbstring.internal_encoding = EUC-JP
mbstring.http_input = auto
mbstring.http_output = pass
mbstring.detect_order = auto
mbstring.substitute_character = none;

※PHP4.3.*は設定が変わっているようなので、上記の設定だけではうまく行かないかもしれません。

 

さいごに

以上でPHP+PostgreSQLが(おまけでMySQLも)動く環境ができました。
これで持ち運びができるPHP開発サーバができました。(^^)

 


Made with Dreamweaver MX