Pdo_sqlsrv and pdo_odbc

Hi guys, I am using Debian 12 and just installed HestiaCP.

How to install pdo_odbc and pdo_sqlsrv for php 8.3 to send queries to mssql from Laravel application?

Thanks for you time! I really appreciate

apt install php8.3-odbc php8.3-sqlsrv

1 Like

root@host:~# apt install php8.3-odbc php8.3-sqlsrv
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
E: Unable to locate package php8.3-sqlsrv
E: Couldn’t find any package by glob ‘php8.3-sqlsrv’
root@host:~#
root@host:~#
root@host:~#

To install sqlsrv you should follow the instructions on this page (Steps 2 and 3):

Note: I’ve never installed them nor will try to do it.

1 Like

sudo: pecl: command not found

You must install php-pear

1 Like

root@host:~# sudo pecl install sqlsrv
WARNING: channel “pecl.php.net” has updated its protocols, use “pecl channel-update pecl.php.net” to update
downloading sqlsrv-5.12.0.tgz …
Starting to download sqlsrv-5.12.0.tgz (193,767 bytes)
…done: 193,767 bytes
34 source files, building
running: phpize
sh: 1: phpize: not found
ERROR: `phpize’ failed

Change php8.2-dev by the php version you are using.

sudo apt install php-pear gcc make autoconf libc-dev pkg-config libreadline-dev php8.2-dev
sudo pecl channel-update pecl.php.net
1 Like

anyway

root@host:~# sudo pecl install sqlsrv
WARNING: channel “pecl.php.net” has updated its protocols, use “pecl channel-update pecl.php.net” to update
downloading sqlsrv-5.12.0.tgz …
Starting to download sqlsrv-5.12.0.tgz (193,767 bytes)
…done: 193,767 bytes
34 source files, building
running: phpize
sh: 1: phpize: not found
ERROR: `phpize’ failed

As I said above:

This is solved using:

sudo pecl channel-update pecl.php.net

This is solved installing the dev package for the php version you are using on your system.

sudo apt install php-pear gcc make autoconf libc-dev pkg-config libreadline-dev php8.2-dev
1 Like

Anyway

Starting to download sqlsrv-5.12.0.tgz (193,767 bytes)
…done: 193,767 bytes
34 source files, building
running: phpize
sh: 1: phpize: not found
ERROR: `phpize’ failed

Also for some reason in the Hestia settings I can’t make 8.3 php primary. In general settings → server. 8.2 is displayed last, although I have 8.3 as well

But are you installing the php dev package for your default php version?

php -v
1 Like

PHP 8.2.22 (cli) (built: Aug 2 2024 16:01:44) (NTS)

But i am using 8.3 for my Laravel app

use php8.3 instead

1 Like
sed -i '/^\t"php-8.2",/a \\t"php-8.3",' /usr/local/hestia/web/edit/server/index.php
v-change-sys-php 8.3
1 Like

root@host:~# sed -i ‘/^\t"php-8.2",/a \t"php-8.3",’ /usr/local/hestia/web/edit/server/index.php
root@host:~# v-change-sys-php 8.3
update-alternatives: using /usr/bin/php8.3 to provide /usr/bin/php (php) in manual mode
root@host:~#

root@host:~# sudo pecl install sqlsrv
downloading sqlsrv-5.12.0.tgz …
Starting to download sqlsrv-5.12.0.tgz (193,767 bytes)
…done: 193,767 bytes
34 source files, building
running: phpize
sh: 1: phpize: not found
ERROR: `phpize’ failed
root@host:~# php -v
PHP 8.3.10 (cli) (built: Aug 2 2024 16:00:00) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.10, Copyright (c) Zend Technologies
with Zend OPcache v8.3.10, Copyright (c), by Zend Technologies
root@host:~#

The last commands configured php 8.3 as your default version,

Did you install php8.3-dev ?

sudo apt install php-pear gcc make autoconf libc-dev pkg-config libreadline-dev php8.3-dev
1 Like

Thank your sir.

Guys, can you tell me what is the correct path if i’m not use apache2?

I’m talking about this:

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

just /etc/php?