【问题标题】:Cannot install sqlsrv library for php5.6 on ubuntu 14.04无法在 ubuntu 14.04 上为 php5.6 安装 sqlsrv 库
【发布时间】:2018-07-20 15:05:51
【问题描述】:

如何安装这个库以使用我的 php5.6 连接到 mssql 2012?

更新: 我发现版本 3.0.1 是正确的版本(如果我错了请纠正我)。

但是现在,我得到了这个错误:

pecl install sqlsrv-3.0.1    
downloading sqlsrv-3.0.1.tgz ...
Starting to download sqlsrv-3.0.1.tgz (134,966 bytes)
.............................done: 134,966 bytes
17 source files, building
running: phpize
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module

ERROR: `phpize' failed

更新: 当我尝试手动安装文件时,顶级目录不包含 config.m4。它只包含 config.w32... 我该怎么办?

【问题讨论】:

标签: php sql-server odbc ubuntu-14.04 unixodbc


【解决方案1】:

在 CentOS 7 上遇到同样的问题。来自 pecl.php.net 的存档(版本 3.0.1,在 4.0.4 文件中存在,但至少需要 php7.0)中不存在文件 config.m4。我认为这个模块不适用于 linux php 5 版本。最好编译mssql模块。

这就是为什么我从 https://museum.php.net 下载完整的 php 存档(在我的情况下是 - php-5.6.40.tar.xz)并从中编译 mssql

cd /tmp/
wget https://museum.php.net/php5/php-5.6.40.tar.gz
tar xvf php-5.6.40.tar.gz
cd php-5.6.40/ext/mssql/
/opt/php56/bin/phpize (in your case path to php5.6 phpize can be different)
yum install autoconf (on ubuntu package can have different name)
yum install freetds freetds-devel freetds-libs freetds (required to compile)
ln -s /usr/lib64/libsybdb.so /usr/lib/libsybdb.so (compiling search for libsybdb.so in /usr/lib/libsybdb.so but file was in  /usr/lib64/libsybdb.so that why i create symlink)
./configure --with-php-config=/opt/php56/bin/php-config (in your case path to php5.6 php-config can be different)
make

我得到了带有我的 php5.6 配置的 mssql 模块

/tmp/php-5.6.40/ext/mssql/modules/mssql.so

并且可以很容易的将它连接到我在php.ini中的php56

【讨论】:

    【解决方案2】:

    您可以像这样安装特定版本:pecl install sqlsrv-4.3.0

    您必须浏览更新日志here 才能找到您需要的版本。

    【讨论】:

    • 我试过了。但它没有指定?版本 3 是否适用于 php5.6 ?
    • 对不起,不知道,你需要自己弄清楚。您可能只是从列表顶部开始,然后继续下降,直到一个有效。
    • 谢谢,我找到版本了。
    • 您能否将您的评论更新为适合您的版本?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-08
    • 2021-12-01
    • 2015-09-23
    • 2016-03-24
    • 2016-02-16
    • 2016-10-30
    相关资源
    最近更新 更多