简体   繁体   English

从IBM Cloud外部将php服务器连接到DB2

[英]Connecting php server to DB2 from outside IBM Cloud

I am following the process as described here: https://www.ibm.com/support/knowledgecenter/en/SSHRBY/com.ibm.swg.im.dashdb.doc/connecting/connect_connecting_php.html 我正在按照此处描述的过程进行操作: https : //www.ibm.com/support/knowledgecenter/zh-CN/SSHRBY/com.ibm.swg.im.dashdb.doc/connecting/connect_connecting_php.html

I have completed the instalation and I have even run the validation command in shell 我已经完成安装,甚至在shell中运行了验证命令

db2cli validate -dsn DashDB -connect -user bluadmin -passwd 'your_secret_password' db2cli validate -dsn DashDB -connect -user bluadmin -passwd'your_secret_password'

see output below 见下面的输出

But still my www page crashes on the line 但是我的www页面仍然崩溃了

$conn = odbc_connect( $conn_string, "", "" );

becasue it does not recognize the odbc_connect function. 因为它无法识别odbc_connect函数。

Any feedback and hopefully help is very welcome. 任何反馈和希望的帮助都非常欢迎。

在此处输入图片说明

Your question is not about programming, but instead it is about configuration. 您的问题与编程无关,而与配置有关。

It is best if you detail your php version and your linux distro details fully every time you ask for help. 最好是每次您寻求帮助时都详细说明您的php版本和Linux发行版详细信息。

You already successfully configured db2dsdriver.cfg and successfully validated a CLI connection to the remote Db2 database. 您已经成功配置了db2dsdriver.cfg并成功验证了到远程Db2数据库的CLI连接。 That is essential. 那是必不可少的。

The next step is to ensure that both ODBC and PHP are configured appropriately. 下一步是确保正确配置ODBC和PHP。

It may help to verify all the following items: 验证以下所有项目可能会有所帮助:

  • Verify php-odbc is installed to match your version of php . 确认已安装php-odbc来匹配您的php版本。 Use the package-manager (eg yum or apt etc.) for your linux distro to install it, there's plenty of pages to help you with that. 在Linux发行版中使用软件包管理器(例如yum或apt等)进行安装,有很多页面可以帮助您。

  • Verify the php.ini has enabled: extension=odbc.so ( for Linux it seems this is not default with php7). 验证php.ini是否已启用:extension = odbc.so(对于Linux,似乎这不是php7的默认设置)。

  • Verify that the command-line php -m shows that odbc is loaded 验证命令行php -m显示odbc已加载

  • If you configured a unixODBC DSN then verify you can successfully connect to the DSN with isql command on linux (to verify that your odbc.ini and odbcinst.ini are properly configured with the Db2 driver and the DSN details). 如果您配置了unixODBC DSN,则请验证您是否可以在Linux上使用isql命令成功连接到DSN(验证odbc.iniodbcinst.ini是否已使用Db2驱动程序和DSN详细信息正确配置)。 Use odbcinst -j to show the path to odbc.ini and odbcinst.ini for your distro. 使用odbcinst -j为您的发行版显示odbc.iniodbcinst.ini的路径。 There's plenty of pages to show how to configure those files, and how to run the isql command line. 有很多页面显示如何配置这些文件以及如何运行isql命令行。 Usage of a DSN is optional, but it can help with sanity checking and centralises the connection strings instead of having them replicated in php scripts. DSN的使用是可选的,但它可以帮助进行完整性检查和集中连接字符串,而不是将其复制到php脚本中。

  • verify the ibm_db2 driver is loaded and pdo_ibm (if using PDO interfaces) with the php -m command line. 验证是否已加载ibm_db2驱动程序,并使用php -m命令行验证pdo_ibm(如果使用PDO接口)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM