2014-01-23 93 views
4

我试图在CentOS 6.5(Final)64bit上安装dblib。 centos 6没有freetds,所以我必须从其他地方获得freetds。 freetds-devel-0.91-2.1.x86_64.rpm。使用pecl来下载和安装PDO DBLIB,但我陷入了困境。我收到的错误如下。pdo dblib在centos 6.x

[[email protected] 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 


[[email protected] php]# whereis freetds 
freetds: /etc/freetds.conf /usr/include/freetds /usr/local/freetds 


[[email protected] 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 

[[email protected] ~]# 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_entryzend_function_entry但作为http://www.radebatz.net/mano/2013/11/05/compiling-pdo_dblib-on-centos-6-with-php-5-4/提到不起作用。

我也曾尝试

[[email protected] 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 
[[email protected] 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目录。

我已经设法使用follwoing configure命令./configure --prefix=/usr/local/freetds --with-gnu-ld --with-pdo-dblib=/usr/local/freetds来安装PDO DBLIB。我的网络应用程序如何不断得到。 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 


[[email protected] 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 


[[email protected] 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 

一次清理后,我设法以某种方式回来

[[email protected] 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 
[[email protected] freetds-0.91]# /usr/bin/ts 
tset tsort tsql 
[[email protected] freetds-0.91]# /usr/bin/ts 
tset tsort tsql 
[[email protected] 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() 
+0

您需要安装freetds的开发文件('freetds的-devel')以及。 –

+0

'freetds-devel'使用来自其他地方的存储库安装 – shorif2000

回答

9

最简单的方式实现这一目标:

  1. 启用EPEL存储库
  2. 安装php-mssql。这将安装unixODBCfreetds

#百胜安装PHP-MSSQL

然后,你可以从PHP + PDO(使用DBLIB驱动程序)从CentOS的连接到您的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 
+0

这是否适用于php 5.5? –

+0

我认为是这样的...... – jap1968

+1

centos 7无法安装php-mssql – SAR

0

百胜安装EPEL释放

百胜升级CA证书--disablerepo = EPEL

荫安装PHP-MSSQL