Mac OS X 上构建 PHP5

在安装 PHP 前先安装 Mysql,Apache2 我用的是 Mac 内置的那个。下载 PHP 5.2.9 源码,然后执行:
./configure –prefix=/usr/local –with-iconv –with-gd
–with-xmlrpc –enable-zip –with-openssl=/usr –enable-ftp –enable-sockets
–enable-mbstring –enable-bcmath –with-curl –with-zlib-dir=/usr
–with-mysqli=/usr/local/mysql/bin/mysql_config
–with-mysql=/usr/local/mysql
–with-config-file-path=/etc/php.ini –with-apxs2=/usr/sbin/apxs
配置过程中会因为缺少某些开发包而出错,用 Mac port 安装一下就可以了

make && sudo make install

这样创建的 libphp5.so 是无法被 Apache 载入的,需要用 lipo 处理一下 Apache 的二进制程序

/usr/sbin$ sudo cp httpd httpd-fat
/usr/sbin$ sudo lipo httpd -thin i386 -output httpd

完了重启 Apache 就可以使用了:
sudo apachectl restart

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>