Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jeremykenedy/f96ad57681b9212766ae55a0d7cc77e8 to your computer and use it in GitHub Desktop.
Save jeremykenedy/f96ad57681b9212766ae55a0d7cc77e8 to your computer and use it in GitHub Desktop.
SQL Server Driver Installer for Laravel Homestead
#!/bin/bash
# SQL Server Driver Installer for Laravel Homestead
#
# This script downloads, compiles, and installs the PHP 7 extension
# files for both the native sqlsrv and the PDO pdo_sqlsrv drivers.
# Get the Microsoft Driver Source Code from Github
cd ~
git clone https://github.com/Microsoft/msphpsql.git
cd msphpsql
git checkout PHP-7.0-Linux
# Run the ODBC Installer Script
sh ODBC\ install\ scripts/installodbc_ubuntu.sh
# Compile and Install the Native sqlsrv Driver
cd ~/msphpsql/source/sqlsrv
phpize && ./configure CXXFLAGS=-std=c++11 && make
sudo make install
sudo echo "extension=sqlsrv.so" | sudo tee /etc/php/7.0/mods-available/sqlsrv.ini
phpenmod sqlsrv
# Compile and Install the pdo_sqlsrv Driver
cd ~/msphpsql/source/pdo_sqlsrv
phpize && ./configure CXXFLAGS=-std=c++11 && make
sudo make install
sudo echo "extension=pdo_sqlsrv.so" | sudo tee /etc/php/7.0/mods-available/pdo_sqlsrv.ini
sudo phpenmod pdo_sqlsrv
# Restart the PHP-FPM Service
sudo systemctl restart php7.0-fpm.service
# Clean Up
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment