install ms sql pdo in php

To install the Microsoft SQL Server PDO driver for PHP, follow these steps:

  1. Make sure you have the SQL Server PDO driver libraries installed on your system. On Ubuntu, you can install them using the following command:
main.php
sudo apt-get install php7.2-sybase  # for PHP 7.2
50 chars
2 lines
  1. You will also need FreeTDS installed. On Ubuntu, you can install it using the following command:
main.php
sudo apt-get install freetds-common freetds-bin unixodbc php7.2-odbc  # for PHP 7.2
84 chars
2 lines
  1. Once the prerequisites are installed, you can enable the ms sql pdo extension in the php.ini file. Locate your php.ini file and add the following line:
main.php
extension=pdo_sqlsrv.so
extension=sqlsrv.so
44 chars
3 lines
  1. Restart your web server for the changes to take effect.

You can verify that the driver is installed and enabled by running the following command:

main.php
php -m | grep pdo_sqlsrv
25 chars
2 lines

If the driver is installed and enabled, you should see pdo_sqlsrv in the list of installed modules.

gistlibby LogSnag