在 Mac OS X 伺服器版編譯

Mac OS X 伺服器安裝.

  1. 獲得最新版本的 Apache 和 PHP。

  2. 將它們的 tar 包解壓,然後如下運行 Apache 的 configure 程式。
    ./configure --exec-prefix=/usr \
    --localstatedir=/var \
    --mandir=/usr/share/man \
    --libexecdir=/System/Library/Apache/Modules \
    --iconsdir=/System/Library/Apache/Icons \
    --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
    --enable-shared=max \
    --enable-module=most \
    --target=apache

  3. 若果想對編譯做些改善,可以增加下面一行:
    setenv OPTIM=-O2

  4. 接下來,進入 PHP 4 原始碼目錄,並進行 configure 動作。
    ./configure --prefix=/usr \
        --sysconfdir=/etc \
        --localstatedir=/var \
        --mandir=/usr/share/man \
        --with-xml \
        --with-apache=/src/apache_1.3.12
    若果需要其它附加功能(MySQL、GD 等),務必將它們新增到這裡。對於 --with-apache 參數,需要將其路徑指向 Apache 原始碼目錄,例如 /src/apache_1.3.12

  5. 輸入 makemake install。這樣在 Apache 原始碼目錄中會建立一名為 src/modules/php4 的目錄。

  6. 現在,重新配置 Apache 以編譯 PHP 4。
    ./configure --exec-prefix=/usr \
    --localstatedir=/var \
    --mandir=/usr/share/man \
    --libexecdir=/System/Library/Apache/Modules \
    --iconsdir=/System/Library/Apache/Icons \
    --includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
    --enable-shared=max \
    --enable-module=most \
    --target=apache \
    --activate-module=src/modules/php4/libphp4.a
    可能會被告知 libmodphp4.a 太舊了。若果出現這個情況,進入 Apache 原始碼目錄中的 src/modules/php4 目錄,並運行該指令: ranlib libmodphp4.a。然後返回到 Apache 原始碼根目錄,再次運行上面的 configure 指令。這樣便會更新連線表。然後再次運行 makemake install 指令。

  7. 從 PHP 4 原始碼目錄複製並更名 php.ini-dist 檔案到 bin 目錄:cp php.ini-dist /usr/local/bin/php.ini 或(若果沒有 local 目錄)cp php.ini-dist /usr/bin/php.ini