Originally I chose php7.4, but after configuration, it kept prompting that the dynamic extension could not be loaded. Downgraded to php7.3.
After compiling and installing php7.3, do the following:
Join Microsoft’s source
curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssqlrelease.repo
You can find it at (https://packages.microsoft.com/config/rhel ), find the corresponding required version
Install the driver
#如果安装过,防止冲突可先卸载再安装 yum remove unixODBC yum install msodbcsql mssql-tools unixODBC-devel
Download the pdo_sqlsrv expansion package, and unzip it
wget http://pecl.php.net/get/pdo_sqlsrv-5.6.1.tgz tar -zxvf pdo_sqlsrv-5.6.1.tgz cd pdo_sqlsrv-5.6.1
Use Corresponding php version of phpize
/www/server/php/73/bin/phpize ./configure --with-php-config=/www/server/php/73/bin/php-config make && make install
Write extension
echo "extension = pdo_sqlsrv.so" >> /www/server/php/73/etc/php.ini /etc/init.d/php-fpm-73 reload
Check whether it is successful
/www/server/php/73/bin/php -m|grep -i sqlsrv
View all extensions
php -m
PS: Pay attention to your own PHP version. After installing PHP7.4 many times, it prompts that the dynamic extension cannot be loaded. I hope that successful experts can leave a comment.