За последние 24 часа нас посетили 20690 программистов и 916 роботов. Сейчас ищут 602 программиста ...

После обновления php 5.4.45 на версию 5.6.36_1 не собирается php-templates и не работает один сайт

Тема в разделе "Установка PHP", создана пользователем tomb2002, 2 июл 2018.

  1. tomb2002

    tomb2002 Новичок

    С нами с:
    2 июл 2018
    Сообщения:
    3
    Симпатии:
    1
    Есть выделенный сервер с сайтами в интернете с установленным Debian 3.2.63-2+deb7u2 x86_64 и nginx 1.2.1 в качестве frontend и Apache/2.2.22 в качестве backend.
    Обновлял сервер и php этими командами:

    apt-get update
    apt-get dist-upgrade
    echo "deb http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list
    echo "deb-src http://packages.dotdeb.org wheezy-php56 all" >> /etc/apt/sources.list.d/dotdeb.list
    wget http://www.dotdeb.org/dotdeb.gpg -O- | apt-key add -
    apt-get update
    apt-cache search php5
    apt-get install php5-fpm

    После обновления пришлось исправить кодировку по умолчанию в настройках /etc/php5/apache2/php.ini
    default_charset = "Windows-1251"
    так как у нескольких сайтов вылезли кракозябры на всех страницах.
    После обновления php с версии 5.4.45 на версию 5.6.36_1 обратили внимание что один из сайтов при открытии главной страницы показывает белый пустой экран. Стал разбиратся и заметил что в файле /etc/php5/apache2/php.ini в разделе Dynamic extensions было указано extension = templates.so
    И после перезагрузки сервисов nginx apache2 php5-fpm стал на почту получать от сервера письма с периодичностью одно письмо в 30 минут.
    PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/
    templates.so' - /usr/lib/php5/20131226/templates.so: cannot open shared object file: No such file or directory in Unknown on line 0
    После выяснения что за дополнение пробует подгрузить php оказалось что это дополнение было скомпилировано к версии php 5.4.45 В директории /usr/lib/php5/20100525/ на сервере нашёл файл которому уже было где-то лет 5 templates.so я скопировал его в папку /usr/lib/php5/20131226/ но начал получать уже другие сообщения от сервера себе на почту
    PHP Warning: PHP Startup: templates: Unable to initialize module
    Module compiled with module API=20100525
    PHP compiled with module API=20131226
    These options need to match
    Стало понятно что мне придётся найти в интернете исходники php-templates и скомпилировать их под свою версию php. Последняя актуальная версия templates была 1.7.2 на сайте https://github.com/rusoft/php-templates
    Но при попытке скомпилировать командами предложенными в файле INSTALL :

    tar -zxf templates.tar.gz
    cd temlpates
    phpize
    ./configure --enable-templates=shared
    make

    Выполняя команду phpize получаю следующее:
    Код (Text):
    1. Configuring for:
    2. PHP Api Version:         20131106
    3. Zend Module Api No:      20131226
    4. Zend Extension Api No:   220131226
    команда ./configure --enable-templates=shared выполняется без ошибок
    Код (Text):
    1. checking for grep that handles long lines and -e... /bin/grep
    2. checking for egrep... /bin/grep -E
    3. checking for a sed that does not truncate output... /bin/sed
    4. checking for cc... cc
    5. checking whether the C compiler works... yes
    6. checking for C compiler default output file name... a.out
    7. checking for suffix of executables...
    8. checking whether we are cross compiling... no
    9. checking for suffix of object files... o
    10. checking whether we are using the GNU C compiler... yes
    11. checking whether cc accepts -g... yes
    12. checking for cc option to accept ISO C89... none needed
    13. checking how to run the C preprocessor... cc -E
    14. checking for icc... no
    15. checking for suncc... no
    16. .....................
    17. checking if cc supports -fno-rtti -fno-exceptions... no
    18. checking for cc option to produce PIC... -fPIC -DPIC
    19. checking if cc PIC flag -fPIC -DPIC works... yes
    20. checking if cc static flag -static works... yes
    21. checking if cc supports -c -o file.o... yes
    22. checking if cc supports -c -o file.o... (cached) yes
    23. checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
    24. checking whether -lc should be explicitly linked in... no
    25. checking dynamic linker characteristics... GNU/Linux ld.so
    26. checking how to hardcode library paths into programs... immediate
    27. checking whether stripping libraries is possible... yes
    28. checking if libtool supports shared libraries... yes
    29. checking whether to build shared libraries... yes
    30. checking whether to build static libraries... no
    31. configure: creating ./config.status
    32. config.status: creating config.h
    33. config.status: executing libtool commands
    после запуска команды make получаю много сообщений об ошибках и сборка прерывается:
    Код (Text):
    1.  
    2. /bin/bash /tmp/templates/libtool --mode=compile cc  -I. -I/tmp/templates -DPHP_ATOM_INC -I/tmp/templates/include -I/tmp/templates/main -I/tmp/templates -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2  -c /tmp/templates/templates.c -o templates.lo
    3. libtool: compile:  cc -I. -I/tmp/templates -DPHP_ATOM_INC -I/tmp/templates/include -I/tmp/templates/main -I/tmp/templates -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/templates/templates.c  -fPIC -DPIC -o .libs/templates.o
    4. /tmp/templates/templates.c:51:1: error: unknown type name 'function_entry'
    5. /tmp/templates/templates.c:52:2: warning: braces around scalar initializer [enabled by default]
    6. /tmp/templates/templates.c:52:2: warning: (near initialization for 'templates_functions[0]') [enabled by default]
    7. /tmp/templates/templates.c:52:2: warning: initialization makes integer from pointer without a cast [enabled by default]
    8. /tmp/templates/templates.c:52:2: warning: (near initialization for 'templates_functions[0]') [enabled by default]
    9. /tmp/templates/templates.c:52:2: error: initializer element is not computable at load time
    10. /tmp/templates/templates.c:52:2: error: (near initialization for 'templates_functions[0]')
    11. /tmp/templates/templates.c:52:2: warning: excess elements in scalar initializer [enabled by default]
    12. /tmp/templates/templates.c:52:2: warning: (near initialization for 'templates_functions[0]') [enabled by default]
    13. /tmp/templates/templates.c:52:2: warning: excess elements in scalar initializer [enabled by default]
    14. /tmp/templates/templates.c:52:2: warning: (near initialization for 'templates_functions[0]') [enabled by default]
    15. /tmp/templates/templates.c:52:2: warning: excess elements in scalar initializer [enabled by default]
    16. /tmp/templates/templates.c:52:2: warning: (near initialization for 'templates_functions[0]') [enabled by default]
    17. /tmp/templates/templates.c:52:2: warning: excess elements in scalar initializer [enabled by default]
    18. /tmp/templates/templates.c:52:2: warning: (near initialization for 'templates_functions[0]') [enabled by default]
    19. /tmp/templates/templates.c:53:2: warning: braces around scalar initializer [enabled by default]
    20. /tmp/templates/templates.c:53:2: warning: (near initialization for 'templates_functions[1]') [enabled by default]
    21. /tmp/templates/templates.c:53:2: warning: initialization makes integer from pointer without a cast [enabled by default]
    22. ...............................
    23. /tmp/templates/templates.c:726:3: warning: 'zend_get_parameters_ex' is deprecated (declared at /usr/include/php5/Zend/zend_API.h:241) [-Wdeprecated-declarations]
    24. /tmp/templates/templates.c:728:3: warning: 'zend_get_parameters_ex' is deprecated (declared at /usr/include/php5/Zend/zend_API.h:241) [-Wdeprecated-declarations]
    25. /tmp/templates/templates.c:730:3: warning: 'zend_get_parameters_ex' is deprecated (declared at /usr/include/php5/Zend/zend_API.h:241) [-Wdeprecated-declarations]
    26. /tmp/templates/templates.c:732:3: warning: 'zend_get_parameters_ex' is deprecated (declared at /usr/include/php5/Zend/zend_API.h:241) [-Wdeprecated-declarations]
    27. /tmp/templates/templates.c: In function 'zif_tmpl_unset':
    28. /tmp/templates/templates.c:786:3: warning: 'zend_get_parameters_ex' is deprecated (declared at /usr/include/php5/Zend/zend_API.h:241) [-Wdeprecated-declarations]
    29. /tmp/templates/templates.c:788:3: warning: 'zend_get_parameters_ex' is deprecated (declared at /usr/include/php5/Zend/zend_API.h:241) [-Wdeprecated-declarations]
    30. make: *** [templates.lo] Помилка 1
    Пробовал компилировать templates на других серверах Debian и на всех получаю одни и те же ошибки.
    Скомпилировать templates.so удалось только на сервере FreeBSD 11.1 но и после того как я скопировал файл templates.so на сервер получил такую ошибку на свою почту от сервера:
    PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/
    templates.so' - /usr/lib/php5/20131226/templates.so: wrong ELF class: ELFCLASS32 in Unknown on line 0

    У меня вопрос как мне собрать templates.so и подсунуть моему серверу ? Может у кого-нибудь уже есть собранная templates.so и он может мне её передать.
     
  2. username

    username Новичок

    С нами с:
    6 июл 2017
    Сообщения:
    225
    Симпатии:
    17
    разработчику php об ошибке сообщили?
     
  3. tomb2002

    tomb2002 Новичок

    С нами с:
    2 июл 2018
    Сообщения:
    3
    Симпатии:
    1
    Нет, ещё не сообщил.
     
  4. tomb2002

    tomb2002 Новичок

    С нами с:
    2 июл 2018
    Сообщения:
    3
    Симпатии:
    1
    Сегодня я могу описать как мне удалось решить мою проблему и вернуть сайт снова в работу. Хотя проблему я решил на пару дней раньше!
    Действительно для работы этого сайта требовался файл temlates.so в этой директории /usr/lib/php5/20131226/
    После длительных поисков решения проблемы на просторах интернета. мне удалось найти решение по сборке дополнения php-templates для версии php5.6.36_1. Сначала я нашёл на этом сайте
    https://sourceforge.net/p/php-templates/bugs/14/
    подсказку что нужно исправить в файле templates.c чтобы сборка прошла успешно

    Ubuntu Server 14.04.3 LTS
    Apache 2.4.7
    PHP 5.5.9
    command "make" say: error: unknown type name 'function_entry' in template.c
    replace "function_entry" to "zend_function_entry" and enjoy!

    Открыл файл нашёл строку
    function_entry templates_functions[] = {
    добавил в начало строки zend_
    zend_function_entry templates_functions[] = {

    и снова запустил команду make
    получил на экран другие сообщения об ошибках:
    Код (Text):
    1. root@server /tmp/templates # make
    2. /bin/bash /tmp/templates/libtool --mode=compile cc  -I. -I/tmp/templates -DPHP_ATOM_INC -I/tmp/templates/include -I/tmp/templates/main -I/tmp/templates -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/templates/tmpl_lib.c -o tmpl_lib.lo
    3. libtool: compile:  cc -I. -I/tmp/templates -DPHP_ATOM_INC -I/tmp/templates/include -I/tmp/templates/main -I/tmp/templates -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/templates/tmpl_lib.c  -fPIC -DPIC -o .libs/tmpl_lib.o
    4. /tmp/templates/tmpl_lib.c: In function 'php_tmpl_pre_parse':
    5. /tmp/templates/tmpl_lib.c:217:21: error: lvalue required as left operand of assignment
    6. /tmp/templates/tmpl_lib.c: In function 'php_tmpl_set':
    7. /tmp/templates/tmpl_lib.c:446:32: warning: comparison of distinct pointer types lacks a cast [enabled by default]
    8. /tmp/templates/tmpl_lib.c:447:7: warning: comparison of distinct pointer types lacks a cast [enabled by default]
    9. /tmp/templates/tmpl_lib.c: In function 'php_tmpl_parse':
    10. /tmp/templates/tmpl_lib.c:700:20: error: lvalue required as left operand of assignment
    11. /tmp/templates/tmpl_lib.c: In function 'php_tmpl_load_structure':
    12. /tmp/templates/tmpl_lib.c:880:19: error: lvalue required as left operand of assignment
    13. make: *** [tmpl_lib.lo] Помилка 1
    Вывод строк сборки значительно уменьшился.
    После этого пришлось снова поискать в интернете что делать с ошибками в файле tmpl_lib.c
    Нашёл ещё одну страницу где предлагалось внести исправления в строки на которых спотыкался сборщик.
    https://blog.himic.ru/2011/01/26/74.html
    Читайте 1 коментарий saint-technik к статье HiMiC "Установка модуля PHP templates.so на Debian Lenny x86".
    Открыв файл я нашёл строки на которых спотыкался сборщик и внёс необходимые исправления.
    У меня это были строки 217, 446, 447, 700, 880.
    Предлагалось заменить в строках 217, 446, 447, 700 и 880 заменить функцию ZV() на Z_STRVAL_P().
    строка 217 оригинал:
    Код (Text):
    1.  
    2. ZV(tmpl->original) = (char*)erealloc(ZV(tmpl->original),
    3. Z_STRVAL_P(tmpl->original) = (char*)erealloc(Z_STRVAL_P(tmpl->original),
    строка 217 исправлена:
    строка 446 оригинал:
    Код (Text):
    1.  
    2. for(p = ZV(path)+ZL(path); p >= ZV(path) && *p != '/'; p--);
    3. for(p = Z_STRVAL_P(path)+ZL(path); p >= Z_STRVAL_P(path) && *p != '/'; p--);
    строка 446 исправлена:
    строка 447 оригинал:
    Код (Text):
    1.  
    2. *(p > ZV(path) ? p++ : ++p) = 0;
    3. *(p > Z_STRVAL_P(path) ? p++ : ++p) = 0;
    строка 447 исправлена:
    строка 700 оригинал:
    Код (Text):
    1.  
    2. ZV(new_path) = (char*)erealloc(ZV(new_path), buf_alloc);
    3. Z_STRVAL_P(new_path) = (char*)erealloc(Z_STRVAL_P(new_path), buf_alloc);
    строка 700 исправлена:
    строка 880 оригинал:
    Код (Text):
    1.  
    2. ZV(new_value) = (char*)erealloc(ZV(new_value), ZL(new_value)+2);
    3. Z_STRVAL_P(new_value) = (char*)erealloc(Z_STRVAL_P(new_value), ZL(new_value)+2);
    строка 880 исправлена:

    После внесения исправлений я снова запустил команду make
    Код (Text):
    1.  
    2. root@server /tmp/templates # make
    3. /bin/bash /tmp/templates/libtool --mode=compile cc  -I. -I/tmp/templates -DPHP_ATOM_INC -I/tmp/templates/include -I/tmp/templates/main -I/tmp/templates -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/templates/tmpl_lib.c -o tmpl_lib.lo
    4. libtool: compile:  cc -I. -I/tmp/templates -DPHP_ATOM_INC -I/tmp/templates/include -I/tmp/templates/main -I/tmp/templates -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/templates/tmpl_lib.c  -fPIC -DPIC -o .libs/tmpl_lib.o
    5. /bin/bash /tmp/templates/libtool --mode=compile cc  -I. -I/tmp/templates -DPHP_ATOM_INC -I/tmp/templates/include -I/tmp/templates/main -I/tmp/templates -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /tmp/templates/search.c -o search.lo
    6. libtool: compile:  cc -I. -I/tmp/templates -DPHP_ATOM_INC -I/tmp/templates/include -I/tmp/templates/main -I/tmp/templates -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /tmp/templates/search.c  -fPIC -DPIC -o .libs/search.o
    7. /bin/bash /tmp/templates/libtool --mode=link cc -DPHP_ATOM_INC -I/tmp/templates/include -I/tmp/templates/main -I/tmp/templates -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -o templates.la -export-dynamic -avoid-version -prefer-pic -module -rpath /tmp/templates/modules  templates.lo tmpl_lib.lo search.lo
    8. libtool: link: cc -shared  -fPIC -DPIC  .libs/templates.o .libs/tmpl_lib.o .libs/search.o    -O2   -Wl,-soname -Wl,templates.so -o .libs/templates.so
    9. libtool: link: ( cd ".libs" && rm -f "templates.la" && ln -s "../templates.la" "templates.la" )
    10. /bin/bash /tmp/templates/libtool --mode=install cp ./templates.la /tmp/templates/modules
    11. libtool: install: cp ./.libs/templates.so /tmp/templates/modules/templates.so
    12. libtool: install: cp ./.libs/templates.lai /tmp/templates/modules/templates.la
    13. libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin" ldconfig -n /tmp/templates/modules
    14. ----------------------------------------------------------------------
    15. Libraries have been installed in:
    16.    /tmp/templates/modules
    17.  
    18. If you ever happen to want to link against installed libraries
    19. in a given directory, LIBDIR, you must either use libtool, and
    20. specify the full pathname of the library, or use the `-LLIBDIR'
    21. flag during linking and do at least one of the following:
    22.    - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
    23.      during execution
    24.    - add LIBDIR to the `LD_RUN_PATH' environment variable
    25.      during linking
    26.    - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
    27.    - have your system administrator add LIBDIR to `/etc/ld.so.conf'
    28.  
    29. See any operating system documentation about shared libraries for
    30. more information, such as the ld(1) and ld.so(8) manual pages.
    31. ----------------------------------------------------------------------
    32.  
    33. Build complete.
    34. Don't forget to run 'make test'.
    Сборка прошла до конца!
    Привожу листинг команды make test

    Код (Text):
    1. root@server /tmp/templates # make test
    2.  
    3. Build complete.
    4. Don't forget to run 'make test'.
    5.  
    6.  
    7. =====================================================================
    8. PHP         : /usr/bin/php
    9. PHP_SAPI    : cli
    10. PHP_VERSION : 5.6.36-1~dotdeb+7.1
    11. ZEND_VERSION: 2.6.0
    12. PHP_OS      : Linux - Linux server 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u2 x86_64
    13. INI actual  : /tmp/templates/tmp-php.ini
    14. More .INIs  :
    15. CWD         : /tmp/templates
    16. Extra dirs  :
    17. VALGRIND    : Not used
    18. =====================================================================
    19. TIME START 2018-07-04 15:20:39
    20. =====================================================================
    21. PASS Check for templates presence [tests/001.phpt]
    22. =====================================================================
    23. TIME END 2018-07-04 15:20:39
    24.  
    25. =====================================================================
    26. TEST RESULT SUMMARY
    27. ---------------------------------------------------------------------
    28. Exts skipped    :    0
    29. Exts tested     :   44
    30. ---------------------------------------------------------------------
    31.  
    32. Number of tests :    1                 1
    33. Tests skipped   :    0 (  0.0%) --------
    34. Tests warned    :    0 (  0.0%) (  0.0%)
    35. Tests failed    :    0 (  0.0%) (  0.0%)
    36. Expected fail   :    0 (  0.0%) (  0.0%)
    37. Tests passed    :    1 (100.0%) (100.0%)
    38. ---------------------------------------------------------------------
    39. Time taken      :    0 seconds
    40. =====================================================================
    41.  
    42. This report can be automatically sent to the PHP QA team at
    43. http://qa.php.net/reports and http://news.php.net/php.qa.reports
    44. This gives us a better understanding of PHP's behavior.
    45. If you don't want to send the report immediately you can choose
    46. option "s" to save it.  You can then email it to qa-reports@lists.php.net later.
    47. Do you want to send this report now? [Yns]: n
    После успешно выполненой команды make можно скопировать файл templates.so из директории modules в директорию с дополнениями php /usr/lib/php5/20131226/
    Рестартовал сервисы
    service php5-fpm restart
    service nginx restart
    service apache2 restart
    и сайт снова стал открыватся.
    Выкладываю в тему архив с исправлениями и готовым файлом templates.so для Debian 64-bit и php5.6.35_1
     

    Вложения:

    • templates.zip
      Размер файла:
      888,7 КБ
      Просмотров:
      4
    acho нравится это.
  5. acho

    acho Активный пользователь

    С нами с:
    28 дек 2016
    Сообщения:
    854
    Симпатии:
    210
    Адрес:
    Санкт-Петербург
    красавец