问题场景
linux centos7.5 环境下,使用宝塔安装PHP链接SQLserver扩展:pdo_sqlsrv、sqlsrv;
如下图所示:
安装完成后报以下错误信息:
报错信息
SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to downl
oad the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712
修复过程:
以上问题跟Windows上使用宝塔一样,缺少一个插件,linux解决方法如下:
linux系统安装方法
1、配置yum源
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/msprod.repo
2、yum 安装sql-tool
yum install -y mssql-tools
3、配置环境变量
echo ‘export PATH=“
P
A
T
H
:
/
o
p
t
/
m
s
s
q
l
−
t
o
o
l
s
/
b
i
n
"
′
>
>
/
.
b
a
s
h
p
r
o
f
i
l
e
e
c
h
o
′
e
x
p
o
r
t
P
A
T
H
=
"
PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile echo 'export PATH="
PATH:/opt/mssql−tools/bin"′>> /.bashprofileecho′exportPATH="PATH:/opt/mssql-tools/bin”’ >> ~/.bashrc
source ~/.bashrc
执行完以上脚本,重新调用PHP链接SQLserver即可。