【问题标题】:Compile PHP with ZTS support on ubuntu 14.04在 ubuntu 14.04 上编译带有 ZTS 支持的 PHP
【发布时间】:2015-07-12 03:43:18
【问题描述】:

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

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

但是,我就是无法正常工作。

如果我编译源代码而不做任何更改,它编译得很好。只要我执行以下步骤 -

找到以 COMMON_CONFIG=--build=$(DEB_BUILD_GNU_TYPE) \ 并添加以下内容 配置标志:

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

然后我们想增加包的版本号,这样它就是 高于存储库中的 PHP 版本。运行 dch -i 和 创建一个新的变更日志条目:

php5 (5.5.9+dfsg-1ubuntu4.5+zts1) 值得信赖;紧急=中等

  • 在 ZTS 支持下重建。

    -- 你周一,2014 年 11 月 10 日 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 实例上尝试过,并且一直遇到同样的问题。
我显然做错了什么,但我不知道它是什么。有谁知道问题可能是什么?

【问题讨论】:

  • 我也有同样的问题。你找到解决办法了吗?
  • 我让它在 RaspberryPi 2 / Raspbian 上与 php 5.4.41 一起使用,但在使用 5.5.9 的 Ubuntu 上尝试时遇到了同样的错误。

标签: php ubuntu build


【解决方案1】:

好的,所以我花了一整天的时间试图解决这个确切的问题,但在任何地方都找不到有效的解决方案。更改操作系统对我来说有点过于激进,所以我改用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 扩展中潜伏着一些错误,因为当我使用 pthread 运行脚本时,即使在使用此方法成功构建 php 后,我仍然会收到 php 警告,并且相同的扩展是在原帖。

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

      我解决了这个问题

      sudo dpkg-reconfigure tzdata
      

      您需要选择您当地的时区,然后全部重试。

      【讨论】:

      • 抱歉,我用的是 CentOS,所以无法确认
      • 在 Ubuntu 14.04.3 LTS 上尝试过,但没有成功。仍然出现同样的错误
      猜你喜欢
      • 2015-07-21
      • 1970-01-01
      • 2016-02-01
      • 2014-06-04
      • 2018-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-02
      相关资源
      最近更新 更多