Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sin_Ester's avatar

SQL Server Drivers not working in forge linux ubuntu 22.04.02

Hi everyone! I'm new to linux I am trying to install sqlsrv driver for my server running on ubuntu 22.04.02. I am running PHP 8.1 and laravel 9.19. I can't seem to make the installation work. I followed this tutorial I found. waaz.xyz/adding-microsoft-sql-server-support-to-laravel-forge/

I also followed the official microsoft one but gives the same error. learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver16

for some reason it throws an error in sudo ACCEPT_EULA=Y apt-get install msodbcsql17

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
msodbcsql17 is already the newest version (17.10.2.1-1).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 freetds-bin : Depends: libodbc2 (>= 2.3.1) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

after that I run sudo apt-get install unixodbc-dev It returns this

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
unixodbc-dev is already the newest version (2.3.11-1).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 freetds-bin : Depends: libodbc2 (>= 2.3.1) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

After that I run sudo pecl install sqlsrv pdo_sqlsrv But gets this error.

libtool: warning: library '/usr/lib/x86_64-linux-gnu/libodbc.la' was moved.
libtool: warning: library '/usr/lib/x86_64-linux-gnu/libodbcinst.la' was moved.
libtool: link: cc -shared  -fPIC -DPIC  .libs/conn.o .libs/util.o .libs/init.o .libs/stmt.o shared/.libs/core_conn.o shared/.libs/core_results.o shared/.libs/core_stream.o shared/.libs/core_init.o shared/.libs/core_stmt.o shared/.libs/core_util.o shared/.libs/FormattedPrint.o shared/.libs/localizationimpl.o shared/.libs/StringFunctions.o   -lstdc++ /usr/lib/x86_64-linux-gnu/libodbc.so /usr/lib/x86_64-linux-gnu/libodbcinst.so  -g -O2 -Wl,-z -Wl,now   -pthread -Wl,-soname -Wl,sqlsrv.so -o .libs/sqlsrv.so
/usr/bin/sed: can't read /usr/lib/x86_64-linux-gnu/libltdl.la: No such file or directory
libtool:   error: '/usr/lib/x86_64-linux-gnu/libltdl.la' is not a valid libtool archive
make: *** [Makefile:249: sqlsrv.la] Error 1
ERROR: `make' failed

after running those these commands fails

sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.1/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.1/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -v 8.1 sqlsrv pdo_sqlsrv

I searched for hours in the internet but can't find a way to fix it so maybe it's unique to how forge sets the server (I don't know). I'm totally lost.

0 likes
3 replies
Sin_Ester's avatar

By the way I also followed this one learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver16

but it also gives the same errors

lwohlhart's avatar

The github issue comment seems to be the current solution: (https://github.com/microsoft/msphpsql/issues/1438#issuecomment-1444773949)

ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev && \
pecl install sqlsrv pdo_sqlsrv || \
apt-get install -y --allow-downgrades odbcinst=2.3.7 odbcinst1debian2=2.3.7 unixodbc=2.3.7 unixodbc-dev=2.3.7 && \
pecl install sqlsrv pdo_sqlsrv

Downgrade unixodbc and dependencies to version 2.3.7 which still have the file

Please or to participate in this conversation.