0%

从源码编译PHP-5.3

下面使用的工具和源码都以PHP-5.3.13作为基础

需要准备的工具

官网上的需求:

autoconf: 2.13+ (for PHP < 5.4.0), 2.59+ (for PHP >= 5.4.0)
automake: 1.4+
libtool: 1.4.x+ (except 1.4.2)
re2c: Version 0.13.4 or newer
flex: Version 2.5.4 (for PHP <= 5.2)
bison:
PHP 5.4: 1.28, 1.35, 1.75, 1.875, 2.0, 2.1, 2.2, 2.3, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.5, 2.5.1, 2.6, 2.6.1, 2.6.2, 2.6.4
PHP 5.5: 2.4, 2.4.1, 2.4.2, 2.4.3, 2.5, 2.5.1, 2.6, 2.6.1, 2.6.2, 2.6.3, 2.6.4, 2.6.5, 2.7
PHP 5.6: 2.4 or later, excluding 3.0 only (3.0.1 and later are OK)
PHP 7.0: 2.4 or later

本次使用:

安装autoconf

wget https://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz
tar -zxvf autoconf-2.13.tar.gz
cd autoconf-2.13
./configure –prefix=/Users/Sinute/local
make
make install

安装automake

wget https://ftp.gnu.org/gnu/automake/automake-1.4.tar.gz
tar -zxvf automake-1.4.tar.gz
cd automake-1.4
./configure –prefix=/Users/Sinute/local
make
make install

安装libtool

wget https://ftp.gnu.org/gnu/libtool/libtool-1.4.tar.gz
tar -zxvf libtool-1.4.tar.gz
cd libtool-1.4
./configure –prefix=/Users/Sinute/local
make
make install

安装re2c

wget https://github.com/skvadrik/re2c/releases/download/0.13.6/re2c-0.13.6.tar.gz
tar -zxvf re2c-0.13.6.tar.gz
cd re2c-0.13.6
./configure –prefix=/Users/Sinute/local
make
make install

最后 export PATH=/Users/Sinute/local:$PATH

编译PHP

http://php.net/releases/ 下载PHP源代码

wget http://museum.php.net/php5/php-5.3.13.tar.gz
tar -zxvf php-5.3.13.tar.gz
cd php-5.3.13
./configure –prefix=/Users/Sinute/local –enable-debug –enable-maintainer-zts –enable-fpm
make
make install

这里带上了–enable-debug, 便于后续开发

编译的时候会报 make: *** [ext/dom/node.lo] Error 1

解决方法:

curl -o php-5.3.13.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
patch -p0 -b < php-5.3.13.patch