2

I'm excited to see the release of 18.04.

My build needs the ability to connect to a MSSQL server running on Ubuntu 18.04 via PHP.

Has a repo been released for mssql-server on this version of Ubuntu?

unhammer
  • 2,321
  • I'm voting to close the question as the question itself is unrelated to Ubuntu. This is about MSSQL, PHP, and creating connections between them, not about anything that's Ubuntu-specific. – code_dredd Apr 29 '18 at 04:11
  • Ok, I see my ranking numbers are declining and the only comment I get is how my question is not about Ubuntu. I beg to differ, my question is about Ubuntu – Dennis W. Watson May 02 '18 at 22:56
  • You're basically asking how to use PHP to connect to a MSSQL database/server. While I understand PHP is running from an Ubuntu box, that detail seems tangential and not relevant to the actual question. Can you edit the question and make the Ubuntu-specific parts more explicit then? – code_dredd May 02 '18 at 23:00
  • I will be using this as a LAMP server in a professional environment in which I need communication with MSSQL via PHP using version 18.04. I have easily found this information in earlier versions and I am just wanting to upgrade to the latest. If this is not the proper forum to ask questions on how to properly configure installations of Ubuntu, please tell me where else I can post this question where I may expect a response from people using 18.04 who have also encountered this problem. – Dennis W. Watson May 02 '18 at 23:22
  • I'm trying to help you out, but I still don't see what the Ubuntu-specific part is. Just saying that you're writing the PHP code in an Ubuntu machine doesn't seem to make a difference, unless there's something specific to Ubuntu, rather than PHP, that's really getting in your way. The way this question is worded, it could be summarized as follows: "How can my PHP script connect to a MSSQL database?" Given that PHP is independent of any OS like Ubuntu, Windows, etc, the detail about running in Ubuntu makes no difference. Please edit the question to specify what's specific to Ubuntu. – code_dredd May 02 '18 at 23:50

1 Answers1

3

https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-linux-2017 so far only mentions 16.04.

The mssql-server package from the repo there works fine in Ubuntus up to 17.10, but after 18.04 it no longer installs due to outdated dependencies.

But we can still install and run it :-) First we add the repo:

$ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
$ echo 'deb [arch=amd64] https://packages.microsoft.com/ubuntu/16.04/mssql-server-2017 xenial main' | sudo tee -a /etc/apt/sources.list.d/mssql-server.list

Then we install the dependencies:

$ sudo apt install openssl1.0 libcurl4 libjemalloc2 libc++1 libsss-nss-idmap0 libc++abi1
$ # Mark them as dependencies so they're autoremoved if you remove mssql-server:
$ sudo apt-mark auto openssl1.0 libcurl4 libjemalloc2 libc++1 libsss-nss-idmap0 libc++abi1

Then we fix the dependency list in the .deb to specify openssl1.0 instead of openssl:

$ mkdir tmp && cd tmp
$ sudo apt download mssql-server
$ ar x mssql-server_14.0.3025.34-3_amd64.deb
$ emacs -Q control.tar.gz

In Emacs:

  1. click the file control in the file listing
  2. edit the line starting with "Depends" to say openssl1.0 instead of openssl (note: it's mentioned two places in the same line),
  3. edit the line starting with "Depends" to say libjemalloc2 instead of libjemalloc1,
  4. then click Save and then the X to the left of Save,
  5. then also click Save in the file listing,
  6. then exit (File→Quit).

Then we repack the archive under a new name and install it:

$ # Note: order of arguments matters here:
$ ar rcs mssql-server_14.0.3025.34-3fixed_amd64.deb debian-binary control.tar.gz data.tar.xz
$ sudo dpkg -i mssql-server_14.0.3025.34-3fixed_amd64.deb

Now just continue from step 4 (mssql-conf setup) of https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-linux-2017 and you should be able to test your connection with e.g. sqsh or tsql.


EDIT: I've got my current script for doing this on Ubuntu 19.10 here: https://gist.github.com/unhammer/6bff7adabb98e581508c042dc1fb9914

unhammer
  • 2,321
  • 1
    Thank you this was helpful. In my case I needed to change openssl AND libcurl3 to libcurl4. I haven't gotten too far, just did the "mssql-conf setup", but so far no problems... Will report back if I find something broken. – Adam Plocher May 15 '18 at 10:52
  • Ah, yeah, it seems libcurl3 and libcurl4 are in conflict, and packages like curl ǹow depend on libcurl4. I'll update the answer. – unhammer May 15 '18 at 13:39
  • Ok, so interestingly, today I boot up and mssql was gone again and this time i have libcurl3 installed instead of 4. Meaning my deb file is broken again (just changed it back to requiring libcurl3 and is working now again). Yesterday I switched a few of my apps to using the ppa's instead of the ubuntu releases and I enabled the experimental apt repo - something in there changed my system to use libcurl3. So, seems some people might have one, some might have the other :) – Adam Plocher May 17 '18 at 04:42
  • Thank you very much for your answer, this is what I was looking for. After Ray commented on my post to have it removed due to the fact I was not using proper semantics in my question, I felt I had no help in getting any answers, I came to the conclusion that 18.04 was not ready for "Prime-Time" and so built in 16.04.  Since you commented I may recompile and try again.  Thanks again for your help. – Dennis W. Watson Jun 01 '18 at 14:45