- 工信部備案號 滇ICP備05000110號-1
- 滇公網安備53011102001527號
- 增值電信業(yè)務經營許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯(lián)網協(xié)會理事單位
- 安全聯(lián)盟認證網站身份V標記
- 域名注冊服務機構許可:滇D3-20230001
- 代理域名注冊服務機構:新網數(shù)碼
- CN域名投訴舉報處理平臺:電話:010-58813000、郵箱:service@cnnic.cn
一般情況下都是php+mysql,asp.net+sqlserver這種使用。有客戶反饋需要在他的centos系統(tǒng)下進行php連接sqlserver數(shù)據(jù)庫,請求協(xié)助處理。
這里藍隊網絡就把整體的安裝設置流程記錄分享下,希望能幫到也有同樣需求的人。
linux下安裝php的mssql擴展,首先需要安裝freetds.下載地址:ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz
登陸我們的服務器,我這里使用的是centos6.7 nginx+apache+php 我的php為5.4版本。
#cd /opt && wget ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz #tar zxvf freetds-patched.tar.gz #cd freetds-0.95.87 && ./configure --prefix=/usr/local/freetds --with-tdsver=7.3 --enable-msdblib # make && make install
安裝完成后安裝php擴展。
#cd /opt/php-5.4.45/ext/mssql #/usr/local/php5.4/bin/phpize #./configure --with-php-config=/usr/local/php5.4/bin/php-config --with-pdo-dblib=/usr/local/freetds/ #make && make install
編譯完php的mssql擴展后編輯你的php配置文件開啟擴展然后重啟apache或者php-fpm(fastcgi)進程。
測試文件:
<?php
error_reporting(E_ERROR & ~E_NOTICE);
ini_set("display_errors",1);
ini_set("error_reporting",E_ALL);
ini_set("log_errors",1);
header("Content-type: text/html; charset=utf-8");
$msdb=mssql_connect("數(shù)據(jù)庫主機地址:1433","用戶","密碼");
if (!$msdb) {
echo "connect sqlserver error";
exit;
}
mssql_select_db("數(shù)據(jù)庫",$msdb);
$result = mssql_query("select @@version", $msdb);
while($row = mssql_fetch_array($result)) {
print_r($row);
}
mssql_free_result($result);
?>
運行截圖:
可以看到成功連接上并執(zhí)行了版本查詢語句。
售前咨詢
售后咨詢
備案咨詢
二維碼

TOP