PHPのインストール

会社のホームページを「作り直せ」とお偉い人に言われ、PHP版に作り直そうと作業中。
職場にはPHPの環境が無いのでマイPCを持ち込んで開発することに。
で、いっちょCygwinPHPを入れてみようかなと思い、ネット上の情報を参考にやってみた。

すんなり行かなかったところは先日のハードリカバリのおかげでCygwinがほぼノーマル(Apacheぐらいしか入ってない)状態だったのでgccflexが無いおかげでconfigureとかでエラーが出たぐらい。

比較的すんなり行った。
手順は下記。

パスを通す

$ export PATH=/usr/local/apache/libexec:$PATH

tarを展開して

$ tar jxvf php-4.4.0.tar.bz2
$ cd php-4.4.0

configure

$ ./configure --with-apxs=/usr/sbin/apxs --without-mysql --enable-mbstring

+------------------------------------------------------------------+
|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.                           |
+------------------------------------------------------------------+
|                         *** NOTE ***                             |
|           The default for register_globals is now OFF!           |
|                                                                  |
|If your application relies on register_globals being ON, you      |
|should explicitly set it to on in your php.ini file.              |
|Note that you are strongly encouraged to read                     |
|http://www.php.net/manual/en/security.registerglobals.php         |
|about the implications of having register_globals set to on, and  |
|avoid using it if possible.                                       |
+------------------------------------------------------------------+

Thank you for using PHP.

こんな感じになればOK

libphp4.soをlibphp4.dllに置き換える

$ sed -i.org 's/libphp4\.so/libphp4.dll/g' Makefile
$ diff Makefile.org Makefile

make

$ make
$ cd libs
$ ls
libphp4.a libphp4.la

上の状態からdllを作る

$ gcc -shared -o libphp4.dll -Wl,--out-implib=libphp4.dll.a \
-Wl,--export-all-symbols \
-Wl,--whole-archive libphp4.a /bin/libhttpd.dll \
-Wl,--no-whole-archive -lcrypt -lresolv

うまくいくとこんな感じ

$ ls
libphp4.a libphp4.dll libphp4.dll.a libphp4.la

ファイル名を省略した場合、読み込むファイルに index.php を追加。


DirectoryIndex index.html index.php

拡張子が php の場合に php スクリプトを実行するように設定。
(# AddType application/x-tar .tgz の記述の下くらいがいいらしい)

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

あとはapacheを再起動して動作確認。

参考サイト:
http://www.asahi-net.or.jp/~wv7y-kmr/memo/php.html#Cygwin_PHP
http://discypus.jp/wiki/?cmd=read&page=Cygwin%2Fapache%2Fphp