linux下 連結 sqlserver資料庫 驅動的安裝

來源:互聯網
上載者:User

標籤:

1.必需安裝freetds 

安裝pdo_dblib擴充首先需要安裝freetds。

freeTDS的最新穩定版是0.91,這個可以在官網上下載http://www.freetds.org/ ,也可以在http://download.csdn.net/detail/DLUTXIE/3663528下載

下載freetds

wget  ftp://ftp.freetds.org/pub/freetds/stable/freetds-stable.tgz

tar zxf freetds-stable.tgz

cd freetds-stable/

/usr/bin/phpzie

./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib

make  && make install 

配置freetds設定檔:

Host填sqlserver伺服器位址

Port 填連接埠

Tds version=8.0

Client charset = utf8

3.安裝php_dblib模組

    /usr/local /php5/bin/phpize 

通過pdo_dblib連結資料庫

--with-pdo-dblib路徑指的是freetds的安裝路徑

    ./configure --with-php-config=/usr/local/php5/bin/php-config  --with-pdo-dblib=/usr/local/freetds

 make

 make install 

在php.ini裡加上extension=pdo_dblib.so。

然後重啟nginx和php-fpm

[[email protected] no-debug-non-zts-20121212]# /etc/init.d/nginx restart

[[email protected] no-debug-non-zts-20121212]# /etc/init.d/php-fpm restart

查看phpinfo裡是否存在pdo_dblib擴充

4.pdo串連資料庫的時候:

         記得是用dblib,而不是sqlserver

<?php

    try{

            $link=new PDO("dblib:host=souyue91;dbname=dbname","dbuser","dbpass");

    }catch(PDOException $e){

        echo $e->getMessage();

    }

Host填的是freetds裡面配的souyue91

linux下 連結 sqlserver資料庫 驅動的安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.