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)
On ubuntu 18.04 and Debian 9, you can install libssl 1.0 to fix this issue:
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.1installed, butmsodbcsql17ignored it. Make use oflibssl1.1instead oflibssl1.0should 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
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
I leave this here. It detects the Debian version: