在 Mac OS X 客户版编译

以下说明将会帮助在 Mac OS X 下为 Apache 服务器安装 PHP 模块,并添加 MySQL 和 PostgreSQL 的支持。本说明是由 Marc Liyanage 提供的。

警告

请注意,在按照下面的步骤操作时,应该停止 Apache 服务器!

按照下面的步骤安装:

  1. 打开终端窗口。

  2. 输入 wget http://www.diax.ch/users/liyanage/software/macosx/libphp4.so.gz,等待下载完毕。

  3. 输入 gunzip libphp4.so.gz

  4. 输入 sudo apxs -i -a -n php4 libphp4.so

  5. 现在输入 sudo open -a TextEdit /etc/httpd/httpd.conf。TextEdit 将把 web 服务器的配置文件打开。在文件的末尾找到下面两行(使用查找命令):
    #AddType application/x-httpd-php .php
    #AddType application/x-httpd-php-source .phps
    将它们前面的两个井号(#)去掉,然后保存文件并退出 TextEdit。

  6. 最后,输入 sudo apachectl graceful 重新启动 web 服务器。

PHP 现在应该已经配置好,并且正在运行了。可以在 Sites 文件夹创建一名为 test.php 的文件。该文件的内容为: <?php phpinfo() ?>

现在在 web 浏览器浏览 127.0.0.1/~your_username/test.php。应该可以看到一个表格列出了 PHP 模块的信息。


add a note add a note User Contributed Notes
Michael Hawkshaw
14-Sep-2004 04:11
Please note that Marc has now compiled a PHP 5.0.1 version of his package. It can be downloaded at:

http://www.entropy.ch/software/macosx/php/

There is also a forum on his site for discussing his package should you have have any queries/issues.
BjarneDM <macintosh at mathiesen dot info>
28-Aug-2004 02:09
This will only install a precompiled PHP4 module for the Apache 1.3.x included by Apple in Mac OS X client. This will not install a cli version of PHP.

If you want to play with Apache2 and PHP the way to go is ServerLogistics < http://www.serverlogistics.com/ >, but this will still be a precompiled version. On the other hand you can both get the Apache2 module and a cli version.

ServerLogistics does include some rudimentary information on how to compile yourself on Mac OS X in the pdf documentation, but it is erroneous in some circumstances, and for newer versions of PHP will neccesiate installation of fink < http://fink.sourceforge.net/ > or darwinports < http://darwinports.opendarwin.org/ > in order to get newer libraries.