Mac OSX10.10.1编译安装php开发环境

下载PDF版:Mac OSX10.10.1编译安装php开发环境

1.确保安装了xcode,没有的话先在AppStore⾥里搜索安装 再运⾏行以下命令

xcode-select --install #这个命令会提⽰示安装命令⾏行开发⼯工具 cd /Applications/Xcode.app/Contents/Developer/Toolchains/ ln -s XcodeDefault.xctoolchain OSX10.10.xctoolchain 下载pcre pcre-8.36.tar.gz

tar -xvf pcre-8.36.tar.gz

./configure

make

make install

2.下载apache httpd-2.4.10.tar.gz 下载php cl1.php.net

3.新建macphp⽂文件夹,把下载好的⽂文件解压到⾥里⾯面,好操作 ⾸首先编译安装apache
mkdir -p /Users/xiaoniba/AMP/apache2
mkdir -p /Users/xiaoniba/AMP/php

cd /User/xiaoniba/Downloads/macphp/httpd-2.4.10

./configure --prefix=/Users/xiaoniba/AMP/apache2 --enable-modules=most --enable-mods-
shared=all
make
make install
cd /usr/sbin
mv httpd httpd.old
mv apachectl apachectl.old
ln -s /Users/xiaoniba/AMP/apache2/bin/apachectl apachectl
ln -s /Users/xiaoniba/AMP/apache2/bin/httpd httpd
httpd -k start

打开localhsot 如果, It’s work ! 表⽰示安装成功。 4.下载mysql安装 http://dev.mysql.com/downloads/mysql/

今天还没有10.10的。先下载个10.9的,安装时要把第三项(startup item)的勾去掉不然装不上

5.下载zlib zlib-1.2.8.tar.gz tar -xvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure

make
sudo make install cd ..

下载libpng libpng-1.6.15.tar.xz tar -zxf libpng-1.6.6.tar.xz
cd libpng-1.6.6
./configure

make
sudo make install cd ..

下载jpeg jpegsrc.v9a.tar tar -zxf jpegsrc.v9a.tar.gz cd jpeg-9
./configure

make
sudo make install cd ..

下载freetype freetype-2.5.3.tar.gz tar -zxf freetype-2.5.3.tar.gz
cd freetype-2.5.3
./configure

make
sudo make install cd ..

下载 libgd libgd-2.1.0.tar.xz
tar -zxf libgd-2.1.0.tar.xz
cd libgd-2.1.0
./configure --with-zlib=/usr/local --with-jpeg=/usr/local --with-png=/usr/local --with- freetype=/usr/local

make
sudo make install cd ..

下载libmcrypt http://mcrypt.hellug.gr/lib/

tar -zxf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7

./configure make
make install

6.编译php
下载php http://php.net tar -zxf php-5.6.3.tar.gz cd php-5.6.3

./configure --prefix=/Users/xiaoniba/AMP/php --with-config-file-path=/Users/xiaoniba/AMP/php -- with-apxs2=/Users/xiaoniba/AMP/apache2/bin/apxs --with-openssl --with-zlib-dir=/usr/local -- enable-bcmath --with-bz2 --with-curl --enable-zip --enable-ftp --with-gd --with-jpeg-dir=/usr/local --with-png- dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-mhash --enable-mbstring --enable-soap --with-iconv --with-pear --enable-session --with-mcrypt --enable-opcache=no -- enable-sockets --with-mysql=/usr/local/mysql-5.6.21-osx10.8-x86_64 --with- mysqli=/usr/local/mysql-5.6.21-osx10.8-x86_64/bin/mysql_config

make
尼玛,遇到错误~~~~ clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [libs/libphp5.bundle] Error 1” ~~~~ 解决办法 export LDFLAGS=-lresolv
再来
make clean && make

⽈曰⼜又来错误 ~~~~~dyld: Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/xiaoniba/Downloads/macphp/php-5.6.3/sapi/cli/php Reason: image not found

/bin/sh: line 1: 29581 Trace/BPT trap: 5 ` if test -x "/Users/xiaoniba/Downloads/macphp/php- 5.6.3/sapi/cli/php"; then /Users/xiaoniba/Downloads/macphp/php-5.6.3/build/shtool echo -n -- "/Users/xiaoniba/Downloads/macphp/php-5.6.3/sapi/cli/php -n"; if test "x" != "x"; then /Users/xiaoniba/Downloads/macphp/php-5.6.3/build/shtool echo -n -- " -d extension_dir=/Users/xiaoniba/Downloads/macphp/php-5.6.3/modules"; for i in bz2 zlib phar; do if test -f "/Users/xiaoniba/Downloads/macphp/php-5.6.3/modules/$i.la"; then . /Users/xiaoniba/Downloads/macphp/php-5.6.3/modules/$i.la; /Users/xiaoniba/Downloads/macphp/php-5.6.3/build/shtool echo -n -- " -d extension=$dlname"; fi; done; fi; else /Users/xiaoniba/Downloads/macphp/php-5.6.3/build/shtool echo -n -- "/Users/xiaoniba/Downloads/macphp/php-5.6.3/sapi/cli/php"; fi;` -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 -d 'safe_mode=0' /Users/xiaoniba/Downloads/macphp/php-5.6.3/ext/phar/build_precommand.php > ext/phar/phar.php

make: *** [ext/phar/phar.php] Error 133 ~~~~

解决办法:ln -s /usr/local/mysql-5.6.21-osx10.8-x86_64/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

make clean make

终于成功了。
最后记得在httpd.conf添加 AddType application/x-httpd-php .php

版权声明:
作者:xiaoniba
链接:https://blog.xiaoniba.com/2014/11/29/mac-osx10-10-1%e7%bc%96%e8%af%91%e5%ae%89%e8%a3%85php%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83-2/
来源:小泥吧的博客
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>