Instructions for installation of MsSQL extension for PHP 7

CentOS 6

curl https://packages.microsoft.com/config/rhel/6/prod.repo > /etc/yum.repos.d/mssql-release.repo
yum clean all
yum update -y
ACCEPT_EULA=Y yum install -y msodbcsql mssql-tools unixODBC-devel 
cd /usr/local/src
rm -rf sqlsrv* pdo*
wget https://pecl.php.net/get/sqlsrv-4.3.0.tgz
tar -zxvf sqlsrv-4.3.0.tgz
cd sqlsrv-4.3.0
phpize
./configure
make
make install
echo ""
grep "sqlsrv.so" /usr/local/php/php.ini || echo "extension=sqlsrv.so" >> /usr/local/php/php.ini
cd /usr/local/src
wget https://pecl.php.net/get/pdo_sqlsrv-4.3.0.tgz
tar -zxvf pdo_sqlsrv-4.3.0.tgz
cd pdo_sqlsrv-4.3.0
phpize
./configure
make
make install
echo ""
grep "pdo_sqlsrv.so" /usr/local/php/php.ini || echo "extension=pdo_sqlsrv.so" >> /usr/local/php/php.ini
rm -rf sqlsrv* pdo*

CentOS 7

curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
yum clean all
yum update -y
ACCEPT_EULA=Y yum install -y msodbcsql mssql-tools unixODBC-devel 
cd /usr/local/src
rm -rf sqlsrv* pdo*
wget https://pecl.php.net/get/sqlsrv-4.3.0.tgz
tar -zxvf sqlsrv-4.3.0.tgz
cd sqlsrv-4.3.0
phpize
./configure
make
make install
echo ""
grep "sqlsrv.so" /usr/local/php/php.ini || echo "extension=sqlsrv.so" >> /usr/local/php/php.ini
cd /usr/local/src
wget https://pecl.php.net/get/pdo_sqlsrv-4.3.0.tgz
tar -zxvf pdo_sqlsrv-4.3.0.tgz
cd pdo_sqlsrv-4.3.0
phpize
./configure
make
make install
echo ""
grep "pdo_sqlsrv.so" /usr/local/php/php.ini || echo "extension=pdo_sqlsrv.so" >> /usr/local/php/php.ini
rm -rf sqlsrv* pdo*

Tagged: