之前搞开发一直都是OS X自带的php5.5,而后须要的扩展使用phpize编译,可是逐渐的自带的php已经没法知足我了,因此准备本身手动编译php。php
首先须要下载php的依赖的库,OS X自带了许多有用的库,可是这些须要你安装xcode命令行工具,这些库的头文件和静态库动态库文件被存放在/usr目录下,包括curl、openssl、libedit等库,咱们只须要下载gd库依赖的libjpeg libpng freetype2就能够了。
具体须要的库能够查看PHP文档mysql
如今咱们开始编译下列库sql
由于不想要把这些库永久编译安装到系统,因此咱们须要新建一个文件夹来存放这些库mkdir ~/local
,而后开始编译这些库xcode
注意!因为是编译安装到自定义目录,因此每一个库的
./configure --prefix=/path/to/local
是必须的。
其次libmcrypt
在PHP文档Mcrypt.installation中推荐增长--disable-posix-threads
,因此咱们也须要加上这个选项。
最后libmcrypt
还须要启用静态库,由于咱们但愿php是以静态库的方式加载这个./configure --prefix=/path/to/local --disable-posix-threads --enable-static
curl
最后请注意将全部的dylib等动态库文件所有删除或者重命名,只留下xxx.a
静态库文件,不然编译的时候php会优先使用动态库文件,那样就没法删除~/local/
文件夹了socket
没什么话好说,就是Unix三板斧./configure make&make install
工具
./configure --enable-fpm --enable-cli --with-config-file-path=/usr/local/etc --with-config-file-scan-dir=/usr/local/etc/php.d --with-libxml-dir=/usr --with-openssl=/usr --with-kerberos=/usr --with-zlib=/usr --with-zlib-dir=/usr --enable-bcmath --with-bz2=/usr --enable-calendar --with-curl=/usr --enable-exif --enable-ftp --with-openssl-dir=/usr --with-jpeg-dir=/Users/tangjiacheng/Downloads/local --with-png-dir=/Users/tangjiacheng/Downloads/local --with-freetype-dir=/Users/tangjiacheng/Downloads/local --enable-gd-native-ttf --with-ldap=/usr --with-ldap-sasl=/usr --enable-mbstring --with-mcrypt=/Users/tangjiacheng/Downloads/local --with-mysql --with-mysql-sock=/tmp/mysql.sock --with-mysqli --with-pdo-mysql --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy=/usr --enable-wddx --with-xmlrpc --with-iconv-dir=/usr --with-xsl=/usr --enable-zip --enable-mysqlnd --with-libedit --with-gd
最后安装完成了还须要复制php-production.ini
或者php-development.ini
url