Msphpsql: Installation of driver in Debian 9 (PHP 7.0)

Created on 28 Jul 2017  路  30Comments  路  Source: microsoft/msphpsql

The page https://github.com/Microsoft/msphpsql/wiki/Install-pdo_sqlsrv-for-PHP-7.0-on-Debian-in-3-ways is nice. But it does not foresee its application on Debian 9 (strectch) - current stable

installing the jessie package seems that it's not working correctly as connecting via PDO with sqlsrv driver returns:
PHP Fatal error: pdo_sqlsrv_db_handle_factory: Unknown exception caught

Linux PDO_SQLSRV

Most helpful comment

Any progress?

All 30 comments

Hi @cusco
Note that we do not yet officially support Debian 9 (Stretch). That being said, did you get our binaries on GitHub release? Or did you install pdo_sqlsrv via PECL?

@cusco you are getting this error because PDO extension is not loaded, php -m would give you the list of loaded modules and you should see PDO there. Also make sure you add "extension=php_pdo.so" in ini file before pdo_sqlsrv.so

I think the the problem lies in the msodbcsql package, which is not available for Stretch (yet).
AFAICS, the major problem is that libmsodbcsql is being linked against two different versions of OpenSSL, where 1.0.2 is available in Stretch, but 1.0.0 is not anymore:

ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.1.so.9.0 | egrep 'lib(ssl|crypto)'
    libcrypto.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007f922b6da000)
    libssl.so.1.0.0 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007f922acd2000)
    libssl.so.1.0.2 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 (0x00007f92282fd000)
    libcrypto.so.1.0.2 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2 (0x00007f9227e99000)

So maybe the question that is the most interesting question for @cusco too:
Is there a timeline for a release of msodbcsql for Stretch?

Update: Okay, so after digging around a bit more, it seems to work when there is just libssl1.0.0 but not when there is just libssl1.0.2 - so apparently one of the dependencies is linked against the newer version of libssl.

I have the exact same problem when I follow the wiki.
I tried with the official docker php:7.1-apache image

Hey guys, just install the libssl1.0.0 from jessie, and it will works:
https://packages.debian.org/jessie/libssl1.0.0

Tested & working

@deStrO Yes, of course that works, but it is neither an elegant nor secure solution...

Hi all, we currently only support Debian Jessie. We understand that Debian 9 is now released! We will look into what it will take to official support Stretch (Debian 9) and update this thread. 馃憤

Any progress?

Just ran through the complete https://github.com/Microsoft/msphpsql/wiki/Install-pdo_sqlsrv-for-PHP-7.0-on-Debian-in-3-ways without any hazzle

