gpt4 book ai didi

php - centos 6.x 上的 pdo dblib

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:05:32 24 4
gpt4 key购买 nike

我正在尝试在 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

我已尝试将 pdo_dblib.c 中的 function_entry 更改为 zend_function_entry 但没有像 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

似乎它没有获取 include 目录。

我已经使用以下配置命令安装了 PDO DBLIB ./configure --prefix=/usr/local/freetds --with-gnu-ld --with-pdo-dblib=/usr/local/freetds.我如何在我的网络应用程序上不断获得。 CDbConnection 无法打开数据库连接:SQLSTATE[HY000] 无法连接:Adaptive Server 不可用或不存在(严重性 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. 安装php-mssql。这也将安装 unixODBCfreetds

# yum install 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

关于php - centos 6.x 上的 pdo dblib,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21315354/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com