这个问题似乎被问了很多,答案似乎随着时间的推移而改变.我花了一个周末的时间让Informix的IBM Client SDK在Debian上运行(因为缺少这个过程的大多数方向,所以这需要一个周末来解决.)我现在可以使用isql连接并运行查询到远程Informix服务器- 没问题.现在我需要
PHP连接,以便我可以将输出呈现给apache.这个语法;
<?PHP try { $dbh = new PDO("informix:DSN=InformixDB","username","password"); } catch (PDOException $e) { echo $e->getMessage(); } ?>
在网页上产生“找不到驱动程序”错误(这是通用语法 – 我当然填写信息).根据我的阅读,需要安装PHP Informix PDO驱动程序,但我找不到操作方法.过去它是用PECL(?)安装的,现在不是.有人知道吗?我安装了以下PHP包;
PHP5 PHP5-dev PHP5-cli
很感谢任何形式的帮助.
这个答案是我在OpenSuse 12.3中配置和安装Informix PDO的方法
我认为它们也应该适用于Debian,除了apache set.
如果要添加一些关于Debian的详细信息,请随意编辑或添加评论.
我认为它们也应该适用于Debian,除了apache set.
如果要添加一些关于Debian的详细信息,请随意编辑或添加评论.
观察:这里没有使用ODBC ……只有纯PDO ……
所有都是用户root执行的
1)下载最新版本的PDO
$mkdir pdo $cd pdo $wget http://pecl.PHP.net/get/PDO_INFORMIX-1.3.1.tgz --2013-11-12 12:21:51-- http://pecl.PHP.net/get/PDO_INFORMIX-1.3.1.tgz Resolving pecl.PHP.net (pecl.PHP.net)... 76.75.200.106 Connecting to pecl.PHP.net (pecl.PHP.net)|76.75.200.106|:80... connected. HTTP request sent,awaiting response... 200 OK Length: 67566 (66K) [application/octet-stream] Saving to: `PDO_INFORMIX-1.3.1.tgz' 100%[=====================================================================================================================================================================================>] 67,566 --.-K/s in 0.04s 2013-11-12 12:21:52 (1.57 MB/s) - `PDO_INFORMIX-1.3.1.tgz' saved [67566/67566]
2)解压缩
$tar zxf PDO_INFORMIX-1.3.1.tgz $cd PDO_INFORMIX-1.3.1/
3)设置你的INFORMIXDIR
$export INFORMIXDIR=/myifx/csdk
3)执行PHPize
$PHPize Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 configure.in:3: warning: prefer named diversions configure.in:3: warning: prefer named diversions
3)执行./configure
$./configure configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for gcc option to accept ISO C99... -std=gnu99 checking for gcc -std=gnu99 option to accept ISO Standard C... (cached) -std=gnu99 checking how to run the C preprocessor... gcc -std=gnu99 -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking for icc... no checking for suncc... no checking whether gcc -std=gnu99 and cc understand -c and -o together... yes checking for system library directory... lib checking if compiler supports -R... no checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for PHP prefix... /usr checking for PHP includes... -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 checking for PHP extension directory... /usr/lib64/PHP5/extensions checking for PHP installed headers prefix... /usr/include/PHP5 checking if debug is enabled... no checking if zts is enabled... no checking for re2c... no configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. checking for gawk... gawk checking for Informix driver for PDO... yes,shared checking for PDO includes... configure: error: Cannot find PHP_pdo_driver.h.
哎呀..这是Opensuse的错误,不确定Debian是否也会发生…
需要在./configure中更正PHP_pdo_driver.h的路径并重新运行.
$grep PHP_pdo_driver.h configure if test -f $abs_srcdir/include/PHP/ext/pdo/PHP_pdo_driver.h; then elif test -f $abs_srcdir/ext/pdo/PHP_pdo_driver.h; then elif test -f $prefix/include/PHP/ext/pdo/PHP_pdo_driver.h; then as_fn_error $? "Cannot find PHP_pdo_driver.h." "$LINENO" 5 $locate PHP_pdo_driver.h /usr/include/PHP5/ext/pdo/PHP_pdo_driver.h $sed -ie 's,include/PHP/ext/pdo/PHP_pdo_driver.h,include/PHP5/ext/pdo/PHP_pdo_driver.h,g' configure $./configure configure: loading site script /usr/share/site/x86_64-unknown-linux-gnu checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for gcc option to accept ISO C99... -std=gnu99 checking for gcc -std=gnu99 option to accept ISO Standard C... (cached) -std=gnu99 checking how to run the C preprocessor... gcc -std=gnu99 -E checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking minix/config.h usability... no checking minix/config.h presence... no checking for minix/config.h... no checking whether it is safe to define __EXTENSIONS__... yes checking for icc... no checking for suncc... no checking whether gcc -std=gnu99 and cc understand -c and -o together... yes checking for system library directory... lib checking if compiler supports -R... no checking if compiler supports -Wl,shared checking for PDO includes... /usr/include/PHP/ext checking for includes and libraries... /myifx/informix checking Informix version... 370 checking how to print strings... printf checking for a sed that does not truncate output... (cached) /usr/bin/sed checking for fgrep... /usr/bin/grep -F checking for ld used by gcc -std=gnu99... /usr/x86_64-suse-linux/bin/ld checking if the linker (/usr/x86_64-suse-linux/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/x86_64-suse-linux/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for ar... ar checking for archiver @FILE support... @ checking for strip... strip checking for ranlib... ranlib checking for gawk... (cached) gawk checking command to parse /usr/bin/nm -B output from gcc -std=gnu99 object... ok checking for sysroot... no checking for mt... mt checking if mt is a manifest tool... no checking for dlfcn.h... yes checking for objdir... .libs checking if gcc -std=gnu99 supports -fno-rtti -fno-exceptions... no checking for gcc -std=gnu99 option to produce PIC... -fPIC -DPIC checking if gcc -std=gnu99 PIC flag -fPIC -DPIC works... yes checking if gcc -std=gnu99 static flag -static works... no checking if gcc -std=gnu99 supports -c -o file.o... yes checking if gcc -std=gnu99 supports -c -o file.o... (cached) yes checking whether the gcc -std=gnu99 linker (/usr/x86_64-suse-linux/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no configure: creating ./config.status config.status: creating config.h config.status: executing libtool commands
4)编译PDO
$make /bin/sh /root/pdo/PDO_INFORMIX-1.3.1/libtool --mode=compile gcc -std=gnu99 -I/usr/include/PHP/ext -I. -I/root/pdo/PDO_INFORMIX-1.3.1 -DPHP_ATOM_INC -I/root/pdo/PDO_INFORMIX-1.3.1/include -I/root/pdo/PDO_INFORMIX-1.3.1/main -I/root/pdo/PDO_INFORMIX-1.3.1 -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 -I/myifx/csdk/incl/cli -I/myifx/csdk/incl/esql -DHAVE_CONFIG_H -g -O2 -c /root/pdo/PDO_INFORMIX-1.3.1/pdo_informix.c -o pdo_informix.lo libtool: compile: gcc -std=gnu99 -I/usr/include/PHP/ext -I. -I/root/pdo/PDO_INFORMIX-1.3.1 -DPHP_ATOM_INC -I/root/pdo/PDO_INFORMIX-1.3.1/include -I/root/pdo/PDO_INFORMIX-1.3.1/main -I/root/pdo/PDO_INFORMIX-1.3.1 -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 -I/myifx/csdk/incl/cli -I/myifx/csdk/incl/esql -DHAVE_CONFIG_H -g -O2 -c /root/pdo/PDO_INFORMIX-1.3.1/pdo_informix.c -fPIC -DPIC -o .libs/pdo_informix.o /bin/sh /root/pdo/PDO_INFORMIX-1.3.1/libtool --mode=compile gcc -std=gnu99 -I/usr/include/PHP/ext -I. -I/root/pdo/PDO_INFORMIX-1.3.1 -DPHP_ATOM_INC -I/root/pdo/PDO_INFORMIX-1.3.1/include -I/root/pdo/PDO_INFORMIX-1.3.1/main -I/root/pdo/PDO_INFORMIX-1.3.1 -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 -I/myifx/csdk/incl/cli -I/myifx/csdk/incl/esql -DHAVE_CONFIG_H -g -O2 -c /root/pdo/PDO_INFORMIX-1.3.1/informix_driver.c -o informix_driver.lo libtool: compile: gcc -std=gnu99 -I/usr/include/PHP/ext -I. -I/root/pdo/PDO_INFORMIX-1.3.1 -DPHP_ATOM_INC -I/root/pdo/PDO_INFORMIX-1.3.1/include -I/root/pdo/PDO_INFORMIX-1.3.1/main -I/root/pdo/PDO_INFORMIX-1.3.1 -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 -I/myifx/csdk/incl/cli -I/myifx/csdk/incl/esql -DHAVE_CONFIG_H -g -O2 -c /root/pdo/PDO_INFORMIX-1.3.1/informix_driver.c -fPIC -DPIC -o .libs/informix_driver.o /root/pdo/PDO_INFORMIX-1.3.1/informix_driver.c: In function 'dbh_prepare_stmt': /root/pdo/PDO_INFORMIX-1.3.1/informix_driver.c:133:3: warning: implicit declaration of function 'stmt_cleanup' [-Wimplicit-function-declaration] /bin/sh /root/pdo/PDO_INFORMIX-1.3.1/libtool --mode=compile gcc -std=gnu99 -I/usr/include/PHP/ext -I. -I/root/pdo/PDO_INFORMIX-1.3.1 -DPHP_ATOM_INC -I/root/pdo/PDO_INFORMIX-1.3.1/include -I/root/pdo/PDO_INFORMIX-1.3.1/main -I/root/pdo/PDO_INFORMIX-1.3.1 -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 -I/myifx/csdk/incl/cli -I/myifx/csdk/incl/esql -DHAVE_CONFIG_H -g -O2 -c /root/pdo/PDO_INFORMIX-1.3.1/informix_statement.c -o informix_statement.lo libtool: compile: gcc -std=gnu99 -I/usr/include/PHP/ext -I. -I/root/pdo/PDO_INFORMIX-1.3.1 -DPHP_ATOM_INC -I/root/pdo/PDO_INFORMIX-1.3.1/include -I/root/pdo/PDO_INFORMIX-1.3.1/main -I/root/pdo/PDO_INFORMIX-1.3.1 -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 -I/myifx/csdk/incl/cli -I/myifx/csdk/incl/esql -DHAVE_CONFIG_H -g -O2 -c /root/pdo/PDO_INFORMIX-1.3.1/informix_statement.c -fPIC -DPIC -o .libs/informix_statement.o /bin/sh /root/pdo/PDO_INFORMIX-1.3.1/libtool --mode=link gcc -std=gnu99 -DPHP_ATOM_INC -I/root/pdo/PDO_INFORMIX-1.3.1/include -I/root/pdo/PDO_INFORMIX-1.3.1/main -I/root/pdo/PDO_INFORMIX-1.3.1 -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 -I/myifx/csdk/incl/cli -I/myifx/csdk/incl/esql -DHAVE_CONFIG_H -g -O2 -o pdo_informix.la -export-dynamic -avoid-version -prefer-pic -module -rpath /root/pdo/PDO_INFORMIX-1.3.1/modules pdo_informix.lo informix_driver.lo informix_statement.lo -Wl,/root/pdo/PDO_INFORMIX-1.3.1/. -L/root/pdo/PDO_INFORMIX-1.3.1/. -Wl,/myifx/csdk/lib/esql -L/myifx/csdk/lib/esql -Wl,/myifx/csdk/lib/cli -L/myifx/csdk/lib/cli -Wl,/myifx/csdk/lib -L/myifx/csdk/lib -lifcli -lifdmr -lifsql -lifasf -lifgen -lifos -lifgls -ldl -lcrypt -lifglx libtool: link: gcc -std=gnu99 -shared -fPIC -DPIC .libs/pdo_informix.o .libs/informix_driver.o .libs/informix_statement.o -L/root/pdo/PDO_INFORMIX-1.3.1/. -L/myifx/csdk/lib/esql -L/myifx/csdk/lib/cli -L/myifx/csdk/lib -lifcli -lifdmr -lifsql -lifasf -lifgen -lifos -lifgls -ldl -lcrypt -lifglx -O2 -Wl,-rpath -Wl,/root/pdo/PDO_INFORMIX-1.3.1/. -Wl,/myifx/csdk/lib/esql -Wl,/myifx/csdk/lib/cli -Wl,/myifx/csdk/lib -Wl,-soname -Wl,pdo_informix.so -o .libs/pdo_informix.so libtool: link: ( cd ".libs" && rm -f "pdo_informix.la" && ln -s "../pdo_informix.la" "pdo_informix.la" ) /bin/sh /root/pdo/PDO_INFORMIX-1.3.1/libtool --mode=install cp ./pdo_informix.la /root/pdo/PDO_INFORMIX-1.3.1/modules libtool: install: cp ./.libs/pdo_informix.so /root/pdo/PDO_INFORMIX-1.3.1/modules/pdo_informix.so libtool: install: cp ./.libs/pdo_informix.lai /root/pdo/PDO_INFORMIX-1.3.1/modules/pdo_informix.la libtool: finish: PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:~/bin:/sbin" ldconfig -n /root/pdo/PDO_INFORMIX-1.3.1/modules ---------------------------------------------------------------------- Libraries have been installed in: /root/pdo/PDO_INFORMIX-1.3.1/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,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'.
5)安装PDO
$make install Installing shared extensions: /usr/lib64/PHP5/extensions/ $ls -ltr /usr/lib64/PHP5/extensions/ | tail -rw-r--r-- 1 root root 85720 Jul 16 08:19 sqlite.so -rw-r--r-- 1 root root 49840 Jul 16 08:19 sqlite3.so -rw-r--r-- 1 root root 48048 Jul 16 08:19 sockets.so -rw-r--r-- 1 root root 35760 Jul 16 08:19 xmlreader.so -rw-r--r-- 1 root root 18928 Jul 16 08:19 tokenizer.so -rw-r--r-- 1 root root 14864 Jul 16 08:19 sysvshm.so -rw-r--r-- 1 root root 40224 Jul 16 08:19 zlib.so -rw-r--r-- 1 root root 102264 Jul 16 08:19 zip.so -rw-r--r-- 1 root root 52016 Jul 16 08:19 xmlwriter.so -rwxr-xr-x 1 root root 164722 Nov 12 12:29 pdo_informix.so
6)在PHP上激活PDO
$cd /etc/PHP5/conf.d $echo "extension=pdo_informix.so" > pdo_informix.ini
7)“激活”Apache的INFORMIX变量.
在这里,debian可能会有所不同.
$cd /etc/sysconfig/ $tail apache2 # # If mod_status is used,include extended information about the server,like # cpu usage,in the status report. It is a server-wide setting,and it can cost # some performance! # APACHE_EXTENDED_STATUS="off" INFORMIXDIR=/myifx/csdk LD_LIBRARY_PATH=/myifx/csdk/lib:/myifx/csdk/lib/esql:/myifx/csdk/lib/client:/myifx/csdk/lib/cli:$LD_LIBRARY_PATH
8)重启apache
$systemctl restart apache2.service
9)然后我可以使用这个PHP访问…
$cd /srv/www/htdocs $cat ifx.PHP <?PHP $db = new PDO("informix:host=myifx_ifxhom; service=11205; database=xyz; server=idsbkp_soc; protocol=onsoctcp; EnableScrollableCursors=1","cesar","cesar"); print "Connection Established!\n\n"; $stmt = $db->query("select * from systables"); $res = $stmt->fetch( PDO::FETCH_BOTH ); $rows = $res[0]; echo "Table contents: $rows.\n"; ?>
您可以检查apache是否使用PHP_info加载了Informix PDO:
并检查apache是否识别出Informix变量:
使用此代码:
$cat PHPinfo.PHP <?PHP // Show all information,defaults to INFO_ALL PHPinfo(); // Show just the module information. // PHPinfo(8) yields identical results. PHPinfo(INFO_MODULES); ?>