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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1352899/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:07:17  来源:igfitidea点击:

Source install Apache 2.2.13 + PHP 5.3 + Snow Leopard

phpmysqlapacheosx-snow-leopard

提问by ricbax

Can anyone direct me to or write their experiences installing Apache and PHP on Snow Leopard?

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

I had this working in the past on Leopard, it would die after a security update, but was as simple as:

我过去在 Leopard 上使用过这个,它会在安全更新后消失,但很简单:

$ ./configure --enable-layout=Darwin --enable-mods-shared=all
$ make
$ sudo make install

and I was up and running again.

我又跑起来了。

Since the Snow Leopard update I get the following issue on make command

自从 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

采纳答案by ricbax

As most of you know Snow Leopard (SL) is based on 64-bit architecture, and when you install Xcode 3.2 that comes with SL the gcc compiler defaults to 4.2.1 and seems to default to x86_64 not i386.

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

Thanks to the following websites:

感谢以下网站:

My Solution:

我的解决方案:

  1. Follow the instructions on hivelogic.com for installing MySQL on SL

  2. Install Apache 2.2.14 via instructions on http://projects.serenity.de/php/- it uses 2.2.13 but replacing a 13 with a 14 is easy right? ;) After Apache (x86_64) is installed do the following:

    cd /usr/local/apache2/bin
    cp httpd /usr/sbin/
    cp apachectl /usr/sbin/
    

    As mentioned on http://www.kevinkorb.com/post/24

  3. Compile and install packages (freetype,gettext,libjpeg,libpng,mcrypt,mhash,etc) mentioned right after the Apache install instructions on http://projects.serenity.de/php/until IMAP, if you need IMAP then try the instructions mentioned in the url above but I didn't install since I didn't need it.

    NOTE: These all compiled as x86_64 with the exception of libpngwhich required the the following to be compiled as 64-bit:

    *export CFLAGS="-arch x86_64" ./configure

  4. This is where all the head banging on a desk and trial and error occurred. The installation of PHP 5.3.0. The biggest issue is with ICONV which has linking issues. I searched all over Google and some others were successful by editing the iconv.c file and the Makefile by adding -lresolv to the EXTRA_LIBS= after the ./configure string was executed. I was not so lucky, but still needed to make the edits for the --without-iconvparameter to work. Also --with-xmlrpcwould not work. For the iconv hacks please refer to this blog entry

  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/
    

    http://www.kevinkorb.com/post/24 所述

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

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

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

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

So here is my ./configure string:

所以这是我的 ./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


On a final note, I downloaded PHP-5.3.2-dev (http://snaps.php.net/) and it seems to have fixed the linking issues with ICONV and XMLRPC. The only changes that I've made to the above ./configure string were replace --without-iconvwith --with-iconv=/usr/localand added --with-xmlrpc. This is a dev version and I am sure that it still has bugs so use at your own discretion.

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

If you are having any issues please feel free to comment and I will try to help!

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

回答by Jess Portnoy

See here: http://bugs.php.net/bug.php?id=49267

见这里:http: //bugs.php.net/bug.php?id=49267

Basically:

基本上:

  1. Add "-lresolv" to MH_BUNDLE_FLAGS, EXTRA_LDFLAGS and EXTRA_LDFLAGS_PROGRAM in "Makefile"

  2. Change "ext/iconv/iconv.c"

    #define iconv libiconv

    to:

    #define iconv iconv

  1. 将“-lresolv”添加到“Makefile”中的 MH_BUNDLE_FLAGS、EXTRA_LDFLAGS 和 EXTRA_LDFLAGS_PROGRAM

  2. 更改“ext/iconv/iconv.c”

    #define iconv libiconv

    到:

    #define iconv iconv

As they say, worked for me.

正如他们所说,对我来说有效。

回答by Marcin Piechota

In apache source directory

在apache源目录中

cd srclib/apr-util/xml/expat
./configure
# OR ./configure --prefix=/{{YOURDIR}}/apache/source/httpd-2.2.22/srclib/apr-util/xml/expat/
sudo make install
# OR make install

Remember to clean up your previous apache install after make install failed

记得在 make install 失败后清理你之前的 apache 安装

cd {{YOURDIR}}/apache/
ls -la
rm -r bin
rm -r build
rm -r include
rm -r lib

回答by stephangroen

The guys from Liip maintain a great package for PHP and Apache on OS X, with really easy install. The package is very suitable for development. You could check it out here: http://php-osx.liip.ch/

Liip 的人为 OS X 上的 PHP 和 Apache 维护了一个很棒的包,安装非常简单。该包非常适合开发。你可以在这里查看:http: //php-osx.liip.ch/

This package installs the (usually) latest PHP 5.3.x/5.4.x on OS X 10.6 (aka Snow Leopard) and OS X 10.7 (aka Lion) in /usr/local/php5. It installs many useful extensions (see below) and ini-settings and is what we at Liip and Local.ch use for our development. It's especially suited for Symfony 2 development. It also provides a decent php.ini with all settings configured according to "Best Practices".

该软件包在 OS X 10.6(又名 Snow Leopard)和 OS X 10.7(又名 Lion)上安装(通常)最新的 PHP 5.3.x/5.4.x,位于 /usr/local/php5。它安装了许多有用的扩展(见下文)和 ini 设置,是我们 Liip 和 Local.ch 用于我们的开发的。它特别适合 Symfony 2 开发。它还提供了一个体面的 php.ini,其中包含根据“最佳实践”配置的所有设置。

You can then use the standard Apache and install MySQL (x64) with the package from the MySQL website.

然后,您可以使用标准的 Apache 并使用 MySQL 网站上的软件包安装 MySQL (x64)。

回答by stephangroen

Well if you have no need for a custom built version of PHP than perhaps the one Apple provides will do, but that is not the case, with the person who asked the question, or me for that matter as I seek an answer to the same question. Does anyone else have a suggestion?

好吧,如果您不需要自定义构建的 PHP 版本,也许 Apple 提供的版本就可以做到,但事实并非如此,对于提出问题的人,或者在我寻求相同答案时的我题。有没有其他人有建议?

回答by Marian

Maybe you didnt install the developer tools!

也许你没有安装开发者工具!

回答by Michael Aaron Safyan

Mac OS X Snow Leopard already comes with Apache 2.2 and PHP 5.3 pre-installed. Please see:

Mac OS X Snow Leopard 已经预装了 Apache 2.2 和 PHP 5.3。请参见:

http://www.brandonsavage.net/first-glance-apples-snow-leopard/

http://www.brandonsavage.net/first-glance-apples-snow-leopard/

It is probably best to leave those alone, as they are optimally configured for Snow Leopard.

最好不要理会它们,因为它们已针对 Snow Leopard 进行了优化配置。