SQLServer-CentOS 6

From DreamFactory
Jump to: navigation, search

There are two different drivers you can use to connect to Microsoft SQL. We 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.

  1. Install the ODBC 13 Driver (only support on Ubuntu 15 and 16)
    • $ sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/mssql-ubuntu-xenial-release/ xenial main" > /etc/apt/sources.list.d/mssqlpreview.list'
    • $ sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
    • $ sudo apt-get update
    • $ sudo apt-get install msodbcsql unixodbc-dev-utf16
  2. Install tools used for PECL
    • $ sudo apt-get install php7.1-dev php-pear
  3. 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.0.8.
      • $ sudo pecl install sqlsrv
      • $ sudo pecl install pdo_sqlsrv
  4. Create the ini files
    • $ sudo sh -c 'echo "extension=sqlsrv.so" > /etc/php/7.1/mods-available/sqlsrv.ini'
    • $ sudo sh -c 'echo "extension=pdo_sqlsrv.so" > /etc/php/7.1/mods-available/pdo_sqlsrv.ini'
  5. Enable the extensions in PHP
    • $ sudo phpenmod sqlsrv pdo_sqlsrv
  6. Restart the PHP-FPM and Nginx or Restart Apache (whichever solution you're using.)
    • Nginx
      • $ sudo service php7.1-fpm restart && sudo service nginx restart
    • Apache
      • $ sudo  service apache2 restart

DBLIB/FreeTDS

  1. Install the module using Apt
    • $ sudo apt-get install php7.1-sybase
  2. Restart the PHP-FPM and Nginx or Restart Apache (whichever solution you're using.)
    • Nginx
      • $ sudo service php7.1-fpm restart && sudo service nginx restart
    • Apache
      • $ sudo  service apache2 restart