The problem with Debian 9 and PHP 7.0 for me is:
PHP Fatal error: Uncaught PDOException: SQLSTATE[01000]: [unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql/lib64/libmsodbcsql-13.0.so.0.0'

ls -la /opt/microsoft/msodbcsql/lib64/
total 1896
drwxr-xr-x 2 root root    4096 Nov  5 20:44 .
drwxr-xr-x 5 root root    4096 Nov  5 20:44 ..
-rwxr-xr-x 1 root root 1929296 Nov  5 20:47 libmsodbcsql-13.0.so.0.0

Although the file is present the driver manager cannot open it. Anybody has an idea ?

Update:
The solution @deStrO worked. Just do

$ wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u6_amd64.deb
# dpkg -i libssl1.0.0_1.0.1t-1+deb8u6_amd64.deb

Let's see when MS bring official support.

@meet-bhagdev, is there any update on the Debian Stretch compability?

@moschlar, No updates but it is in the plan to support it in the next RTW.

Thanks @David-Engel,

Do you have an ETA for the next RTW?

Thanks

@andrewnicols
The next RTW will be during Q1CY2018.

Regards,
David

The solution @codedge had above doesn't quite work anymore, because the link to that .deb file died. This slightly modified version worked great for me, though. Thanks everyone on this thread for finding a work-around.

$ wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb
# dpkg -i libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb

@richbon75 Well the most correct solution would be to include the Jessie repositories again, so that the package can be installed and kept up to date by APT. This way you wouldn't need the full package version anymore - just the name libssl1.0.0.

@moschlar Thanks for the tip. In the interest of having an answer here that someone finding their way to this issue can just grab and use, I guess this would be the more proper way to do it?

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
echo "deb http://deb.debian.org/debian jessie main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install libssl1.0.0

FYI, we just released 5.2.0-RC
To test it with Debian 9, ODBC 17 preview is required. You may check the instructions here

The Debian9-7.0 5.2.0-RC module release is still linked against an unsupported OpenSSL version.

libssl.so.1.0.0 => not found

Hi @jcharaoui,

It sounds like you have the old ODBC version 13 installed. Can you please check?

$ dpkg -l|grep msodbcsql ii msodbcsql 17.0.0.5-1 amd64 ODBC Driver for Microsoft(R) SQL Server(R)

ODBC 17 is not publicly available yet you will have to get the preview binaries here

The driver so file gets installed in /opt/microsoft/msodbcsql/lib64/libmsodbcsql-17.0.so.0.5
you can check the version of libssl:

$ ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-17.0.so.0.5 |grep libssl libssl.so.1.0.2 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 (0x00007f6c69a83000)

@lilgreenbird I do indeed have ODBC 17 installed.

$ ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-17.0.so.0.5 | grep libssl
        libssl.so.1.0.0 => not found
        libssl.so.1.0.2 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 (0x00007f3452f59000)

@jcharaoui , did you remove ODBC driver 13.1 beforehand? Please check the install instruction for ODBC 17 here.

@v-kaywon yes, I removed the ODBC driver 13.1 (apt remove --purge) before installing the new version.

Hi @jcharaoui I think I have reproduced the issue. My apologies I didn't catch this earlier. What you actually need to do is to install ODBC 13.1 first and then ODBC 17. The 1st installation will get your the dependencies that is needed to run the ODBC driver. Note the reason this is necessary is because ODBC 17 is not publicly available yet so you need to the ODBC 17 preview manually, thus it won't install the dependencies automatically for you.

So please remove your current ODBC 17 driver, then follow the installations instructions here to install ODBC 13, and then here

Please let me know if you have any questions, thanks.

@lilgreenbird That is exactly what I did the first time: I installed ODBC 13.1, then uninstalled, then installed ODBC 17. Are you sure your reproduced the issue on Debian 9.0 (stretch)? This truly doesn't seem to be the case, so let me spell it out for you:

The missing dependency is libssl-1.0.0. However this version of OpenSSL (1.0.0) is deprecated (see the Note section in the latest OpenSSL security advisory) and no longer supported on any recent operating system release. The ldd utility clearly indicates that the ODBC 17 library you distribute is linked to this old, deprecated and insecure OpenSSL library.

This is not an installation or packaging issue, this is an issue with the binaries your distribute. Please let us know when a fix will be released.

We install and test the same binaries in our Debian 9 test bed nightly we do not see any problems with it at all.

In trying to include a log of the exact steps that I took to repro your issues I found the culprit. Are you sure you installed the Debian 9 binaries and not Debian 8?? I can see your error if I install the wrong binaries:

bamboo@PHP-014-DEB9:~$ uname -a
Linux PHP-014-DEB9 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux
bamboo@PHP-014-DEB9:~$sudo ACCEPT_EULA=Y dpkg -i /Bamboo/PHP/ODBC/Debian8/msodbcsql_17.0.0.5-1_amd64.deb
Selecting previously unselected package msodbcsql.
(Reading database ... 139254 files and directories currently installed.)
Preparing to unpack .../msodbcsql_17.0.0.5-1_amd64.deb ...
Unpacking msodbcsql (17.0.0.5-1) ...
Setting up msodbcsql (17.0.0.5-1) ...
bamboo@PHP-014-DEB9:~$ ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-17.0.so.0.5|grep libssl
    libssl.so.1.0.0 => not found
    libssl.so.1.0.2 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 (0x00007f71c50bd000)

but if I install the proper Debian 9 binaries in Debian 9 then all is fine:

bamboo@PHP-014-DEB9:~$ uname -a
Linux PHP-014-DEB9 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux
bamboo@PHP-014-DEB9:~$yes | sudo apt-get purge -y msodbcsql
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  msodbcsql*
0 upgraded, 0 newly installed, 1 to remove and 106 not upgraded.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 139271 files and directories currently installed.)
Removing msodbcsql (17.0.0.5-1) ...
(Reading database ... 139253 files and directories currently installed.)
Purging configuration files for msodbcsql (17.0.0.5-1) ...
bamboo@PHP-014-DEB9:~$             sudo ACCEPT_EULA=Y dpkg -i /Bamboo/PHP/ODBC/Debian9/msodbcsql_17.0.0.5-1_amd64.deb
Selecting previously unselected package msodbcsql.
(Reading database ... 139254 files and directories currently installed.)
Preparing to unpack .../msodbcsql_17.0.0.5-1_amd64.deb ...
Unpacking msodbcsql (17.0.0.5-1) ...
Setting up msodbcsql (17.0.0.5-1) ...
bamboo@PHP-014-DEB9:~$ ldd /opt/microsoft/msodbcsql/lib64/libmsodbcsql-17.0.so.0.5|grep libssl
    libssl.so.1.0.2 => /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 (0x00007fb3c2df4000)

@lilgreenbird OK I understand what the problem is. You're right, I was using the Debian 8 package, which is probably the case with everyone else who reported this bug.

The problem is that in your documentation, under ODBC 17 Linux Installation / Debian 8 and 9, the download link you provide for msodbcsql_17.0.0.5-1_amd64.deb and mssql-tools_17.0.0.5-1_amd64.deb is misleading because it's only valid for Debian 8. If we replace Debian%208 by Debian%209 in the URL, then the correct version is downloaded.

I would suggest to replace this:

wget https://github.com/Microsoft/msphpsql/raw/dev/ODBC%2017%20binaries%20preview/Debian%208/msodbcsql_17.0.0.5-1_amd64.deb

with this:

wget https://github.com/Microsoft/msphpsql/raw/dev/ODBC%2017%20binaries%20preview/Debian%20`grep -oe '^[0-9]' /etc/debian_version`/msodbcsql_17.0.0.5-1_amd64.deb

This way it will automatically download the correct version for Debian 8 or 9.

yes, we will fix the documentation, thank you.
If it's ok with you can we close this issue?

Well, the documentation is still wrong, so no.
This is not good, it's downloading the same package twice, msodbcsql, and mssql-tools is now missing.

wget https://github.com/Microsoft/msphpsql/raw/dev/ODBC%2017%20binaries%20preview/Debian%208/msodbcsql_17.0.0.5-1_amd64.deb
wget https://github.com/Microsoft/msphpsql/raw/dev/ODBC%2017%20binaries%20preview/Debian%20`grep -oe '^[0-9]' /etc/debian_version`/msodbcsql_17.0.0.5-1_amd64.deb

This is how it should be:

wget https://github.com/Microsoft/msphpsql/raw/dev/ODBC%2017%20binaries%20preview/Debian%20`grep -oe '^[0-9]' /etc/debian_version`/mssql-tools_17.0.0.5-1_amd64.deb
wget https://github.com/Microsoft/msphpsql/raw/dev/ODBC%2017%20binaries%20preview/Debian%20`grep -oe '^[0-9]' /etc/debian_version`/msodbcsql_17.0.0.5-1_amd64.deb

Please consider fixing the versioning scheme for your Debian package. Your package versions should be different across operating system releases!

This has now been updated.
fyi this is only a preview release of ODBC 17, the instructions here will be removed once ODBC 17 becomes publicly available soon.

Closing this as ODBC 17.1 is officially released.

Was this page helpful?
0 / 5 - 0 ratings