SQLServer CentOS 7
From DreamFactory
There are two different drivers you can use to connect to Microsoft SQL. We highly recommend the sqlsrv driver over dblib/freetds. However dblib/freetds is still supported.
SQLSRV
Note: These instructions were adapted from the official Microsoft PHP SQLSRV repo on Github[1]. Please consult this repo for additional information about this driver and its implementation options.
- Install the ODBC 13 Driver
-
$ sudo sh -c 'curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo'
- If the unixodbc-utf16 packages are already installed
-
$ sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
-
-
$ sudo ACCEPT_EULA=Y yum install msodbcsql unixODBC-devel
-
- Install tools used for PECL
-
$ sudo yum install php71w-devel php71w-pear
-
$ sudo yum groupinstall 'Development Tools'
-
- Install sqlsrv and pdo_sqlsr using PECL
- sqlsrv on PECL is has been released from development to stable. As of the writing of these instructions, the latest verison 4.3.0.
-
$ sudo pecl install sqlsrv
-
$ sudo pecl install pdo_sqlsrv
-
- sqlsrv on PECL is has been released from development to stable. As of the writing of these instructions, the latest verison 4.3.0.
- Create the ini files
-
$ sudo sh -c 'echo "extension=sqlsrv.so" > /etc/php.d/sqlsrv.ini'
-
$ sudo sh -c 'echo "extension=pdo_sqlsrv.so" > /etc/php.d/pdo_sqlsrv.ini'
-
- Restart PHP-FPM or Apache (whichever solution you're using.)
DBLIB/FreeTDS
- Install the module using Yum
-
$ sudo yum install php71w-mssql
-
- Restart PHP-FPM or Apache (whichever solution you're using.)