This article is about the installation of php and php-fpm using yum, the path to the relevant configuration file may not be the same as the environment of the gods (find the relevant configuration file according to your own environment).
Add the pdo_sqlsrv.so extension to the /etc/php.ini configuration file.
extension=pdo.so extension=pdo_sqlsrv.so
pdo_sqlsrv.so is a sqlserver extension and needs to be loaded before the pdo.so extension, otherwise the following error will occur
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_sqlsrv.so' - /usr/lib64/php/modules/pdo_sqlsrv.so: undefined symbol: php_pdo_register_driver in Unknown on line 0
Restart the php-fpm service
$ systemctl restart php-fpm
IV. Verify that the extension is installed correctly
Verify that the extension is successfully installed
$ php -m | grep pdo_sqlsrv
Here you can see that the pdo_sqlsrv extension has been added to php.
But then there is a PHP Warning: Module 'PDO' already loaded in Unknown on line 0 Warning message.
After some troubleshooting, I found that the pdo.so extension is also referenced in the /etc/php.d/pdo.ini configuration file.
Comment out the pdo.so extension referenced in /etc/php.d/pdo.ini and leave only the extension in /etc/php.ini.
After commenting, restart php-fpm and recheck the php extensions, and the Warning message will not appear.