SQLServer

From DreamFactory
Jump to: navigation, search
(SQLSRV)
Line 9: Line 9:
 
#* <source lang="bash">$ sudo apt-get install php-dev php-pear</source>
 
#* <source lang="bash">$ sudo apt-get install php-dev php-pear</source>
 
# Install sqlsrv and pdo_sqlsr using PECL
 
# Install sqlsrv and pdo_sqlsr using PECL
#* Find the right version number
+
#* 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 still listed as under development so you have to specify the version number. You can get this using the below command. As of the writing of these instructions, the latest verison 4.0.6.
+
#** <source lang="bash">$ sudo pecl install sqlsv</source>
#** <source lang="bash">$ pecl search sqlsrv</source>
+
#* Install the drivers (use the version number acquired via the previous command)
+
#** <source lang="bash">$ sudo pecl install pdo_sqlsrv-4.0.6</source>
+
#** <source lang="bash">$ sudo pecl install sqlsv-4.0.6</source>
+
 
# Enable the drivers in PHP
 
# Enable the drivers in PHP
 
#* <source lang="bash">$ sudo nano /etc/php/7.0/mods-available/pdo_sqlsrv.ini</source>
 
#* <source lang="bash">$ sudo nano /etc/php/7.0/mods-available/pdo_sqlsrv.ini</source>
Line 22: Line 18:
 
#** Edit the file so it reads: <code>extension=sqlsrv.so</code>
 
#** Edit the file so it reads: <code>extension=sqlsrv.so</code>
 
#** Save and exit the file
 
#** Save and exit the file
 +
#* <source lang="bash">$ sudo phpenmod sqlsrv</source>
 
# Restart the PHP-FPM and Nginx or Restart Apache (whichever solution you're using.)
 
# Restart the PHP-FPM and Nginx or Restart Apache (whichever solution you're using.)
 
#* Nginx
 
#* Nginx

Revision as of 16:27, 6 January 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

  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 php-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 sqlsv
  4. Enable the drivers in PHP
    • $ sudo nano /etc/php/7.0/mods-available/pdo_sqlsrv.ini
      • Edit the file so it reads: extension=pdo_sqlsrv.so
      • Save and exit the file
    • $ sudo nano /etc/php/7.0/mods-available/sqlsrv.ini
      • Edit the file so it reads: extension=sqlsrv.so
      • Save and exit the file
    • $ sudo phpenmod sqlsrv
  5. Restart the PHP-FPM and Nginx or Restart Apache (whichever solution you're using.)
    • Nginx
      • $ sudo service php7.0-fpm restart && sudo service nginx restart
    • Apache
      • $ sudo  service apache2 restart

DBLIB/FreeTDS

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