Mac OS X 系统下的安装
PHP 手册

在 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


Mac OS X 系统下的安装
PHP 手册