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
- <source lang="bash">$ sudo sh -c 'curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo'</source>
- If the unixodbc-utf16 packages are already installed
- <source lang="bash">$ sudo yum remove unixODBC-utf16 unixODBC-utf16-devel</source>
- <source lang="bash">$ sudo ACCEPT_EULA=Y yum install msodbcsql unixODBC-devel</source>
- Install tools used for PECL
- <source lang="bash">$ sudo yum install php71w-devel php71w-pear</source>
- <source lang="bash">$ sudo yum groupinstall 'Development Tools'</source>
- 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.
- <source lang="bash">$ sudo pecl install sqlsrv</source>
- <source lang="bash">$ sudo pecl install pdo_sqlsrv</source>
- 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
- <source lang="bash">$ sudo sh -c 'echo "extension=sqlsrv.so" > /etc/php.d/sqlsrv.ini'</source>
- <source lang="bash">$ sudo sh -c 'echo "extension=pdo_sqlsrv.so" > /etc/php.d/pdo_sqlsrv.ini'</source>
- Restart PHP-FPM or Apache (whichever solution you're using.)
DBLIB/FreeTDS
- Install the module using Yum
- <source lang="bash">$ sudo yum install php71w-mssql</source>
- Restart PHP-FPM or Apache (whichever solution you're using.)