在 TurnKey GNU/Linux 9.11 中安装 sqlsrv php 扩展时出现问题

Problem installing sqlsrv php extension in TurnKey GNU/Linux 9.11

我已经尝试在我的 LAMP 服务器中为 php 安装 sqlsrv 和 pdo_sqlsrv 扩展,命令为:

pecl install sqlsrv
pecl install pdo_sqlsrv

但失败并出现此错误:

Makefile:204: recipe for target 'shared/core_stream.lo' failed
make: *** [shared/core_stream.lo] Error 1
ERROR: `make' failed

更多详情:

lsb_release -a
No LSB modules are available.
Distributor ID: TurnKey
Description:    TurnKey GNU/Linux 9.11 (stretch)
Release:        9.11
Codename:       stretch

odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

odbcinst -q -d -n "ODBC Driver 13 for SQL Server"
[ODBC Driver 13 for SQL Server]
Description=Microsoft ODBC Driver 13 for SQL Server
Driver=/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.2
UsageCount=1

在此先感谢您的帮助

您尝试安装的 SQL 服务器的 ODBC 驱动程序 13 已经过时,不适合基于您的 Linux 发行版的 Debian 9。

您应该安装 ODBC 驱动程序 17:

sudo su 
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list

exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
# optional: for bcp and sqlcmd
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
# optional: for unixODBC development headers
sudo apt-get install unixodbc-dev
# optional: kerberos library for debian-slim distributions
sudo apt-get install libgssapi-krb5-2

以上代码专用于 Debian 9,可能无法在您的系统上运行,但很可能会。 代码来自: Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS