centos 安装 php sqlsrv

6 篇文章 0 订阅

此贴可解决thinkphp无法连接sqlserver    couldn't found driver  错误  学习thinkphp 请加群 89890449

 

一、加入微软的源

curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssqlrelease.repo 

复制代码

二、防止冲突先卸载原有版本(可选)

yum remove unixODBC 

复制代码

三、安装驱动(三个都要装上,缺一不可)

yum install msodbcsql mssql-tools unixODBC-devel

复制代码

四、下载pdo_sqlsrv扩展包 http://pecl.php.net/package/pdo_sqlsrv
五、以4.0.8为例

tar -zxvf pdo_sqlsrv-4.0.8.tgz

复制代码

六、进入解压目录

cd pdo_sqlsrv-4.0.8

复制代码

七、执行PHP的一个扩展命令

/usr/local/php/bin/phpize

复制代码

八、编译

./configure --with-php-config=/usr/local/php/bin/php-config

复制代码

九、安装

make && make install

复制代码

十、修改/usr/local/php/etc/php.ini 查找:extension = 再最后一个extension= 后面添加上extension = "pdo_sqlsrv.so"
十一、重启PHP,大功告成 
 

某些服务器上可能会报这个错误

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/



 One of the configured repositories failed (testing 2 devtools for CentOS 7),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=testing-devtools-2-centos-7 ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable testing-devtools-2-centos-7
        or
            subscription-manager repos --disable=testing-devtools-2-centos-7

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=testing-devtools-2-centos-7.skip_if_unavailable=true

解决方法:修改/etc/yum.repos.d 文件夹下devtools-2.repo文件, 改名备份,使其失效,即可解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值