PDO Informix ODBC驱动程序可与PHP CLI配合使用,但不适用于浏览器

时间:2013-11-22 15:24:58

标签: php linux pdo odbc informix

我只是尝试使用Informix驱动程序创建与数据库的连接。

服务器在CentOS 6.4上运行,PDO_INFORMIX-1.3.1和clientsdk.4.10.FC2DE.LINUX。

我在/ etc / sysconfig / httpd中设置了env var,然后运行以下命令:

  • chcon -t lib_t / opt / informix / lib / cli / *。so
  • chcon -t lib_t / opt / informix / lib / *。so
  • chcon -t lib_t / opt / informix / lib / esql / *。so
  • chcon -t lib_t /opt/informix/lib/c++/*.so
  • chcon -t lib_t / opt / informix / lib / dim / *。so
  • chcon -t lib_t / opt / informix / lib / client / cms / *。so
  • chcon -t lib_t /opt/informix/OAT/Apache_2.4.2/modules / *。so
  • chcon -t lib_t /opt/informix/OAT/PHP_5.4.4 / *。so
  • chcon -t lib_t /opt/informix/OAT/PHP_5.4.4/lib/php/extensions / *。so
  • / sbin目录/ LDCONFIG
  • setenforce 0

当我运行“php /var/www/html/informix.php”时,连接成功,但是当我在浏览器上调用相同的脚本时,我收到此错误:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE=08004, SQLDriverConnect: -908 [Informix][Informix ODBC Driver][Informix]Attempt to connect to database server (cms_net) failed.' in /var/www/html/informix.php:30 Stack trace: #0 /var/www/html/informix.php(30): PDO->__construct('informix:host=1...', 'user', 'xxxxx') #1 {main} thrown in /var/www/html/informix.php on line 30

我尝试在/ etc / hosts中设置主机,但没有成功。

我不知道如何解决这个问题。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:1)

我解决了这个问题。实际上,SELinux就是原因。我只是做

setsebool -P httpd_can_network_connect=1