OSX下手工编译PHP开发环境

第一步是安装Xcode,Xcode可以通过app store 来安装,这里就不说了,虽说安装了xcode但是命令行工具什么的也还是没有,在装好xcode后要安装命令行工具。打开终端,命令如下:

xcode-select --install

接下来我们需要安装pkg-config,好多软件在编译的时候都需要pkg-config来寻找依赖;也可参考 http://www.l68.net/2139.html

#注 最新版是 0.29,在OSX 在make的时候会报C连接失败,多次尝试无解,但是0.28正常编译,看官不信自己测试
curl -o pkg-config-0.28.tar.gz http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz
tar -xf pkg-config-0.28.tar.gz
cd pkg-config-0.28
./configure  --with-internal-glib
make
sudo  make install
cd ../

接下来我们需要安装openssl,在10.11下openssl自带的版本是0.9.8,但是缺少头文件,我们还是编译一个好了;

curl -o openssl-1.0.2d.tar.gz http://openssl.org/source/openssl-1.0.2d.tar.gz
tar zxf openssl-1.0.2d.tar.gz
#不重新编译openssl wget会找不到头文件
./Configure darwin64-x86_64-cc --prefix=/usr/local
make
sudo make install
cd ../

好了,现在可以编译安装wget了;

curl -o wget-1.16.3.tar.gz http://ftp.gnu.org/pub/gnu/wget/wget-1.16.3.tar.gz
tar zxf wget-1.16.3.tar.gz
#如果装了pkg-config可以用下面这句
./configure --with-ssl=openssl
#Note if you still have an error in OS X 10.10+ and OS X 10.11+, use this variation of configure:
#如果没装pkg-config就用下面的,手动指定openssl的路径,不让wget自己寻找,因为他是用pkg-config来寻找的,没装pkg-config就没法configure通过
./configure --with-ssl=openssl --with-libssl-prefix=/usr/local
make
sudo make install
cd ../

下面就是编译PHP了,

 

wget -c http://mirrors.ustc.edu.cn/gnu/libtool/libtool-2.4.6.tar.gz
tar zxvf libtool-2.4.6.tar.gz
cd libtool-2.4.6/
./configure
make 
sudo make install
cd ../

wget -c http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar zxvf autoconf-2.69.tar.gz
cd autoconf-2.69/
./configure
make 
sudo make install
cd ../

wget -c http://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz
tar zxvf automake-1.15.tar.gz
cd automake-1.15/
./configure
make 
sudo make install
cd ../

wget -c http://zlib.net/zlib-1.2.8.tar.gz
tar zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure
make 
sudo make install
cd ../

wget -c http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar zxvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6/
make 
sudo make install
cd ../

wget -c http://www.libssh2.org/download/libssh2-1.6.0.tar.gz
tar zxvf libssh2-1.6.0.tar.gz
cd libssh2-1.6.0/
./configure
make 
sudo make install
cd ../

wget -c https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz
tar zxf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable/
./configure 
make
sudo make install
cd ../

wget -c http://curl.haxx.se/download/curl-7.45.0.tar.gz
tar zxvf curl-7.45.0.tar.gz
cd curl-7.45.0/
./configure --with-libssh2 --with-gssapi
make 
sudo make install
cd ../

wget -c http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14/
./configure
make 
sudo make install
cd ../

wget -c http://7xk96f.com1.z0.glb.clouddn.com/software/mcrypt/libmcrypt-2.5.8.tar.gz
tar zxvf libmcrypt-2.5.8.tar.gz 
cd libmcrypt-2.5.8/
./configure
make 
sudo make install
cd libltdl/
./configure --enable-ltdl-install
make 
sudo make install
cd ../../

wget -c http://7xk96f.com1.z0.glb.clouddn.com/software/mhash/mhash-0.9.9.9.tar.gz
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
sudo make install
cd ../


wget -c http://7xk96f.com1.z0.glb.clouddn.com/software/mcrypt/mcrypt-2.6.8.tar.gz
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
export LD_LIBRARY_PATH=/usr/local/lib
export LDFLAGS="-L/usr/local/lib/ -I/usr/local/include/"
export CFLAGS="-I/usr/local/include/"
./configure
make 
sudo make install
cd ../

wget -c http://7xk96f.com1.z0.glb.clouddn.com/software/luajit/LuaJIT-2.0.4.tar.gz
tar zxf LuaJIT-2.0.4.tar.gz
cd LuaJIT-2.0.4
make && sudo make install
cd ../

wget -c http://7xk96f.com1.z0.glb.clouddn.com/software/pcre/pcre-8.37.tar.gz
tar zxf pcre-8.37.tar.gz
cd pcre-8.37
./configure
make && sudo make install
cd ../

curl -o php-5.6.15.tar.gz http://hk1.php.net/get/php-5.6.15.tar.gz/from/this/mirror
tar zxf php-5.6.14.tar.gz
cd php-5.6.14/
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/private/etc --with-apxs2=/usr/sbin/apxs --with-config-file-path=/etc --with-config-file-scan-dir=/private/etc/php --with-libxml-dir --with-openssl --with-kerberos --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --enable-fpm --enable-ftp --with-png-dir --with-gd --with-jpeg-dir --enable-gd-native-ttf --with-icu-dir --enable-mbstring --enable-mbregex --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-xmlrpc --with-readline --with-iconv-dir --with-xsl --enable-zip --with-pcre-regex --with-freetype-dir --enable-xml --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pdo-sqlite --with-sqlite3 --disable-rpath  --enable-inline-optimization --with-mcrypt  --with-mhash --enable-pcntl --enable-sockets  --without-pear --with-gettext --enable-fileinfo --enable-opcache --enable-cli
make ZEND_EXTRA_LIBS='-liconv'
sudo make install

cp php.ini-production /etc/php.ini
cp /etc/php-fpm.conf.default /etc/php-fpm.conf

wget -c http://7xk96f.com1.z0.glb.clouddn.com/software/tengine/tengine-2.1.0.tar.gz
tar zxf tengine-2.1.0.tar.gz
cd tengine-2.1.0
./configure --prefix=/usr --sbin-path=/usr/sbin --dso-path=/usr/lib/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/private/var/log/nginx/access.log --error-log-path=/private/var/log/nginx/error.log --lock-path=/private/var/lock/nginx.lock --pid-path=/private/var/run/nginx.pid --http-client-body-temp-path=/private/var/lib/nginx/body --http-fastcgi-temp-path=/private/var/lib/nginx/fastcgi --http-proxy-temp-path=/private/var/lib/nginx/proxy --http-scgi-temp-path=/private/var/lib/nginx/scgi --http-uwsgi-temp-path=/private/var/lib/nginx/uwsgi --with-luajit-inc=/usr/local/include/luajit-2.0 --with-luajit-lib=/usr/local/lib --with-ipv6 --with-mail --with-pcre-jit --with-http_ssl_module --with-http_sub_module --with-http_flv_module --with-mail_ssl_module --with-http_dav_module --with-http_xslt_module --with-http_spdy_module --with-http_geoip_module --with-http_realip_module --with-http_addition_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_image_filter_module --with-http_lua_module=shared --with-http_footer_filter_module=shared --with-http_sysguard_module=shared --with-http_limit_req_module=shared --with-http_trim_filter_module=shared --with-http_upstream_ip_hash_module=shared --with-http_upstream_least_conn_module=shared --with-http_upstream_session_sticky_module=shared --with-http_concat_module=shared --with-cc-opt="-Wno-deprecated-declarations"

make && sudo make install
cd ../

#汉化站点目录
mkdir /Users/XXX/Sites
mkdir /Users/XXX/Sites/.localized

未经允许不得转载:SuperMan's blog » OSX下手工编译PHP开发环境

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址