Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sqlsrv connection problem: Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1' #592

Closed
3 of 7 tasks
SlimDeluxe opened this issue Jun 13, 2019 · 12 comments · Fixed by #647
Closed
3 of 7 tasks
Assignees
Labels

Comments

@SlimDeluxe
Copy link

SlimDeluxe commented Jun 13, 2019

ISSUE TYPE

  • Bug Report

Checklist

(the above files are not allowed as attachments, let me know if you need them and I can zip them)

OS / ENVIRONMENT

  1. Host operating system and version: Ubuntu 18.04 x64
  2. (Windows) Native Docker or Docker Toolbox: not sure what is meant here - I followed your installation instructions
  3. Docker version: Docker version 18.09.6, build 481bc77
  4. Docker Compose version: docker-compose version 1.23.2, build 1110ad01
  5. (Linux) Is SELinux enabled?: Yes
  6. What git commit hash are you on?: fdb6cff

SUMMARY

When connecting to remote SQL server an error is returned.

STEPS TO REPRODUCE

  1. Enable the sqlsrv extension / remove it from the disabled modules
    PHP_MODULES_DISABLE=oci8,PDO_OCI,pdo_sqlsrv,rdkafka,swoole
  2. Enable (copy and rename) the startup script in cfg/php-startup-7.2: 02-ms-odbc-driver.sh-example and set the ACCEPT_EULA to Y
  3. Start the enviroment
  4. In a PHP script, try connecting to a remote server
$serverName = "xx.xx.xx.xx\\INSTANCE_NAME";
    $connectionOptions = array(
        "Database" => "dbname",
        "Uid" => "username",
        "PWD" => "password"
    );

EXPECTED BEHAVIOUR

Being able to connect.

ACTUAL BEHAVIOUR

sqlsqv_errors() returns the following array:

array(1) {
--
  | [0]=>
  | array(6) {
  | [0]=>
  | string(5) "01000"
  | ["SQLSTATE"]=>
  | string(5) "01000"
  | [1]=>
  | int(0)
  | ["code"]=>
  | int(0)
  | [2]=>
  | string(117) "[unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1' : file not found"
  | ["message"]=>
  | string(117) "[unixODBC][Driver Manager]Can't open lib '/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1' : file not found"
  | }
  | }

OTHER INFORMATION

Start command

docker-compose up -d httpd php mysql redis rabbit

File and user permissions (Linux & MacOS)

$ id
uid=1000(omer) gid=1000(omer) groups=1000(omer),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lpadmin),126(sambashare),999(docker)

$ ls -la
drwxr-xr-x 17 omer omer  4096 jun 13 19:22 .
drwxr-xr-x 40 omer omer  4096 jun 13 19:42 ..
drwxr-xr-x  2 omer omer  4096 jun  5 21:39 autostart
drwxr-xr-x  3 omer omer  4096 dec 26 18:28 backups
drwxr-xr-x  2 omer omer  4096 dec 26 17:58 bash
drwxr-xr-x  2 omer omer  4096 dec 26 18:28 ca
drwxr-xr-x 57 omer omer  4096 jun  5 21:39 cfg
-rw-r--r--  1 omer omer  4558 jun  5 21:39 CHANGELOG.md
drwxr-xr-x  2 omer omer  4096 jun  5 21:39 compose
-rw-r--r--  1 omer omer  2770 jun  5 21:39 CONTRIBUTING.md
drwxr-xr-x  3 root root  4096 jun  5 20:25 data
drwxr-xr-x  3 omer omer  4096 jun  5 21:39 .devilbox
-rw-r--r--  1 omer omer   680 dec 26 17:58 docker-compose.override.yml
-rw-r--r--  1 omer omer   743 dec 26 17:58 docker-compose.override.yml-example
-rw-r--r--  1 omer omer 14314 jun  5 21:39 docker-compose.yml
drwxr-xr-x 20 omer omer  4096 jun  5 21:39 docs
-rw-r--r--  1 omer omer  2445 jun  5 21:39 .editorconfig
-rw-r--r--  1 omer omer 16956 jun 13 19:22 .env
-rw-r--r--  1 omer omer 16622 jun  5 21:39 env-example
drwxr-xr-x  8 omer omer  4096 jun 13 21:37 .git
drwxr-xr-x  3 omer omer  4096 jun  5 21:39 .github
-rw-r--r--  1 omer omer  3837 jun  5 21:39 .gitignore
-rw-r--r--  1 omer omer  1064 dec 26 17:58 LICENSE.md
drwxr-xr-x  8 omer omer  4096 dec 26 18:28 log
drwxr-xr-x  2 omer omer  4096 jun  5 21:39 mail
drwxr-xr-x  8 omer omer  4096 dec 26 17:58 mod
-rw-r--r--  1 omer omer 63103 jun  5 21:39 README.md
-rw-r--r--  1 omer omer    86 dec 26 17:58 shell.bat
-rwxr-xr-x  1 omer omer    59 dec 26 17:58 shell.sh
drwxr-xr-x  5 omer omer  4096 jun  5 21:39 .tests
-rw-r--r--  1 omer omer  9808 jun  5 21:39 .travis.yml
-rwxr-xr-x  1 omer omer  2265 jun  5 21:39 update-docker.sh
-rw-r--r--  1 omer omer  1043 jun  5 21:39 UPDATING.md

@SlimDeluxe SlimDeluxe added the bug label Jun 13, 2019
@science695
Copy link

@SlimDeluxe Can you use get into the container shell (using shell.sh or shell.bat) and ls the lib file?

@SlimDeluxe
Copy link
Author

@science695 I remember checking and it was there, I can check again when I get home later today.

@SlimDeluxe
Copy link
Author

SlimDeluxe commented Jul 4, 2019

