参考文章php
http://www.cnblogs.com/facetwitter/p/6444706.html?utm_source=itdadao&utm_medium=referralhtml
http://www.cnblogs.com/jiechn/p/4841865.htmlnginx
1.必需安装freetdssql
配置数据库
[myconfig]
host = 192.168.2.22
port = 1433
tds version = 8.0
client chaeset = UTF-8服务器
测试 :/usr/local/freetds/bin/tsql -H 数据库服务器IP -p 端口号 -U 用户名 -P 密码(用这个我是测试链接不上)yii
我是这样测试的: Cd 到 /usr/local/freetds/bin/tsqlphp-fpm
tsql -S myconfig -U name -P password 能链接上 ,简单的 命令 use database;top 10 * from table;测试
3接下来添加php的mssq和pdo_dblib扩展spa
个人环境是nginx 的因此重启完nginx 重启 php-fpm
4.最后数据库配置
'class' => 'yii\db\Connection',
'dsn' => 'dblib:host=myconfig;dbname=dbname',//这里我用ip他不行,用这个名称就能够,我也不知道 ,这个要是不行,试下下面这个
//'dsn' => 'sqlsrv:Server=myconfig;Database=dbname',
'username' => '',
'password'=>'',
//'charset'=>'utf8',
//'persistent'=> false,
'enableSchemaCache' => true,
// Duration of schema cache.
'schemaCacheDuration' => 300,
// Name of the cache component used. Default is 'cache'.
'schemaCache' => 'cache',
若是报找不到驱动的就先确保装了上面的扩展和模块,重启nginx,php-fpm,再就是dsn的配置问题了