SQLServer

From DreamFactory
Jump to: navigation, search
Line 11: Line 11:
 
# Install tools used for PECL
 
# Install tools used for PECL
 
#* <source lang="bash">$ sudo yum install php71w-devel php71w-pear</source>
 
#* <source lang="bash">$ sudo yum install php71w-devel php71w-pear</source>
 +
# Update GCC
 +
#* <source lang="bash">$ sudo wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo</source>
 +
#* <source lang="bash">$ sudo yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++</source>
 +
# Configure PECL to use the newer GCC
 +
#* <source lang="bash">$ sudo pecl config-set bin_dir /opt/rh/devtoolset-2/root/usr/bin</source>
 
# Install sqlsrv and pdo_sqlsr using PECL
 
# 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.
 
#* sqlsrv on PECL is has been released from development to stable. As of the writing of these instructions, the latest verison 4.0.8.

Revision as of 17:15, 16 October 2017

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)
    • $ curl https://packages.microsoft.com/config/rhel/6/prod.repo | sudo tee /etc/yum.repos.d/mssql-tools.repo
    • sudo ACCEPT_EULA=Y yum install msodbcsql mssql-tools
    • sudo yum install unixODBC-devel
    • echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
    • echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
    • source ~/.bashrc
  2. Install tools used for PECL
    • $ sudo yum install php71w-devel php71w-pear
  3. Update GCC
    • $ sudo wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
    • $ sudo yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
  4. Configure PECL to use the newer GCC
    • $ sudo pecl config-set bin_dir /opt/rh/devtoolset-2/root/usr/bin
  5. 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
  6. 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'
  7. Enable the extensions in PHP
    • $ sudo phpenmod sqlsrv pdo_sqlsrv
  8. 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