centos 6.x 上的 pdo dblib

2023-12-05

我正在尝试在 CentOS 版本 6.5(最终版)64 位上安装 dblib。 centos 6 没有 freetds,所以我必须从其他地方获取 freetds。freetds-devel-0.91-2.1.x86_64.rpm。使用 pecl 下载并安装 PDO DBLIB 但我陷入 make 困境。我收到的错误如下。

[root@rajesh PDO_DBLIB-1.0]# make
/bin/sh /root/php/PDO_DBLIB-1.0/libtool --mode=compile cc -I/usr/include/php/ext -DPDO_DBLIB_FLAVOUR=\"freetds\" -I. -I/root/php/PDO_DBLIB-1.0 -DPHP_ATOM_INC -I/root/php/PDO_DBLIB-1.0/include -I/root/php/PDO_DBLIB-1.0/main -I/root/php/PDO_DBLIB-1.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/php/PDO_DBLIB-1.0/pdo_dblib.c -o pdo_dblib.lo 
libtool: compile:  cc -I/usr/include/php/ext -DPDO_DBLIB_FLAVOUR=\"freetds\" -I. -I/root/php/PDO_DBLIB-1.0 -DPHP_ATOM_INC -I/root/php/PDO_DBLIB-1.0/include -I/root/php/PDO_DBLIB-1.0/main -I/root/php/PDO_DBLIB-1.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/php/PDO_DBLIB-1.0/pdo_dblib.c  -fPIC -DPIC -o .libs/pdo_dblib.o
In file included from /root/php/PDO_DBLIB-1.0/pdo_dblib.c:32:
/root/php/PDO_DBLIB-1.0/php_pdo_dblib_int.h:45:23: error: sybfront.h: No such file or directory
/root/php/PDO_DBLIB-1.0/php_pdo_dblib_int.h:46:20: error: sybdb.h: No such file or directory
/root/php/PDO_DBLIB-1.0/php_pdo_dblib_int.h:47:23: error: syberror.h: No such file or directory
In file included from /root/php/PDO_DBLIB-1.0/pdo_dblib.c:32:
/root/php/PDO_DBLIB-1.0/php_pdo_dblib_int.h:90: error: expected ‘)’ before ‘*’ token
/root/php/PDO_DBLIB-1.0/php_pdo_dblib_int.h:93: error: expected ‘)’ before ‘*’ token
/root/php/PDO_DBLIB-1.0/php_pdo_dblib_int.h:110: error: expected specifier-qualifier-list before ‘LOGINREC’
/root/php/PDO_DBLIB-1.0/pdo_dblib.c:76: error: expected ‘)’ before ‘*’ token
/root/php/PDO_DBLIB-1.0/pdo_dblib.c:123: error: expected ‘)’ before ‘*’ token
/root/php/PDO_DBLIB-1.0/pdo_dblib.c: In function ‘zm_startup_pdo_dblib’:
/root/php/PDO_DBLIB-1.0/pdo_dblib.c:175: error: ‘FAIL’ undeclared (first use in this function)
/root/php/PDO_DBLIB-1.0/pdo_dblib.c:175: error: (Each undeclared identifier is reported only once
/root/php/PDO_DBLIB-1.0/pdo_dblib.c:175: error: for each function it appears in.)
/root/php/PDO_DBLIB-1.0/pdo_dblib.c:195: error: ‘error_handler’ undeclared (first use in this function)
/root/php/PDO_DBLIB-1.0/pdo_dblib.c:196: error: ‘msg_handler’ undeclared (first use in this function)
make: *** [pdo_dblib.lo] Error 1


[root@rajesh php]# whereis freetds
freetds: /etc/freetds.conf /usr/include/freetds /usr/local/freetds


[root@rajesh php]# php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_dblib.so' - /usr/lib64/php/modules/pdo_dblib.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

[root@rajesh ~]# rpm -qa | grep freetds
freetds-devel-0.91-1.el6.rf.x86_64
freetds-0.91-1.el6.rf.x86_64

