jtech's picture

Hi, Any easy way of installing the pdo_sqlsrv and sqlsrv drivers. I'm relativly new to debiam/linux

I'm using NGINX Buster VM image.

Not having much luck...

tried this....

curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list

apt-get update
ACCEPT_EULA=Y apt-get install msodbcsql17

apt-get install g++

apt install php-pear php7.3-dev

pecl install sqlsrv
pecl install pdo_sqlsrv
 

Forum: 
Jeremy Davis's picture

You didn't actually include an error message, so I'm not clear exactly what went wrong where.

Anyway, I tried installing it and the pecl step(s) failed for me. First it failed because 'make' was missing, so I added that package. Then it still failed (with "fatal error: sql.h: No such file or directory"). That lead me to conclude that there was a missing dependency. So I had a look around and there is another MS package called "unixodbc-dev". Microsoft suggests that it's optional, but that doesn't appear to be the case...

To install those 2:

ACCEPT_EULA=Y apt install -y make unixodbc-dev

After that, the pecl steps succeeded for me. Then I wrote the PHP config files, enabled them. Finally I restarted the php process:

mod_avail=/etc/php/7.3/mods-available
echo -e "; priority=20\nextension=sqlsrv.so" > $mod_avail/sqlsrv.ini
echo -e "; priority=30\nextension=pdo_sqlsrv.so\n" > $mod_avail/pdo_sqlsrv.ini                    

phpenmod sqlsrv pdo_sqlsrv

systemctl restart php-fastcgi.service

Now the PHP info (i.e. http://YOUR_SERVER/phpinfo.php) shows the new drivers ('sqlsrv' & 'pdo_sqlsrv') enabled. I know nothing about MSSQLServer so didn't test beyond that.

Perhaps some of what I've written helps you out? If not, please share more detail on the actual problem you're hitting, including any error messages.

Add new comment