PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Windows 系统下的安装> <Mac OS X 系统下的安装
Last updated: Mon, 26 Nov 2007

view this page in

在 Mac OS X 客户版编译

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

Warning

请注意,在按照下面的步骤操作时,应该停止 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
在 Mac OS X 客户版编译
mdoyle at cooperationireland dot org
07-Apr-2008 10:54
With OSX 10.5, the bundled version is up to date but didn't come with the modules I needed (notably I wanted the pgsql database extension).

Getting this to work was quite simple in the end, what made it difficult is the build-options for Apache. After searching on google, I found instructions to re-build apache with the following options:

./configure --enable-layout=Darwin --enable-mods-shared=all

(Step 1: download the latest Apache2.2 source files,
 Step 2: extract the tarball
 Step 3: ./configure --enable-layout=Darwin --enable-mods-shared=all
 Step 4: make all
 Step 5: sudo make install)

Without this step, when I rebuilt PHP either directly with the source from the PHP.net site or using MacPorts I was getting an error about the wrong architecture like this one:

httpd: Syntax error on line 114 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/libphp5.so into server: dlopen(/usr/libexec/apache2/libphp5.so, 10): no suitable image found.  Did find:\n\t/usr/libexec/apache2/libphp5.so: mach-o, but wrong architecture

After re-building and Apache with the configuration above and  restarting it, everything worked again and I can now use PostgreSQL from within PHP on my MacBook Pro.
rahul
09-May-2007 03:54
if `wget` isn't installed or not in your path use `curl -O` instead.

Windows 系统下的安装> <Mac OS X 系统下的安装
Last updated: Mon, 26 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites