CentOS and pdo_sqlsrv for PHP 7.2 - how to install (PLESK)

220 Views Asked by At

I am hosting a site that needs to connect to SQL Server.

My PHP 7.2 is missing pdo_sqlsrv - how to install it and make it work?

I was trying that solution: Centos 8, PHP 7.2 and MS Sql Server but pecl/sqlsrv requires PHP (version >= 8.0.0) and I need 7.2

1

There are 1 best solutions below

0
ButcherFromHell On

Install the msodbcsql package:

# curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
# yum remove unixODBC-utf16 unixODBC-utf16-devel
# ACCEPT_EULA=Y yum install msodbcsql18

Install necessary packages:

# yum install unixODBC-devel make gcc-c++ gcc autoconf automake plesk-php72-devel libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64

Add the pdo_sqlsrv and sqlsrv-5.8.1 modules:

# /opt/plesk/php/7.2/bin/pecl install pdo_sqlsrv-5.8.1
# echo "extension=pdo_sqlsrv.so" > /opt/plesk/php/7.2/etc/php.d/pdo_sqlsrv.ini
# /opt/plesk/php/7.2/bin/pecl install sqlsrv-5.8.1
# echo "extension=sqlsrv.so" > /opt/plesk/php/7.2/etc/php.d/sqlsrv.ini

Reread PHP handlers:

# plesk bin php_handler --reread

Reread the components properties to make modules visible in GUI:

# plesk sbin packagemng -sdf

Make sure that the required modules are enabled:

# /opt/plesk/php/X.X/bin/php -m | grep sqlsrv
pdo_sqlsrv
sqlsrv

Restart the PHP-FPM master process to apply changes to FPM sites

Solution from PLESK