msphpsql: After upgrading from pdo_sqlsrv release candidate and msodbcsql17.1: Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.1.so.0.1' : file not found

Driver version or file name

pdo_sqlsrv 5.2.0, msodbcsql17

SQL Server version

docker mssql image: microsoft/mssql-server-linux:2017-latest

Client operating system

Php docker image running debian, host machine both UBUNTU and OS X.

PHP version

PHP 7.2-fpm on debian using the docker image

Microsoft ODBC Driver version

MSODBCSQL 17.1.0.1 : /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.1.so.0.1

Problem description

Previously I was using the preview driver (pdo_)sqlsrv5.2.0RC together with the preview ODBC17.0.5 drivers from this repo to connect to mssql. My php docker file looked like this:

FROM php:7.2-fpm
ARG TIMEZONE
RUN apt-get update && apt-get install -y freetds-bin freetds-dev freetds-common libct4 libsybdb5 libicu-dev libcurl3-dev git zlib1g-dev apt-transport-https gnupg wget

# Install mssql drivers
RUN apt-get install -y unixodbc-dev 
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql
RUN yes | apt-get purge -y msodbcsql
RUN wget https://github.com/Microsoft/msphpsql/raw/dev/ODBC%2017%20binaries%20preview/Debian%209/msodbcsql_17.0.0.5-1_amd64.deb
RUN wget https://github.com/Microsoft/msphpsql/raw/dev/ODBC%2017%20binaries%20preview/Debian%209//mssql-tools_17.0.0.5-1_amd64.deb
RUN ACCEPT_EULA=Y dpkg -i msodbcsql_17.0.0.5-1_amd64.deb
RUN ACCEPT_EULA=Y dpkg -i mssql-tools_17.0.0.5-1_amd64.deb
RUN ln -fsv /opt/mssql-tools/bin/* /usr/bin
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv-5.2.0RC1
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv

And i was able to connect to mssql from php. However since recently the preview binaries have been removed from this repository and the pdo_sqlsrv version seem to have been updated to a stable version. I decided to upgrade to (pdo)_sqlsrv 5.2 and msodbc 17.1.0.1 by changing my dockerfile to:

FROM php:7.2-fpm
ARG TIMEZONE
RUN apt-get update && apt-get install -y freetds-bin freetds-dev freetds-common libct4 libsybdb5 libicu-dev libcurl3-dev git zlib1g-dev apt-transport-https gnupg wget

# Install mssql drivers
RUN apt-get install -y unixodbc-dev
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN apt-get upgrade
RUN export DEBIAN_FRONTEND=noninteractive && ACCEPT_EULA=Y apt-get install -y msodbcsql17 mssql-tools
RUN ln -fsv /opt/mssql-tools/bin/* /usr/bin
RUN pecl install sqlsrv
RUN pecl install pdo_sqlsrv-5.2.0
RUN docker-php-ext-enable sqlsrv pdo_sqlsrv

After rebuilding the docker image I get the php exception message:

Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.1.so.0.1' : file not found

The file however seems to exist (if i run ls /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.1.so.0.1 it returns the file name). Some how (pdo_) sqsrv 5.2.0 seems to not work with the msodbc sql 17.1.0.1 drivers? Any ideas how to fix this?

Thanks a lot.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 31 (10 by maintainers)

Most upvoted comments

On ubuntu 18.04 and Debian 9, you can install libssl 1.0 to fix this issue:

apt install libssl1.0

This should be a dependency the msodbcsql17 package.

On ubuntu 18.04 and Debian 9, you can install libssl 1.0 to fix this issue:

apt install libssl1.0

This should be a dependency the msodbcsql17 package.

This fixed my similar problem for “Can’t open lib ‘/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.2.so.0.1’ : file not found”.

Anyway ubuntu 18.04 has libssl1.1 installed, but msodbcsql17 ignored it. Make use of libssl1.1 instead of libssl1.0 should be a better solution.

If anyone else hit the same issue as me (which is the opposite problem as @singhkays had) it looks like the official PHP Docker image for 7.1 updated from jessie to stretch last week, which broke our build since the binaries from the Debian 8 repo target different versions of libssl/libcrypto

@v-chojas Thanks for taking a deeper look, that was it! … in a roundabout way… I started looking into why that package was not available for my container image and it turns out the container image is based on Debian 8 instead of 9 as I had initially thought. I updated the Dockerfile with Debian 8 install instructions and it works now!

I realized the problem - in my dockerfile I was still using the debian 8 repo (for jessie) and needed to update it to use the debian 9 (stretch) repo.

Now it’s working properly! Here is that section from my dockerfile

RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update -yqq \
    && ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev unixodbc \
    && rm -r /var/lib/apt/lists/*

RUN pecl install sqlsrv pdo_sqlsrv

RUN /usr/local/bin/docker-php-ext-enable sqlsrv pdo_sqlsrv

I recommend to move them instead of copying, that way you will not confuse yourself with multiple DM libraries.

in kali linux,how fix, i am ok @fabiang @chrispappas @stevedesmond-ca

# find / -name "libssl.so.1*.*"
/var/lib/docker/aufs/diff/ab6ad040a6763faa6f03ef656622243463e7730a88f68a6725c462465edc0bfe/lib/x86_64-linux-gnu/libssl.so.1.0.0
^C
root@b90f61682f4b:~/mytools/tmp# cp  /var/lib/docker/aufs/diff/ab6ad040a6763faa6f03ef656622243463e7730a88f68a6725c462465edc0bfe/lib/x86_64-linux-gnu/libssl.so.1.0.0 /usr/lib/x86_64-linux-gnu/


# find / -name "libcrypto.so.1*.*"
/var/lib/docker/aufs/diff/ab6ad040a6763faa6f03ef656622243463e7730a88f68a6725c462465edc0bfe/lib/x86_64-linux-gnu/libcrypto.so.1.0.0

cp /var/lib/docker/aufs/diff/ab6ad040a6763faa6f03ef656622243463e7730a88f68a6725c462465edc0bfe/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /usr/lib/x86_64-linux-gnu/ 

I leave this here. It detects the Debian version:

RUN DEBIAN_FRONTEND=noninteractive apt-get update -yqq \
    && apt-get install -y apt-transport-https \
    && apt-get install -y --no-install-recommends curl libc6 g++ libssl1.0 \
    && export $(grep VERSION_ID /etc/os-release | sed -e 's/\"//g') \
    && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
    && curl https://packages.microsoft.com/config/debian/${VERSION_ID}/prod.list > /etc/apt/sources.list.d/mssql-release.list \
    && apt-get update -yqq \
    && ACCEPT_EULA=Y apt-get install -y --no-install-recommends unixodbc odbcinst1debian2 unixodbc-dev msodbcsql17 mssql-tools \
    && pecl install pdo_sqlsrv \
    && docker-php-ext-enable pdo_sqlsrv \
    && apt-get remove -y unixodbc-dev curl g++ apt-transport-https \
    && rm -rf /var/lib/apt/lists/* \
    && rm /etc/apt/sources.list.d/mssql-release.list