Msphpsql: Ubuntu 18.04 Installation of MSODBCSQL Driver 17

Created on 17 Sep 2018  路  16Comments  路  Source: microsoft/msphpsql

PHP Driver version or file name

5.3

## Client operating system

Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

## PHP version

7.2

## Microsoft ODBC Driver version

Microsoft ODBC Driver 17 for SQL Server

Problem description

Attempted to follow installation instructions found here: https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017

The driver installs fine through PECL and I can load/use it in PHP, but it gives me the following message:

SQLSTATE[IMSSP]: This extension requires the Microsoft ODBC Driver for SQL Server to communicate with SQL Server. Access the following URL to download the ODBC Driver for SQL Server for x64: https://go.microsoft.com/fwlink/?LinkId=163712 (SQL: SELECT TOP 1 * FROM tablename)

Expected behavior and actual behavior

My expectation was to follow the Ubuntu 18.04 install instructions at the link above and have a working PHP SQLSRV driver. However, it fails trying to install msodbcsql17.

user@hostname:~$ sudo apt-get install msodbcsql17
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
msodbcsql17 : Depends: unixodbc (>= 2.3.1) but it is not installable
E: Unable to correct problems, you have held broken packages.

user@hostname:~$ sudo apt-get install unixodbc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package unixodbc is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
odbcinst1debian2 odbcinst libodbc1

E: Package 'unixodbc' has no installation candidate

user@hostname:~$ sudo apt-get install odbcinst1debian2 odbcinst libodbc1
Reading package lists... Done
Building dependency tree
Reading state information... Done
libodbc1 is already the newest version (2.3.4-1.1ubuntu3).
odbcinst is already the newest version (2.3.4-1.1ubuntu3).
odbcinst1debian2 is already the newest version (2.3.4-1.1ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

odbcinst -j
unixODBC 2.3.4
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /home/user/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

dpkg-query -L libodbc1
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libodbc.so.2.0.0
/usr/lib/x86_64-linux-gnu/libodbccr.so.2.0.0
/usr/lib/x86_64-linux-gnu/odbc
/usr/lib/x86_64-linux-gnu/odbc/libnn.so
/usr/share
/usr/share/doc
/usr/share/doc/libodbc1
/usr/share/doc/libodbc1/NEWS.Debian.gz
/usr/share/doc/libodbc1/changelog.Debian.gz
/usr/share/doc/libodbc1/copyright
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/libodbc1
/usr/lib/x86_64-linux-gnu/libodbc.so.1
/usr/lib/x86_64-linux-gnu/libodbc.so.2
/usr/lib/x86_64-linux-gnu/libodbccr.so.1
/usr/lib/x86_64-linux-gnu/libodbccr.so.2

configuration

All 16 comments

I also attempted to download the .Deb file and use dpkg -i to install, but it threw the same error about missing unixodbc.

Hi @plabbett

It's unusual it said unixodbc not available... because it should be found in the standard repos. Perhaps the repos are somewhat messed up? Did you start with a clean env or was it an upgrade from an older one?

If you have customised your repo, it's possible that it was not overwritten with the one for 18.04.

Please uninstall everything ODBC driver / unixODBC to start from scratch and/or try again in a clean vm.

It was a clean install, adding in the ondrej PPA for Ubuntu. My sources.list has the typical sources in it. I will try another clean server and see which PPA breaks it I guess. Thanks, will report back.

deb http://archive.ubuntu.com/ubuntu bionic main
deb http://archive.ubuntu.com/ubuntu bionic-security main
deb http://archive.ubuntu.com/ubuntu bionic-updates main

Oh that explains it. Do not add the ondrej PPA because it comes with conflicting dependencies. Please read our notes in the link.

Yeah, I must have have read the first few sentences of that info box without groking the warning about conflict, especially since the Step 1 on that page shows adding in the ondrej PPA. Thanks for pointing it out!

Is there any way to do it while retaining the ondrej repo? I don't see php7.3 packages in the base 18.04 repo.

@benyanke we do plan to test that out very soon as PHP 7.3 is going to GA in about a week. Meanwhile, this page might have answered your questions.

Thanks @yitam - it looks like that link recommends the ondrej repo however. Is there any plans to have the PECL packages work well with the ondrej repo?

Yes @benyanke we will verify PECL install with the latest ondrej repo and if compatible, we will update our instructions accordingly. Rest assured this is of high priority.

Excellent. Thank you!

Where can I subscribe / watch to track this?

We will update our release page and instructions some time after PHP 7.3 GA so please stay tuned, @benyanke

@benyanke

Where can I subscribe / watch to track this?

FYI, please follow https://blogs.msdn.microsoft.com/sqlphp/

FYI, @benyanke
5.5.0-preview is published, and we welcome feedback.

Thanks for the notification @yitam . I look forward to now start updating my application to php 7.3.

For the help of anyone else who finds this, github also introduced a great new feature: watching only releases.

image

I've done this on this repo, and hopefully it's helpful to others as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Agares picture Agares  路  6Comments

sirio3mil picture sirio3mil  路  6Comments

adankert picture adankert  路  4Comments

Grglrglrg picture Grglrglrg  路  4Comments

naman-simform picture naman-simform  路  4Comments