0

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

elb98rm
  • 103
  • 1
  • 4

2 Answers2

0

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

elb98rm
  • 103
  • 1
  • 4
  • 2
    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). – Gerald Schneider Nov 27 '22 at 06:40
0

Perhaps this script will help you: https://gist.github.com/leidison/e62f7899d54923c32744bb69704524a4