Centos 8,PHP 7.2和MS Sql Server [英] Centos 8, PHP 7.2 and MS Sql Server

查看:83
本文介绍了Centos 8,PHP 7.2和MS Sql Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正计划继续使用Centos 8,但似乎仅使用普通的Centos 8软件包就无法与SQL Server建立有效的PDO连接.

I am planning moving on to the Centos 8 but it seems that I cannot get a working PDO connection with SQL server using just plain Centos 8 packages.

我已经安装了unixODBC软件包,然后从PECL sqlsrv和sqlsrv_pdo安装了软件包,但是我不知道如何进行实际的连接或odbc配置.

I have installed the unixODBC packages and after that from PECL sqlsrv and sqlsrv_pdo but I can't figure out how to make the actual connection or odbc configuration.

由于我要转移到新环境中的大多数代码都是使用PDO编写的,因此我不想将其更改为sql server native.

As most of my code to be transferred to the new environments is written using PDO, I wouldn't want to change it to sql server native.

是否有任何分步说明如何在不使用freetds的情况下建立到SQL Server的PDO ODBC连接,而centt存储库(或RHEL都无法使用)没有提供.

Are there any step-by-step instructions how to build PDO ODBC connection to sql server without using freetds, which isn't available through the centos repositories (or RHEL either).

推荐答案

我遇到了同样的问题,并按照以下步骤解决了该问题:

I faced the same issue and I solved it as follow:

sudo dnf install php-pear
sudo dnf install php-devel
sudo dnf install make
sudo pecl install sqlsrv
sudo dnf install unixODBC-devel
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv

然后:

sudo nano /etc/php.d/30-pdo_sqlsrv.ini

添加文件30-pdo_sqlsrv.ini:

Add in the file 30-pdo_sqlsrv.ini:

extension=pdo_sqlsrv.so

然后:

sudo nano /etc/php.d/20-sqlsrv.ini

添加文件20-sqlsrv.ini:

Add in the file 20-sqlsrv.ini:

extension=sqlsrv.so

https:/下载并安装msodbcsql17-17.4.2.1-1.x86_64.rpm/packages.microsoft.com/rhel/8/prod/

sudo yum install msodbcsql17-17.4.2.1-1.x86_64.rpm

然后只需要重新启动php-fpm

Then just need to restart php-fpm

sudo systemctl restart php-fpm.service

祝你好运!

这篇关于Centos 8,PHP 7.2和MS Sql Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