注意:
1、server-dsn是数据源,事先在freetds.conf配置好的
[server-dsn]
host = 192.168.10.125
port = 1433
tds version = 8.0
client charset = UTF-8
开始安装
1、输入安装命令 自动先安装freetds安装包
sudo yum install php-mssql -y
sudo service httpd restart
2 、phpinfo查看有mssql即安装成功
3 、简单代码测试mssql
<?php
//第2种ok
$conn=@mssql_connect("server-dsn","sa","123456") or die("连接错误");
mssql_select_db("THIS08") or die("没有此数据库");
$sql="select @@version";//查版本
$sql = 'SELECT * FROM ZY_USER';
$result=mssql_query($sql);
print_r($result);
while($row=mssql_fetch_assoc($result))
{ //print_r($row);
}
mssql_close($conn);
?>
标签:centos,server,dsn,freetds,php,安装,mssql
From: https://blog.51cto.com/u_2148212/7604932