源码安装Apache 2.2.13 + PHP 5.3 + Snow Leopard

ric*_*bax 5 php mysql apache osx-snow-leopard

任何人都可以指导我或写他们在Snow Leopard上安装Apache和PHP的经验吗?

我曾经在Leopard上工作,它会在安全更新后死掉,但是很简单:

$ ./configure --enable-layout=Darwin --enable-mods-shared=all
$ make
$ sudo make install
Run Code Online (Sandbox Code Playgroud)

我又站起来了.

自Snow Leopard更新后,我在make命令上遇到以下问题

libtool: link: cannot find the library `/usr/lib/libexpat.la' or unhandled argument `/usr/lib/libexpat.la'
make[2]: *** [htpasswd] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
Run Code Online (Sandbox Code Playgroud)

ric*_*bax 2

大多数人都知道 Snow Leopard (SL) 基于 64 位架构,当您安装 SL 附带的 Xcode 3.2 时,gcc 编译器默认为 4.2.1,并且似乎默认为 x86_64 而不是 i386。

感谢以下网站:

我的解决方案:

  1. 按照 hivelogic.com 上的说明在 SL 上安装 MySQL

  2. 通过http://projects.serenity.de/php/上的说明安装 Apache 2.2.14 - 它使用 2.2.13,但用 14 替换 13 很容易,对吗?;) 安装 Apache (x86_64) 后,执行以下操作:

    cd /usr/local/apache2/bin
    cp httpd /usr/sbin/
    cp apachectl /usr/sbin/
    
    Run Code Online (Sandbox Code Playgroud)

    正如http://www.kevinkorb.com/post/24中提到的

  3. 编译并安装在http://projects.serenity.de/php/上的 Apache 安装说明之后提到的软件包(freetype、gettext、libjpeg、libpng、mcrypt、mhash 等)直到 IMAP,如果您需要 IMAP,请尝试说明上面的网址中提到,但我没有安装,因为我不需要它。

    注意:这些都编译为 x86_64,但libpng除外,它需要将以下内容编译为 64 位:

    *导出 CFLAGS="-arch x86_64" ./configure

  4. 这就是所有头撞桌子、反复试验的地方。PHP 5.3.0的安装。最大的问题是 ICONV 存在链接问题。我在 Google 上进行了搜索,其他一些人通过编辑 iconv.c 文件和 Makefile(在执行 ./configure 字符串后将 -lresolv 添加到 EXTRA_LIBS= 来成功)。我没有那么幸运,但仍然需要对--without-iconv参数进行编辑才能工作。另外--with-xmlrpc 也不起作用。对于 iconv hacks,请参阅此博客条目

这是我的 ./configure 字符串:

./configure 
--prefix=/usr/local/php5
--without-iconv
--with-apxs2=/usr/local/apache2/bin/apxs
--enable-pdo
--with-gd 
--with-zlib 
--with-jpeg-dir=/usr/local 
--with-png-dir=/usr/local 
--with-libxml-dir=/usr/local 
--with-curl 
--with-mcrypt 
--with-pdo-mysql=/usr/local/mysql 
--with-mysqli=/usr/local/mysql/bin/mysql_config 
--with-mysql=/usr/local/mysql 
--with-mhash 
--with-libxml-dir=/usr/local 
--with-t1lib=/usr/local 
--with-xsl 
--with-freetype-dir=/usr/local 
--with-gettext 
--with-bz2=/usr 
--with-openssl=/usr 
--enable-bcmath 
--enable-calendar 
--enable-cgi 
--enable-exif 
--enable-ftp 
--enable-gd-native-ttf 
--enable-mbstring 
--enable-soap 
--enable-sqlite-utf8 
--enable-cli 
--enable-wddx 
--enable-zip

make
sudo make install
Run Code Online (Sandbox Code Playgroud)

最后一点,我下载了 PHP-5.3.2-dev ( http://snaps.php.net/ ),它似乎修复了 ICONV 和 XMLRPC 的链接问题。我对上面的 ./configure 字符串所做的唯一更改是将--without-iconv替换为--with-iconv=/usr/local并添加--with-xmlrpc。这是开发版本,我确信它仍然存在错误,因此请自行决定使用。

如果您有任何问题,请随时发表评论,我会尽力提供帮助!