Problem: Need to setup SQLSRV for multiple version of PHP on dev server so that connection to SQL Server can be established using PHP.

Install Microsoft ODBC 17

sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -

Download package for Ubuntu 18.04

curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
sudo apt-get install unixodbc-dev

Download and configure driver for PHP 7.4

sudo apt-get -y install php-pear php7.4-dev
sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set phar /usr/bin/phar7.4
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4

sudo pecl uninstall -r sqlsrv 
sudo pecl uninstall -r pdo_sqlsrv 
sudo pecl -d php_suffix=7.4 install sqlsrv
sudo pecl -d php_suffix=7.4 install pdo_sqlsrv
sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.4/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.4/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -v 7.4 sqlsrv pdo_sqlsrv
sudo service apache2 restart

Download and configure driver for PHP 7.3

sudo apt-get -y install php-pear php7.3-dev
sudo update-alternatives --set php /usr/bin/php7.3
sudo update-alternatives --set phar /usr/bin/phar7.3
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.3
sudo update-alternatives --set phpize /usr/bin/phpize7.3
sudo update-alternatives --set php-config /usr/bin/php-config7.3

sudo pecl uninstall -r sqlsrv 
sudo pecl uninstall -r pdo_sqlsrv 
sudo pecl -d php_suffix=7.3 install sqlsrv
sudo pecl -d php_suffix=7.3 install pdo_sqlsrv
sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.3/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.3/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -v 7.3 sqlsrv pdo_sqlsrv
sudo service apache2 restart

Download and configure driver for PHP 7.2

sudo apt-get -y install php-pear php7.2-dev
sudo update-alternatives --set php /usr/bin/php7.2
sudo update-alternatives --set phar /usr/bin/phar7.2
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.2
sudo update-alternatives --set phpize /usr/bin/phpize7.2
sudo update-alternatives --set php-config /usr/bin/php-config7.2

sudo pecl uninstall -r sqlsrv 
sudo pecl uninstall -r pdo_sqlsrv 
sudo pecl -d php_suffix=7.2 install sqlsrv
sudo pecl -d php_suffix=7.2 install pdo_sqlsrv
sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.2/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.2/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -v 7.2 sqlsrv pdo_sqlsrv
sudo service apache2 restart