软件准备
1. mysql server for mac ,到http://mysql.easynet.be/downloads/mysql/5.0.html#downloads 下载
2. php 5.2.6 mac os x 10.5自带
3. Apache httpd-2.2.11.tar.gz 的最新源代码http://httpd.apache.org/download.cgi
4. php 5.2.6 的源代码tar包
mac 也自带了apache,可以直接在控制面板的共享里启用apache服务,不过我一般是自己编译httpd.
配置httpd加载php5.so的模块
编辑/usr/local/httpd/conf/httpd.conf
查找LoadModule加上一行:
LoadModule php5_module modules/libphp5.so
保存退出。
安装gd库支持
mac 自带的php默认是没有启用gd支持的,需要额外编译gd库。在这里我走了很多弯路,最后在找到方法。想看英文的请参考http://www.gigoblog.com/2008/10/08/install-gd-for-php-on-mac-os-x-105-leopard/
以下内容引用自http://www.gigoblog.com/2008/10/08/install-gd-for-php-on-mac-os-x-105-leopard/
sudo bash
You will need to enter your administrator password.
输入密码。
Install libjpeg
The free image compression library, libjpeg, is required by GD.
First, let’s create a directory for storing the source files we’ll be downloading:
安装GD支持安装libjpeg,所以我们先创建一个源代码目录并下载代码编译安装。
mkdir -p /SourceCache
cd /SourceCache
Download the source file and unpack it:
下载并解压
curl -O http://www.ijg.org/files/jpegsrc.v6b.tar.gz
tar xzpf jpegsrc.v6b.tar.gz
cd /SourceCache/jpeg-6b
cp /usr/share/libtool/config.sub .
cp /usr/share/libtool/config.guess . For 32-bit only
, use the following command:
32位的使用:
./configure --enable-shared 64-bit
architecture uses this command instead:
64位的使用:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64
-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch
ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch
ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch
ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure
--enable-shared
Continue on for both architectures:
最后编译安装:
make clean
make
mkdir -p /usr/local/include
mkdir -p /usr/local/bin
mkdir -p /usr/local/lib
mkdir -p /usr/local/man/man1
make install
You now have compiled libjpeg!
这样libjpeg就安装好了。
下面安装GD库。
mkdir -p /SourceCache
cd /SourceCache
curl -O http://www.opensource.apple.com/darwinsource/10.5.5/apache_mod_php-44.1/php-5.2.6.tar.bz2
tar xjf php-5.2.6.tar.bz2
cd /SourceCache/php-5.2.6/ext/gd For 32-bit
use:
./configure --with-zlib-dir=/usr
--with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6
--with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6