Skip to main content
LaravelUncategorized

How to install MSSQL extension of PHP in Ubuntu

To install the MSSQL extension for PHP on Ubuntu, you will need to follow these steps:

  1. Install the necessary dependencies:

Before you can install the MSSQL extension, you will need to install some dependencies that are required by the extension. Run the following command to install these dependencies:

sudo apt-get update
sudo apt-get install unixodbc-dev freetds-dev
  1. Install the MSSQL extension:

Next, you will need to install the MSSQL extension for PHP. You can do this using the pecl (PHP Extension Community Library) command. Run the following command to install the extension:

sudo pecl install sqlsrv
  1. Enable the MSSQL extension:

After the MSSQL extension is installed, you will need to enable it in your PHP configuration. To do this, open the “php.ini” file in a text editor and add the following line:

extension=sqlsrv.so
  1. Restart your web server:

After making these changes, you will need to restart your web server in order for the changes to take effect.

  1. Test the MSSQL extension:

To test that the MSSQL extension has been installed and enabled correctly, you can create a PHP file with the following code:

<?php
phpinfo();
?>

Run this PHP file in your web browser and look for the “sqlsrv” section. If this section is present, the MSSQL extension has been installed and enabled successfully.