I had a server set up with the following installed and running:
Ubuntu 20.04
NGINX 1.17.10
PHP 7.4.5
The PHP installation does have the PDO SQLSRV driver installed and working properly.
I needed to add PHP 5.6 to the same server for an older web site. I was able to successfully install PHP 5.6. but I can't seem to get the SQLSRV driver part to install properly.
I had previously installed the mssql tools on the server when setting up PHP 7.4:
apt-get install msodbcsql17 -y
apt-get install mssql-tools
apt install unixodbc-dev
pecl install sqlsrv
pecl install pdo_sqlsrv
In trying to set it up for 5.6, I did follow the steps for the original install. I ran the following commands:
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/5.6/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/5.6/mods-available/pdo_sqlsrv.ini
phpenmod -v 5.6 sqlsrv pdo_sqlsrv
pecl config-set php_ini /etc/php/5.6/fpm/php.ini
ls /etc/php/5.6/fpm/conf.d/*sqlsrv.ini
All commands ran successfully. I then added the following lines to the relevant php.ini file /etc/php/5.6/fpm/php.ini
extension=sqlsrv.so
extension=pdo_sqlsrv.so
I reloaded and restarted php5.6-fpm and then restarted NGINX. PHP 5.6 is successfully installed and I can see the info by running phpinfo(). I got no errors during installation. However, under PDO, PDO Drivers is showing no value. I also confirmed that sqlsrv_connect is not recognized.
I know it would be ideal not to have multiple versions of PHP or to have installed them at separate times, but I didn't have a choice on this project. Do I need to install a separate version of sqlsrv and pdo_sqlsrv on the box, or am I just missing something in the installation?