我曾尝试改变function_entry to zend_function_entry in pdo_dblib.c但并不像中提到的那样工作http://www.radebatz.net/mano/2013/11/05/compiling-pdo_dblib-on-centos-6-with-php-5-4/.

我也尝试过

[root@rajesh PDO_DBLIB-1.0]# ll /usr/include/freetds
total 132
-rw-r--r-- 1 root root  3054 Feb 19  2013 bkpublic.h
-rw-r--r-- 1 root root 21930 Feb 19  2013 cspublic.h
-rw-r--r-- 1 root root  4847 Feb 19  2013 cstypes.h
-rw-r--r-- 1 root root  7319 Feb 19  2013 ctpublic.h
-rw-r--r-- 1 root root   995 Feb 19  2013 odbcss.h
-rw-r--r-- 1 root root  5086 Feb 19  2013 sqldb.h
-rw-r--r-- 1 root root  1985 Feb 19  2013 sqlfront.h
-rw-r--r-- 1 root root 60728 Feb 19  2013 sybdb.h
-rw-r--r-- 1 root root  1535 Feb 19  2013 syberror.h
-rw-r--r-- 1 root root  1235 Feb 19  2013 sybfront.h
-rw-r--r-- 1 root root  2686 Feb 19  2013 tds_sysdep_public.h
[root@rajesh PDO_DBLIB-1.0]# cp /usr/include/freetds/* /usr/local/freetds/include/
cp: overwrite `/usr/local/freetds/include/bkpublic.h'? n
cp: overwrite `/usr/local/freetds/include/cspublic.h'? n
cp: overwrite `/usr/local/freetds/include/cstypes.h'? n
cp: overwrite `/usr/local/freetds/include/ctpublic.h'? n
cp: overwrite `/usr/local/freetds/include/odbcss.h'? n
cp: overwrite `/usr/local/freetds/include/sqldb.h'? n
cp: overwrite `/usr/local/freetds/include/sqlfront.h'? n
cp: overwrite `/usr/local/freetds/include/sybdb.h'? n
cp: overwrite `/usr/local/freetds/include/syberror.h'? n
cp: overwrite `/usr/local/freetds/include/sybfront.h'? n
cp: overwrite `/usr/local/freetds/include/tds_sysdep_public.h'? n

似乎它没有获取包含目录。

我已成功使用以下配置命令安装 PDO DBLIB./configure --prefix=/usr/local/freetds --with-gnu-ld --with-pdo-dblib=/usr/local/freetds。在我的网络应用程序上,我不断收到。CDbConnection failed to open the DB connection: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)

/etc/freetds.conf

[ebenezer]
        host = ebenezer.uk.domain.com
        port = 1433
        tds version = 8.0


[root@rajesh PDO_DBLIB-1.0]# tsql -C
Compile-time settings (established with the "configure" script)
                            Version: freetds v0.91
             freetds.conf directory: /etc
     MS db-lib source compatibility: yes
        Sybase binary compatibility: yes
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 4.2
                              iODBC: no
                           unixodbc: yes
              SSPI "trusted" logins: no
                           Kerberos: no


[root@rajesh PDO_DBLIB-1.0]# TDSVER=8.0 tsql -S ebenezer -U invload -P invload
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> quit

清理后我设法以某种方式回到

[root@rajesh freetds-0.91]# TDSVER=7.1 /usr/local/freetds/bin/tsql -H ebenezer -U invload -P invlaod -p 1443
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20009 (severity 9):
    Unable to connect: Adaptive Server is unavailable or does not exist
    OS error 111, "Connection refused"
There was a problem connecting to the server
[root@rajesh freetds-0.91]# /usr/bin/ts
tset   tsort  tsql   
[root@rajesh freetds-0.91]# /usr/bin/ts
tset   tsort  tsql   
[root@rajesh freetds-0.91]# /usr/bin/tsql -H ebenezer -U invload -P invlaod -p 1443
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Error 20009 (severity 9):
    Unable to connect: Adaptive Server is unavailable or does not exist
    OS error 111, "Connection refused"
There was a problem connecting to the server


tail: /tmp/freetds.log: file truncated
log.c:196:Starting log file for FreeTDS 0.91
    on 2014-01-24 20:07:55 with debug flags 0x4fff.
iconv.c:330:tds_iconv_open(0x142c3e0, UTF-8)
iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
iconv.c:187:local name for UTF-8 is UTF-8
iconv.c:187:local name for UCS-2LE is UCS-2LE
iconv.c:187:local name for UCS-2BE is UCS-2BE
iconv.c:349:setting up conversions for client charset "UTF-8"
iconv.c:351:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:391:preparing iconv for "ISO-8859-1" <-> "ISO-8859-1" conversion
iconv.c:394:tds_iconv_open: done
net.c:205:Connecting to 172.16.0.71 port 1443 (TDS version 4.2)
net.c:270:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:306:getsockopt(2) reported: Connection refused
net.c:316:tds_open_socket() failed
util.c:331:tdserror(0x142c140, 0x142c3e0, 20009, 111)
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
mem.c:615:tds_free_all_results()

实现这一目标的简单方法是:

  1. 启用 EPEL 存储库
  2. Install php-mssql。这将安装unixODBC and freetds, too.

# yum 安装 php-mssql

然后,您可以从 CentOS 从 PHP + PDO(使用 dblib 驱动程序)连接到 MSSQL 服务器

$dsn = "dblib:host=<host>;dbname=<dbname>";
$user = <user>;
$password = <password>;
$db = new PDO($dsn, $user, $password);

Dockerfile 示例,但也应该适用于任何 CentOS6+ 和 PHP 7.0:

FROM centos:centos7

RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm\
# We include PHP 7 from REMI since it's not in EPEL.
    http://rpms.remirepo.net/enterprise/remi-release-7.rpm\
# This will help verify packages and so you will see fewer errors(red) in the build output.
 && rpm --import \
      /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7\
      /etc/pki/rpm-gpg/RPM-GPG-KEY-remi\
      /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7\
# Spedify which version of PHP 7 to install here
 && yum-config-manager --enable remi,remi-php70\
 && yum -y install php-mssql
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

centos 6.x 上的 pdo dblib 的相关文章

  • PHP 如何判断用户是否按下了 Enter 键或 Submit 按钮?

    我遇到的问题是我在一个表单中有多个提交输入 每个提交输入都有不同的值 我更愿意将它们保留为提交 Whenever the user presses Enter it is as though the topmost submit input
  • openssl_pkey_get_details($res) 不返回公共指数

    我在用着这个例子 https stackoverflow com a 12575951 2016196使用 php 生成的密钥进行 javascript 加密openssl图书馆 但是 details openssl pkey get de
  • 删除PHP字符串中所有不匹配的字符?

    我有一个文本 我想从中删除所有不属于以下字符的字符 所需字符 0123456789 abcdefghijklmnopqrstuvwxyz n 最后一个是我确实想保留的 n 换行符 要匹配除列出的字符之外的所有字符 请使用反转字符集 http
  • 如何使用 phpunit 运行单个测试方法?

    我正在努力运行一个名为testSaveAndDrop在文件中escalation EscalationGroupTest php with phpunit 我尝试了以下组合 phpunit EscalationGroupTest escal
  • 在 php 中为类自动生成 getter 和 setter 的最佳方法是什么? [关闭]

    Closed 这个问题是基于意见的 help closed questions 目前不接受答案 我经常创建一个包含一些私有变量的类 当设置此类的实例时 应该可以使用 getter 和 setter 填充该类的所有变量 有没有一种简单的方法可
  • Yii 使用 ajax 进行分页

    我需要使用ajax启用分页 我的代码 控制器 更新内容ajax function actionIndex dataProvider new CActiveDataProvider News array pagination gt array
  • 如何使用 php 发送服务器错误响应?

    一旦用户点击删除按钮我的 jQuery 脚本要求服务器删除所选项目 现在我想要我的php发送成功或错误响应的脚本 是否有可能触发错误回调万一该项目无法删除 Thanks 我的 jQuery 代码 ajax type post url myA
  • PHP严格标准:声明应该兼容

    我有以下类层次结构 class O Base class O extends O Base abstract class A Abstract public function save O Base obj class A extends
  • 如何使用 php 下载/打印页面的特定部分

    我有一个 HTML 页面如下 Lorem Ipsum is simply dummy text of the printing and typesetting industry Lorem Ipsum has been the indust
  • 将“php”作为 shell 脚本执行时的自定义 php.ini 文件

    我在跑php作为 shell 脚本 我不确定 shell脚本 是否正确 该文件以 usr bin php 这很好用 但 MongoDB 类没有正确加载php ini文件 具有extension mongo so 未使用 我该如何使用它tha
  • 是否可以使用 PHP 重定向发送 POST 数据?

    更新 这不是重复的如何使用 PHP 发送 POST 请求 https stackoverflow com questions 5647461 how do i send a post request with php 那里的解决方案对我不起
  • 如何在原则 2 迁移中删除外键

    我想在原则 2 迁移中删除外键 但没有 dropForeignKeyConstraint 有谁知道怎么丢掉吗 public function down Schema schema table schema gt getTable table
  • 使用 SSL 证书验证 Web 浏览器

    是否可以使用 ssl 证书对 Web 浏览器进行身份验证 假设我在应用程序中存储私钥 有什么方法可以从浏览器读取密钥并尝试基于该私钥进行身份验证 您可以使用 SSL TLS 客户端证书身份验证来对浏览器 用户进行身份验证 服务器必须请求客户
  • PHP preg_filter 返回意外的长值

    尝试在 Woocommerce 中删除标签并过滤值 但无法以正确的格式获取它 有东西有腥味 我正在使用WC gt cart gt get cart subtotal 来检索该值 在此示例中 我的值是 2 429kr 原始返回值是 span
  • jQuery Mobile 表单验证

    我有一个移动网站 除了验证之外一切都工作正常 基本上我希望从用户那里获取值 然后在单独的页面 process php 上处理它们 但是 在这样做之前 我需要检查以确保字段已填充 我已经研究了几种方法来做到这一点 但似乎没有一种有效 我现在有
  • PHP 中只保留数组的前 N ​​个元素? [复制]

    这个问题在这里已经有答案了 有没有办法只保留数组的前 N 个 例如 10 个 元素 我知道有array pop 但是有没有更好 更优雅的方法呢 您可以使用array slice http php net array slice or arr
  • 跟踪用户何时点击浏览器上的后退按钮

    是否可以检测用户何时单击浏览器的后退按钮 我有一个 Ajax 应用程序 如果我可以检测到用户何时单击后退按钮 我可以显示适当的数据 任何使用 PHP JavaScript 的解决方案都是优选的 任何语言的解决方案都可以 只需要我可以翻译成
  • 表单提交后如何保留选择字段中的选定值?

    我有一个用于将票证上传到数据库的主页 我有一个选择字段 我想保留用户在提交表单之前选择的值 但它没有发生 这是我选择字段的代码
  • 内部 while 循环不工作

    这是我项目网页上的代码片段 这里我想显示用户选择的类别 然后想显示属于该类别的主题 在那里 用户可以拥有多个类别 这没有问题 我可以在第一个 while 循环中打印所有这些类别 问题是当我尝试打印主题时 结果只显示一行 但每个类别中有更多主
  • 如何使用 PHPExcel 库从 Excel 获取日期

    我正在尝试使用 PHPExcel 从 Excel 获取日期 但我没有得到日期 我得到的字符串值不是 1970 以来的秒数 我尝试过的代码是 InvDate trim excel gt getActiveSheet gt getCell B

随机推荐