Score:0

Installing sql server drivers for php on ubuntu

in flag

Background

I have an ubuntu server running laravel that needs to connect to a different server of ours running mssql.

Linux server:

  • Ubuntu 20.04
  • php 8.1

I created a laravel test query to help me debug the process. As expected it gave a could not find driver exception as expected.

Next I attempted to follow the Microsoft instructions. These are at:

Steps taken so far

  • sudo pecl install sqlsrv
  • sudo pecl install pdo_sqlsrv

I quickly sanity checked the next command: (printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.1/mods-available/sqlsrv.ini). However, this gave a problem. The sqlsrv.ini file did not exist.

To be clear: /etc/php/8.1/mods-available/sqlsrv.ini does not exist.

(.. and thus sudo phpenmod -v 8.1 sqlsrv pdo_sqlsrv obviously wont work)

I ran sudo pecl install pdo_sqlsrv to double check I hadn't missed anything, and it gave the error:

  • pecl/pdo_sqlsrv is already installed and is the same as the released version 5.10.1 install failed

Question

How do I either:

  • complete my php pdo_sqlsrv driver installation; OR
  • do it correctly from scratch

Many thanks

Romeo Ninov avatar
in flag
Edit the file with `vi` or your favorite text editor
elb98rm avatar
in flag
Which file do you mean? How will editing a file fix a missing driver? What should I edit?
Romeo Ninov avatar
in flag
`/etc/php/8.1/mods-available/sqlsrv.ini`
elb98rm avatar
in flag
I will try that now
Score:0
in flag

This came from me editing as sudo, rather than root.

in flag
To explain what happened: the command you called "sanity check" doesn't actually check anything, it creates the config file that is needed later. As you noticed, the output redirection is problematic when using sudo. How to work around that problem is explained for [example here](https://serverfault.com/questions/540492/sudo-echo-bla-etc-sysctl-conf-permission-denied).
Score:0
US flag
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.