如何使 informix pdo 工作,即使在 debian 机器和 docker 上 make test 失败

how to make informix pdo work even though make test fails on debian machine and docker

我尝试在本地和 docker 上使用 PDO 安装 Informix,每种方式都会导致相同的失败测试。

我不确定 'just' 测试是否失败,因为需要一些配置才能使它们 运行,而如果我开始处理这些,客户端/pdo 会工作正常。

更新:
事实证明,即使 make test 全部失败,PDO 仍然有效。 意思是下面的 Dockerfile 可以启动 PHP-8.0 Informix 4.50 PDO_INFORMIX 1.3.6 容器(您需要先下载 IBM Informix CSDK and the PDO

Dockerfile

FROM php:8.0.17-fpm-buster

# Provide Files
ADD ./PDO_INFORMIX-1.3.6.tgz /informix-pdo
ADD ./ibm.csdk.4.50.FC7.LNX.tar /informix-sdk

# Prepare Install SDK
ENV INFORMIXDIR=/opt/IBM/Informix_Client-SDK
RUN apt update && apt -y install rpm && mkdir -p /var/lib/rpm && rpm --initdb
RUN apt -y install libncurses5

# Install SDK
RUN cd /informix-sdk && \
    ./installclientsdk -i silent -DLICENSE_ACCEPTED=TRUE -DUSE_OPENSSL_CONSOLE="Use GSKit" -DUSER_INSTALL_DIR=/opt/IBM/Informix_Client-SDK -DCHOSEN_FEATURE_LIST=SDK,SDK-CPP,SDK-CPP-DEMO,SDK-ESQL,SDK-ESQL-DEMO,SDK-ESQL-ACM,SDK-LMI,SDK-ODBC,SDK-ODBC-DEMO,DBA-DBA,SDK-NETCORE,GLS,GLS-WEURAM,GLS-EEUR,GLS-JPN,GLS-KOR,GLS-CHN,GLS-OTH -DCHOSEN_INSTALL_FEATURE_LIST=SDK,SDK-CPP,SDK-CPP-DEMO,SDK-ESQL,SDK-ESQL-DEMO,SDK-ESQL-ACM,SDK-LMI,SDK-ODBC,SDK-ODBC-DEMO,DBA-DBA,SDK-NETCORE,GLS,GLS-WEURAM,GLS-EEUR,GLS-JPN,GLS-KOR,GLS-CHN,GLS-OTH -DCHOSEN_INSTALL_SET=Custom

# Install PDO, add extension to php, 
RUN cd /informix-pdo/PDO_INFORMIX-1.3.6/ && \
    phpize && \
    ./configure --with-pdo-informix=/opt/IBM/Informix_Client-SDK && \
    make && \
    make install && \
    echo "extension=pdo_informix" > /usr/local/etc/php/conf.d/docker-php-ext-informix.ini && \
    kill -USR2 1 && \ 
    make test

CMD ["tail", "-f", "/dev/null"]

:
我在 make test 之前添加了 pdo_informix extensionrestart php,因为我需要启用扩展。如果不这样做,make test.

没有区别

测试结果

root@555b0fd88bc6:/informix-pdo/PDO_INFORMIX-1.3.6# make test
/bin/bash /informix-pdo/PDO_INFORMIX-1.3.6/libtool --mode=install cp ./pdo_informix.la /informix-pdo/PDO_INFORMIX-1.3.6/modules
cp ./.libs/pdo_informix.so /informix-pdo/PDO_INFORMIX-1.3.6/modules/pdo_informix.so
cp ./.libs/pdo_informix.lai /informix-pdo/PDO_INFORMIX-1.3.6/modules/pdo_informix.la
PATH="$PATH:/sbin" ldconfig -n /informix-pdo/PDO_INFORMIX-1.3.6/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /informix-pdo/PDO_INFORMIX-1.3.6/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.


=====================================================================
PHP         : /usr/local/bin/php
PHP_SAPI    : cli
PHP_VERSION : 8.0.17
ZEND_VERSION: 4.0.17
PHP_OS      : Linux - Linux 555b0fd88bc6 4.9.0-18-amd64 #1 SMP Debian 4.9.303-1 (2022-03-07) x86_64
INI actual  : /informix-pdo/PDO_INFORMIX-1.3.6/tmp-php.ini
More .INIs  :
CWD         : /informix-pdo/PDO_INFORMIX-1.3.6
Extra dirs  :
VALGRIND    : Not used
=====================================================================

All tests fail

有了这个docker-compose和上面问题中提到的dockerfile,就可以建立一个可行的解决方案。
确保数据库的 tmp 文件夹存在并且可以写入

mkdir -p /tmp/ibm-storage/extvol
chmod 777 /tmp/ibm-storage/extvol

要推出测试数据库,请等待 docker-compose 完成,然后 运行 docker-compose exec db /opt/ibm/informix/bin/dbaccessdemo

version: '3.8'

services: 
  app:
    build: 
      context: ./app 
      dockerfile: Dockerfile-php8
    volumes:
      - ./:/opt/scripts
    environment: 
      - INFORMIX_PASSWORD=in4mix
    
  db:
    image: ibmcom/informix-developer-database:latest 
    environment: 
      - INFORMIX_PASSWORD=in4mix
      - LICENSE=accept
      - DBSERVERNAME=db
      - INFORMIXSERVER=db
    volumes:
      - /tmp/ibm-storage/extvol:/opt/ibm/data
    ports: 
      - 9088:9088
      - 9089:9089
      - 27017:27017
      - 27018:27018 
      - 27883:27883
    
# Custom network
networks:
  default:
    name: my-net