Yii 2.0 Linux MSSQL setup – could not find driver (Could not connect to a database)

My setup:

Debian

MSSQL Express 2014

Yii 2.0

To get a connection to a database working i had to do the following:

in my /config/db.php

We are using dblib as this works on Linux 

More info here regards the DSN

http://www.yiiframework.com/doc-2.0/guide-db-dao.html (It would be nice if they would let us know that not all drivers works on Linux:)

return [
‘class’ => ‘yii\db\Connection’,
‘dsn’ => ‘dblib:host=xx;dbname=xx’,
‘username’ => ‘xx’,
‘password’ => ‘xx!’,
‘charset’ => ‘utf8’,

then install

apt-get install php5-sybase

service apache2 restart and try again.

I have also installed the following:

apt-get install php5-sqlite

apt-get install php5-odbc

Hope this helps someone!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s