【宝塔】安装sqlsrv扩展

网络上较多的教程基于centos的sqlsrv扩展安装教程
这边记录下基于Debian系的deepin发行版下安装sqlsrv扩展

示例环境:
宝塔:7.9.0
OS:Deepin GNU/Linux 20.4 x86_64(Py3.7.8)
PHP:7.4

第一步、依赖安装

sudo apt-get install unixodbc-dev

第二步、安装PHP的pdo-sqlsrv扩展库

其他版本,可到这个链接寻找:
https://pecl.php.net/package/pdo_sqlsrv
不同版本的对应,可以参考这里:
https://docs.microsoft.com/en-us/sql/connect/php/microsoft-php-drivers-for-sql-server-support-matrix?view=sql-server-ver15#php-version-support

# [可选] 源码压缩包存放位置
cd /usr/local/src;

下载对应版本PHP扩展库

# 下载
wget https://pecl.php.net/get/pdo_sqlsrv-5.8.1.tgz

# 解压
tar -zxvf pdo_sqlsrv-5.8.1.tgz

# 进入解压后的目录
cd pdo_sqlsrv-5.8.1

编译安装

1、运行phpize:

/www/server/php/74/bin/phpize 
# 得到类似以下内容:
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902

2、执行配置设置:

./configure --with-php-config=/www/server/php/74/bin/php-config
# 不出意外的话,得到类似以下内容
# ....省略其他信息....
creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC
checking if g++ PIC flag -fPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
(cached) (cached) checking how to hardcode library paths into programs... immediate
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h

3、编译扩展库

make && make install
# 不出意外的话,得到类似以下内容
# ....省略其他信息....
Installing shared extensions: /www/server/php/74/lib/php/extensions/no-debug-non-zts-20190902/

三、宝塔php.ini配置

将:
/www/server/php/74/lib/php/extensions/no-debug-non-zts-20190902/pdo_sqlsrv.so
配置到php.ini中,配置内容例如:

extension = /www/server/php/74/lib/php/extensions/no-debug-non-zts-20190902/pdo_sqlsrv.so

【宝塔】安装sqlsrv扩展配置

四、验证

在这里插入图片描述

附:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陀螺蚁

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值