SQLSRV PHP extension for Plesk PHP 7.4
Foreword
The PHP Microsoft SQL Extension (sqlsrv) can be used to establish a native MSSQL connection to a Microsoft SQL Server.
Before installing PHP extensions, a server snapshot should be created so that you can undo the installation with just a few clicks in the event of an error. Please read the following article: Server snapshots
Installation
Additional packages are required for the installation under PHP 7.4. These can be installed using the following SSH command:
apt install plesk-php74-dev apt-transport-https gcc g++ unixodbc unixodbc-dev make
Next, the msodbcsql17 package from Microsoft must be installed:
PHP 7.4
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg
curl https://packages.microsoft.com/config/debian/12/prod.list | tee /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get install msodbcsql17
The PHP extension SQLSRV must be installed for each PHP version:
PHP 7.4
/opt/plesk/php/7.4/bin/pecl install pdo_sqlsrv-5.10.1
echo "extension=pdo_sqlsrv.so" > /opt/plesk/php/7.4/etc/php.d/pdo_sqlsrv.ini
/opt/plesk/php/7.4/bin/pecl install sqlsrv-5.10.1
echo "extension=sqlsrv.so" > /opt/plesk/php/7.4/etc/php.d/sqlsrv.ini
To enable the new configuration via the Plesk web interface, the PHP handlers must be reinitialized:
plesk bin php_handler --reread
plesk sbin packagemng -sdf
The PHP handlers must then be restarted so that the SQLSRV extension can be used:
Warning: Restarting the PHP modules will terminate and restart all running PHP processes. If the installation is carried out on a production system, we recommend making this change at night.
systemctl restart plesk-php74-fpm