在 ubuntu 14.04 上使用 ZTS 支持编译 PHP

Compile PHP with ZTS support on ubuntu 14.04

我一直在尝试使用 ZTS 支持编译 PHP,但没有成功。我试过几篇文章,但这一篇似乎完全符合我的要求 -

https://www.digitalocean.com/community/questions/enable-zts-support-on-ubuntu-14-04

但是,我无法正常工作。

如果我不加修改地编译源代码,它编译得很好。只要我执行以下步骤 -

Find the section starting with COMMON_CONFIG=--build=$(DEB_BUILD_GNU_TYPE) \ and add the following configure flags:

        --enable-maintainer-zts \
        --enable-pthreads \

Then we want to bump the version number for the package, so that it is higher than the version of PHP in the repository. Run dch -i and create a new changelog entry:

php5 (5.5.9+dfsg-1ubuntu4.5+zts1) trusty; urgency=medium

  • Rebuild with ZTS support.

    -- You Mon, 10 Nov 2014 13:14:32 -0500


我得到以下输出(仅显示错误开始出现的位置)-

  libtool: compile:  /php5-5.5.9+dfsg/apache2-build/meta_ccld -IZend/ -I/php5-5.5.9+dfsg/Zend/ -DPHP_ATOM_INC -I/php5-5.5.9+dfsg/apache2-build/in                                            clude -I/php5-5.5.9+dfsg/apache2-build/main -I/php5-5.5.9+dfsg -I/php5-5.5.9+dfsg/apache2-build/ext/date/lib -I/php5-5.5.9+dfsg/ext/date/lib -I                                            /php5-5.5.9+dfsg/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/enchant -I/usr/X11 -I/usr/include/freetype2 -I/usr/include/x86_64-linux-g                                            nu -I/php5-5.5.9+dfsg/ext/mbstring/oniguruma -I/php5-5.5.9+dfsg/apache2-build/ext/mbstring/oniguruma -I/php5-5.5.9+dfsg/ext/mbstring/libmbfl -I                                            /php5-5.5.9+dfsg/apache2-build/ext/mbstring/libmbfl -I/php5-5.5.9+dfsg/ext/mbstring/libmbfl/mbfl -I/php5-5.5.9+dfsg/apache2-build/ext/mbstring/                                            libmbfl/mbfl -I/usr/include/mysql -I/usr/include/postgresql -I/usr/include/pspell -I/usr/include/tidy -I/php5-5.5.9+dfsg/apache2-build/TSRM -I/                                            php5-5.5.9+dfsg/apache2-build/Zend -I/php5-5.5.9+dfsg/main -I/php5-5.5.9+dfsg/Zend -I/php5-5.5.9+dfsg/TSRM -I/php5-5.5.9+dfsg/apache2-build/ -D                                            _FORTIFY_SOURCE=2 -D_REENTRANT -I/usr/include -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -O2 -Wall -fs                                            igned-char -fno-strict-aliasing -g -pthread -DZTS -c /php5-5.5.9+dfsg/Zend/zend.c  -fPIC -DPIC -o Zend/.libs/zend.o
    /php5-5.5.9+dfsg/Zend/zend.c: In function 'zend_error':
    /php5-5.5.9+dfsg/Zend/zend.c:1043:28: warning: 'error_lineno' may be used uninitialized in this function [-Wmaybe-uninitialized]
          active_opline->lineno = error_lineno;
                                ^
    echo "# Generated by Makefile for libtool" > Zend/zend_dtrace.d.lo
    if CFLAGS="-I/usr/include -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -O2 -Wall -fsigned-char -fno-stri                                            ct-aliasing -g -pthread -DZTS" dtrace -G -o Zend/.libs/zend_dtrace.d.o -s /php5-5.5.9+dfsg/Zend/zend_dtrace.d  main/.libs/main.o Zend/.libs/zen                                            d_API.o Zend/.libs/zend_execute.o Zend/.libs/zend_exceptions.o Zend/.libs/zend_dtrace.o Zend/.libs/zend.o 2> /dev/null && test -f "Zend/.libs/z                                            end_dtrace.d.o"; then \
              echo "pic_object='.libs/zend_dtrace.d.o'" >> Zend/zend_dtrace.d.lo ;\
            else \
              echo "pic_object='none'" >> Zend/zend_dtrace.d.lo ;\
            fi
    if CFLAGS="-I/usr/include -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -O2 -Wall -fsigned-char -fno-stri                                            ct-aliasing -g -pthread -DZTS" dtrace -G -o Zend/zend_dtrace.d.o -s /php5-5.5.9+dfsg/Zend/zend_dtrace.d main/main.o Zend/zend_API.o Zend/zend_e                                            xecute.o Zend/zend_exceptions.o Zend/zend_dtrace.o Zend/zend.o 2> /dev/null && test -f "Zend/zend_dtrace.d.o"; then \
              echo "non_pic_object='zend_dtrace.d.o'" >> Zend/zend_dtrace.d.lo ;\
            else \
              echo "non_pic_object='none'" >> Zend/zend_dtrace.d.lo ;\
            fi
    /bin/bash /php5-5.5.9+dfsg/apache2-build/libtool --preserve-dup-deps --mode=compile /php5-5.5.9+dfsg/apache2-build/meta_ccld -Iext/date/lib -Ie                                            xt/date/ -I/php5-5.5.9+dfsg/ext/date/ -DPHP_ATOM_INC -I/php5-5.5.9+dfsg/apache2-build/include -I/php5-5.5.9+dfsg/apache2-build/main -I/php5-5.5                                            .9+dfsg -I/php5-5.5.9+dfsg/apache2-build/ext/date/lib -I/php5-5.5.9+dfsg/ext/date/lib -I/php5-5.5.9+dfsg/ext/ereg/regex -I/usr/include/libxml2                                             -I/usr/include/enchant -I/usr/X11 -I/usr/include/freetype2 -I/usr/include/x86_64-linux-gnu -I/php5-5.5.9+dfsg/ext/mbstring/oniguruma -I/php5-5.                                            5.9+dfsg/apache2-build/ext/mbstring/oniguruma -I/php5-5.5.9+dfsg/ext/mbstring/libmbfl -I/php5-5.5.9+dfsg/apache2-build/ext/mbstring/libmbfl -I/                                            php5-5.5.9+dfsg/ext/mbstring/libmbfl/mbfl -I/php5-5.5.9+dfsg/apache2-build/ext/mbstring/libmbfl/mbfl -I/usr/include/mysql -I/usr/include/postgr                                            esql -I/usr/include/pspell -I/usr/include/tidy -I/php5-5.5.9+dfsg/apache2-build/TSRM -I/php5-5.5.9+dfsg/apache2-build/Zend -I/php5-5.5.9+dfsg/m                                            ain -I/php5-5.5.9+dfsg/Zend -I/php5-5.5.9+dfsg/TSRM -I/php5-5.5.9+dfsg/apache2-build/  -D_FORTIFY_SOURCE=2 -D_REENTRANT  -I/usr/include -g -O2                                             -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -O2 -Wall -fsigned-char -fno-strict-aliasing -g -pthread -DZTS  -c                                             /php5-5.5.9+dfsg/ext/date/php_date.c -o ext/date/php_date.lo
    libtool: compile:  /php5-5.5.9+dfsg/apache2-build/meta_ccld -Iext/date/lib -Iext/date/ -I/php5-5.5.9+dfsg/ext/date/ -DPHP_ATOM_INC -I/php5-5.5.                                            9+dfsg/apache2-build/include -I/php5-5.5.9+dfsg/apache2-build/main -I/php5-5.5.9+dfsg -I/php5-5.5.9+dfsg/apache2-build/ext/date/lib -I/php5-5.5                                            .9+dfsg/ext/date/lib -I/php5-5.5.9+dfsg/ext/ereg/regex -I/usr/include/libxml2 -I/usr/include/enchant -I/usr/X11 -I/usr/include/freetype2 -I/usr                                            /include/x86_64-linux-gnu -I/php5-5.5.9+dfsg/ext/mbstring/oniguruma -I/php5-5.5.9+dfsg/apache2-build/ext/mbstring/oniguruma -I/php5-5.5.9+dfsg/                                            ext/mbstring/libmbfl -I/php5-5.5.9+dfsg/apache2-build/ext/mbstring/libmbfl -I/php5-5.5.9+dfsg/ext/mbstring/libmbfl/mbfl -I/php5-5.5.9+dfsg/apac                                            he2-build/ext/mbstring/libmbfl/mbfl -I/usr/include/mysql -I/usr/include/postgresql -I/usr/include/pspell -I/usr/include/tidy -I/php5-5.5.9+dfsg                                            /apache2-build/TSRM -I/php5-5.5.9+dfsg/apache2-build/Zend -I/php5-5.5.9+dfsg/main -I/php5-5.5.9+dfsg/Zend -I/php5-5.5.9+dfsg/TSRM -I/php5-5.5.9                                            +dfsg/apache2-build/ -D_FORTIFY_SOURCE=2 -D_REENTRANT -I/usr/include -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format                                            -security -O2 -Wall -fsigned-char -fno-strict-aliasing -g -pthread -DZTS -c /php5-5.5.9+dfsg/ext/date/php_date.c  -fPIC -DPIC -o ext/date/.libs                                            /php_date.o
    In file included from /php5-5.5.9+dfsg/main/php.h:39:0,
                     from /php5-5.5.9+dfsg/ext/date/php_date.c:21:
    /php5-5.5.9+dfsg/ext/date/php_date.c: In function 'php_date_do_return_parsed_time':
    /php5-5.5.9+dfsg/ext/date/php_date.c:2992:71: error: 'TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH' undeclared (first use in this function)
        add_assoc_bool(element, parsed_time->relative.first_last_day_of == TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH ? "first_day_of_month" : "last_day_of                                            _month", 1);
                                                                           ^
    /php5-5.5.9+dfsg/Zend/zend_API.h:387:68: note: in definition of macro 'add_assoc_bool'
     #define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key)+1, __b)
                                                                        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:2992:71: note: each undeclared identifier is reported only once for each function it appears in
        add_assoc_bool(element, parsed_time->relative.first_last_day_of == TIMELIB_SPECIAL_FIRST_DAY_OF_MONTH ? "first_day_of_month" : "last_day_of                                            _month", 1);
                                                                           ^
    /php5-5.5.9+dfsg/Zend/zend_API.h:387:68: note: in definition of macro 'add_assoc_bool'
     #define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key)+1, __b)
                                                                        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c: In function 'php_date_timezone_set':
    /php5-5.5.9+dfsg/ext/date/php_date.c:3320:4: warning: implicit declaration of function 'timelib_set_timezone_from_offset' [-Wimplicit-function-                                            declaration]
        timelib_set_timezone_from_offset(dateobj->time, tzobj->tzi.utc_offset);
        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3323:4: warning: implicit declaration of function 'timelib_set_timezone_from_abbr' [-Wimplicit-function-de                                            claration]
        timelib_set_timezone_from_abbr(dateobj->time, tzobj->tzi.z);
        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c: In function 'timezone_initialize':
    /php5-5.5.9+dfsg/ext/date/php_date.c:3659:2: warning: implicit declaration of function 'timelib_parse_zone' [-Wimplicit-function-declaration]
      dummy_t->z = timelib_parse_zone(&tz, &dst, dummy_t, &not_found, DATE_TIMEZONEDB, php_date_parse_tzfile_wrapper);
      ^
    /php5-5.5.9+dfsg/ext/date/php_date.c: In function 'zif_timezone_transitions_get':
    /php5-5.5.9+dfsg/ext/date/php_date.c:3912:20: error: 'timelib_tzinfo' has no member named 'bit32'
       if (tzobj->tzi.tz->bit32.timecnt > 0) {
                        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3924:34: error: 'timelib_tzinfo' has no member named 'bit32'
        } while (begin < tzobj->tzi.tz->bit32.timecnt);
                                      ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3929:20: error: 'timelib_tzinfo' has no member named 'bit32'
       if (tzobj->tzi.tz->bit32.timecnt > 0) {
                        ^
    In file included from /php5-5.5.9+dfsg/main/php.h:39:0,
                     from /php5-5.5.9+dfsg/ext/date/php_date.c:21:
    /php5-5.5.9+dfsg/ext/date/php_date.c:3901:37: error: 'timelib_tzinfo' has no member named 'bit32'
     #define add_last() add(tzobj->tzi.tz->bit32.timecnt - 1, timestamp_begin)
                                         ^
    /php5-5.5.9+dfsg/Zend/zend_API.h:385:92: note: in definition of macro 'add_assoc_long'
     #define add_assoc_long(__arg, __key, __n) add_assoc_long_ex(__arg, __key, strlen(__key)+1, __n)
                                                                                                ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3901:20: note: in expansion of macro 'add'
     #define add_last() add(tzobj->tzi.tz->bit32.timecnt - 1, timestamp_begin)
                        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3930:4: note: in expansion of macro 'add_last'
        add_last();
        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3901:37: error: 'timelib_tzinfo' has no member named 'bit32'
     #define add_last() add(tzobj->tzi.tz->bit32.timecnt - 1, timestamp_begin)
                                         ^
    /php5-5.5.9+dfsg/Zend/zend_API.h:387:92: note: in definition of macro 'add_assoc_bool'
     #define add_assoc_bool(__arg, __key, __b) add_assoc_bool_ex(__arg, __key, strlen(__key)+1, __b)
                                                                                                ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3901:20: note: in expansion of macro 'add'
     #define add_last() add(tzobj->tzi.tz->bit32.timecnt - 1, timestamp_begin)
                        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3930:4: note: in expansion of macro 'add_last'
        add_last();
        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3901:37: error: 'timelib_tzinfo' has no member named 'bit32'
     #define add_last() add(tzobj->tzi.tz->bit32.timecnt - 1, timestamp_begin)
                                         ^
    /php5-5.5.9+dfsg/Zend/zend_API.h:390:111: note: in definition of macro 'add_assoc_string'
     #define add_assoc_string(__arg, __key, __str, __duplicate) add_assoc_string_ex(__arg, __key, strlen(__key)+1, __str, __duplicate)
                                                                                                                   ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3901:20: note: in expansion of macro 'add'
     #define add_last() add(tzobj->tzi.tz->bit32.timecnt - 1, timestamp_begin)
                        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3930:4: note: in expansion of macro 'add_last'
        add_last();
        ^
    /php5-5.5.9+dfsg/ext/date/php_date.c:3935:36: error: 'timelib_tzinfo' has no member named 'bit32'
       for (i = begin; i < tzobj->tzi.tz->bit32.timecnt; ++i) {
                                        ^
    make[1]: *** [ext/date/php_date.lo] Error 1
    make[1]: Leaving directory `/php5-5.5.9+dfsg/apache2-build'
    make: *** [build-apache2-stamp] Error 2
    dpkg-buildpackage: error: debian/rules build gave error exit status 2
    debuild: fatal error at line 1364:
    dpkg-buildpackage -rfakeroot -D -us -uc failed

我在全新的 EC2 实例上尝试过不止一次,但始终遇到同样的问题。
我显然做错了什么,但我不知道它是什么。有人知道问题出在哪里吗?

我解决了这个问题

sudo dpkg-reconfigure tzdata

您需要选择当地时区并重试所有时区。

抱歉回复晚了。为了任何人在搜索中找到这个 - 我最终转而启动了一个 CentOS 实例,并且 PHP 构建第一次工作。

好的,所以我花了一整天的时间试图解决这个确切的问题,但无法在任何地方找到有效的解决方案。更改 OS 对我来说有点过于激进,所以我改用了 this route。它将允许您对某些脚本使用可选的 php5-zts。我还跳过了与 mongo 相关的所有步骤,所以我不能说它们是否有效。但是,自 2016 年 2 月 19 日起,本指南应进行多项重要调整,否则将无法使用。
1) pthreads 的当前主分支针对 php7,而不是

git clone https://github.com/krakjoe/pthreads.git

运行

git clone https://github.com/krakjoe/pthreads.git --branch PHP5 --single-branch

否则您的构建尝试将失败。

2) 第一次 运行 make 命令可能会失败,因为源目录中没有 "makefile"。老实说,我不知道应该使用哪个,所以我不得不猜测它是 "Makefile.global":

cd /usr/local/src/php-5.6.12
./buildconf --force
make -f Makefile.global clean

所有后续的 make 调用都会记住该 makefile,因此您不必再次指定它。

3) 最后作者弄乱了 ln 语法,参数的顺序应该颠倒过来:

ln -s /usr/local/src/php-5.6.12/sapi/cli/php /usr/bin/php5-zts

除此之外,这是一位很棒的指南,它拯救了我的一天。

PS: Date extension 中似乎潜伏着一些错误,因为当我 [=42] =] 脚本与 pthreads,并且相同的扩展是在原始 post.

中给出致命错误的那个