How to install and configure the connection to mssql in php8.2?

Post Reply
kziel
Posts: 5
Joined: Mon Jun 12, 2023 4:56 pm
Been thanked: 1 time

Hello, I want to connect to a mssql database but I don't know how to install and activate the extensions for myvesta, can someone please help me?
Last edited by kziel on Sat Jun 24, 2023 12:16 pm, edited 1 time in total.

Tags:
User avatar
myVesta
Site Admin
Posts: 949
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 9 times
Been thanked: 6 times

mysql or mssql?
in subject you wrote 'mysql'
kziel
Posts: 5
Joined: Mon Jun 12, 2023 4:56 pm
Been thanked: 1 time

myVesta wrote: Mon Jun 12, 2023 9:12 pm mysql or mssql?
in subject you wrote 'mysql'
I'm sorry I wrote mysql in the title, what I need is to connect to mssql.
User avatar
myVesta
Site Admin
Posts: 949
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 9 times
Been thanked: 6 times

We will assume you are already installed PHP 8.2.

Logged in as 'root', do the following:

Code: Select all

apt-get update
apt-get install -y php8.2-dev
apt-get install -y unixodbc-dev
sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' /etc/locale.gen
locale-gen
update-alternatives --set php /usr/bin/php8.2
pecl install sqlsrv
pecl install pdo_sqlsrv
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/8.2/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/8.2/mods-available/pdo_sqlsrv.ini
phpenmod -v 8.2 sqlsrv pdo_sqlsrv
systemctl restart php8.2-fpm
Based on tutorial from https://learn.microsoft.com/en-us/sql/c ... -on-debian
kziel
Posts: 5
Joined: Mon Jun 12, 2023 4:56 pm
Been thanked: 1 time

when i use pecl install sqlsrv i get the following error:

Code: Select all

WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-upd                                                                                                                                                             ate pecl.php.net" to update
downloading sqlsrv-5.11.0.tgz ...
Starting to download sqlsrv-5.11.0.tgz (192,671 bytes)
.........................................done: 192,671 bytes
34 source files, building
running: phpize
sh: 1: phpize: not found
ERROR: `phpize' failed
I am using the latest version of myvesta and I have php 8.2 installed.

Code: Select all

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/php8.2   82        auto mode
  1            /usr/bin/php5.6   56        manual mode
  2            /usr/bin/php7.2   72        manual mode
  3            /usr/bin/php7.4   74        manual mode
  4            /usr/bin/php8.1   81        manual mode
  5            /usr/bin/php8.2   82        manual mode
I've tried removing the rules from disable_functions and I still get the same error.
User avatar
myVesta
Site Admin
Posts: 949
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 9 times
Been thanked: 6 times

try:

Code: Select all

apt update
apt install -y php8.2-dev
kziel
Posts: 5
Joined: Mon Jun 12, 2023 4:56 pm
Been thanked: 1 time

myVesta wrote: Tue Jun 27, 2023 1:44 pm try:

Code: Select all

apt update
apt install -y php8.2-dev
After executing that command I had this error:
plat.h:30:10: fatal error: sql.h: No such file or directory
I corrected it with this:

Code: Select all

sudo apt-get install unixodbc-dev
Thank you very much for the help.
User avatar
myVesta
Site Admin
Posts: 949
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 9 times
Been thanked: 6 times

Thanks for the feedback, I added it to the manual.
kziel
Posts: 5
Joined: Mon Jun 12, 2023 4:56 pm
Been thanked: 1 time

I can see the content of a php file with mssql in the browser but I don't know why the database doesn't connect with remote ip.
I have tested it from Microsoft SQL Server Manager Studio, and I connect it to the database, it works, but it doesn't work from Vesta. I think something is missing in the web server.
Could you see what is missing to connect to a remote database please?
User avatar
myVesta
Site Admin
Posts: 949
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 9 times
Been thanked: 6 times

I don't have any idea how I can see it.
Do you have something in the error log of your domain?
Post Reply