Установка sqlsrv и pdo_sqlsrv на Ubuntu 18.04 для дополнительного php7.4

Путь до php необходимо прописать свой, в данном примере он /opt/php74

apt-get install curl
apt-get install autoconf
apt-get install gcc
apt-get install g++
apt-get install -y build-essential

curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
apt-get update

sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17
sudo ACCEPT_EULA=Y apt-get install -y mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
sudo apt-get install -y unixodbc-dev

sudo update-alternatives --set php /opt/php74/bin/php

sudo pecl config-set php_ini /opt/php74/etc/php.ini
sudo pecl config-set ext_dir /opt/php74/lib/php/modules/
sudo pecl config-set bin_dir /opt/php74/bin/
sudo pecl config-set php_bin /opt/php74/bin/php
sudo pecl config-set php_suffix 7.4

sudo ln -s /opt/php74/bin/phpize /usr/bin/phpize7.4

sudo /opt/php74/bin/pecl install sqlsrv
sudo /opt/php74/bin/pecl install pdo_sqlsrv

printf "; priority=20\nextension=sqlsrv.so\n" > /opt/php74/etc/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /opt/php74/etc/mods-available/pdo_sqlsrv.ini

#simple phpenmod
sudo ln -s /opt/php74/etc/mods-available/sqlsrv.ini /opt/php74/etc/php.d/20-sqlsrv.ini
sudo ln -s /opt/php74/etc/mods-available/pdo_sqlsrv.ini /opt/php74/etc/php.d/30-pdo_sqlsrv.ini
01.11.2021
SysPage.ru