@science695, yes, it exists

devilbox@php-7.2.19 in /shared/httpd $ ls -la /opt/microsoft/msodbcsql17/lib64/
total 2032
drwxr-xr-x 2 root root    4096 Jul  4 19:35 ./
drwxr-xr-x 6 root root    4096 Jul  4 19:35 ../
-rwxr-xr-x 1 root root 2069832 Feb 12 22:05 libmsodbcsql-17.3.so.1.1

Btw. the same error occurs with PHP 7.3 set in .env, so I guess it's not specific to any PHP version

@whuhacker
Copy link

whuhacker commented Jul 10, 2019

Maybe related to microsoft/msphpsql#745 (comment)
apt install libssl1.0 will solve the problem

I thought they fixed it in msodbcsql17 (17.3), but it's not.

$ ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1
	linux-vdso.so.1 (0x00007fff6998f000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fbd882de000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fbd880d6000)
	libodbcinst.so.2 => /usr/lib/x86_64-linux-gnu/libodbcinst.so.2 (0x00007fbd87ebb000)
	libcrypto.so.1.0.0 => not found
	libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007fbd87be5000)
	libgssapi_krb5.so.2 => /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007fbd8799a000)
	libssl.so.1.0.0 => not found
	libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007fbd87793000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fbd8740a000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fbd8706c000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fbd86e54000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fbd86c35000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbd86844000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fbd888e7000)
	libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007fbd86612000)
	libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007fbd8640e000)
	libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007fbd86203000)
	libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007fbd85fff000)
	libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fbd85de4000)```

@SlimDeluxe
Copy link
Author

@whuhacker
It seems it's already installed:

devilbox@php-7.3.5 in /shared/httpd $ dpkg --get-selections | grep libssl
libssl-dev:amd64				install
libssl1.0.2:amd64				install
libssl1.1:amd64					install

But you are on to something, they really are not registered correctly. Any idea how to fix this?

devilbox@php-7.3.5 in /shared/httpd $ ldd /opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1 | grep 'not found'
	libcrypto.so.1.0.0 => not found
	libssl.so.1.0.0 => not found

I tried searching for the specified files globally but there are no results :(

@Tbaile
Copy link

Tbaile commented Jul 18, 2019

Got the same error here, is by any changes related to microsoft/msphpsql#1002 ?

@SlimDeluxe
Copy link
Author

@Tbaile someone on gitter told me "this dockerfile works well", but I haven't tried it. Devilbox is my first contact with docker, so I don't know what to do with it and I haven't googled it yet :) I want to find a solution within devilbox.

FROM devilbox/php-fpm:7.3-prod

RUN apt-get update && apt-get install -y wget gpg apt-transport-https ca-certificates
RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
RUN mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
RUN wget -q https://packages.microsoft.com/config/debian/9/prod.list
RUN mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
RUN chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
RUN chown root:root /etc/apt/sources.list.d/microsoft-prod.list
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql17

@Tbaile
Copy link

Tbaile commented Jul 19, 2019

I want to find a solution within devilbox

Well, this Dockerfile is exactly devilbox, just with a few add-ons 😄, don't worry if it's your first approach, once you got into the mindset it's easier.
With that said, didn't knew ODBC can be installed given the correct repos, the documentation about the IIS systems is quite tricky and is subject to changes between languages.
I'll give a try when I get off work, I'll let you know if I fix something 😉

@SlimDeluxe
Copy link
Author

I want to find a solution within devilbox

Well, this Dockerfile is exactly devilbox, just with a few add-ons , don't worry if it's your first approach, once you got into the mindset it's easier.

I realise DevilBox is just a wrapper for Docker. I only meant to say that I want a solution that's easy to implement and manage with updates (git pull), portability to other systems/developers... in mind.
With that said, I converted the above script to a startup shell script and it works fine :) The only downside is that now the PHP container needs some more time to startup - the apt update command is somewhat slow.
Anyway, here's the script which you should put in cfg/php-startup-7.3/ (for a specific PHP version) or autostart/ (for all versions).

#!/bin/bash

apt update
apt install -y wget gpg apt-transport-https ca-certificates
cd ~
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
mv microsoft.asc.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/9/prod.list
mv prod.list /etc/apt/sources.list.d/microsoft-prod.list
chown root:root /etc/apt/trusted.gpg.d/microsoft.asc.gpg
chown root:root /etc/apt/sources.list.d/microsoft-prod.list
apt update
ACCEPT_EULA=Y apt install -y msodbcsql17

However I still think the startup script distributed with DevilBox should be fixed, so I will leave this bug report open. Maybe some developer will get around and attend to it.

@Tbaile
Copy link

Tbaile commented Jul 27, 2019 via email

@SlimDeluxe
Copy link
Author

Considering your last reply, I tried changing the startup script to use the version 9 and it works :) And it's much faster to start than the apt one.

So all you need to do is change this line in 02-ms-odbc-driver.sh

MSODBC_URL="https://packages.microsoft.com/debian/8/prod/pool/main/m/msodbcsql17/"

to this:

MSODBC_URL="https://packages.microsoft.com/debian/9/prod/pool/main/m/msodbcsql17/"

@stale
Copy link

stale bot commented Oct 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the issue:stale This issue has become stale and is marked for auto-close label Oct 6, 2019
@stale stale bot closed this as completed Oct 13, 2019
@cytopia cytopia reopened this Nov 17, 2019
@stale stale bot removed the issue:stale This issue has become stale and is marked for auto-close label Nov 17, 2019
@cytopia cytopia self-assigned this Nov 30, 2019
cytopia added a commit that referenced this issue Nov 30, 2019
@cytopia cytopia mentioned this issue Nov 30, 2019
@cytopia cytopia mentioned this issue Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants