Last active
June 6, 2019 11:02
-
-
Save soup-bowl/d00254603a7ef007551fb2be90495c4f to your computer and use it in GitHub Desktop.
Microsoft SQL Server driver installer for Local by Flywheel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
_DEB_VER=8 | |
_MSSQL_VER=5.6.1 | |
_PHP_VER=7.2 | |
# Grab dependencies, then add Microsoft repo and grab further dependencies. | |
apt-get -q update | |
apt-get install -qy curl apt-transport-https wget gnupg build-essential autoconf pkg-config | |
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - | |
curl https://packages.microsoft.com/config/debian/$_DEB_VER/prod.list | tee --append /etc/apt/sources.list.d/mssql-release.list | |
apt-get -q update | |
ACCEPT_EULA=Y apt-get install msodbcsql17 -qy | |
apt-get install -qy unixodbc unixodbc-dev | |
# Grab and unpack the PECL SQL Server extensions. | |
mkdir app/sql /app/sql/sqlsrv /app/sql/pdo_sqlsrv | |
curl https://pecl.php.net/get/sqlsrv-$_MSSQL_VER.tgz -o /app/sql/sqlsrv.tgz | |
curl https://pecl.php.net/get/pdo_sqlsrv-$_MSSQL_VER.tgz -o /app/sql/pdo_sqlsrv.tgz | |
tar -zxf /app/sql/sqlsrv.tgz -C /app/sql/sqlsrv | |
tar -zxf /app/sql/pdo_sqlsrv.tgz -C /app/sql/pdo_sqlsrv | |
# Install into the current PHP installation. | |
cd app/sql/sqlsrv/*/ | |
/opt/php/$_PHP_VER*/bin/phpize | |
./configure --with-php-config=/opt/php/$_PHP_VER*/bin/php-config | |
make -s | |
make install | |
cd app/sql/pdo_sqlsrv/*/ | |
/opt/php/$_PHP_VER*/bin/phpize | |
./configure --with-php-config=/opt/php/$_PHP_VER*/bin/php-config | |
make -s | |
make install | |
# Clean up | |
rm -r /app/sql | |
# Add to php.ini if desired, and restart Apache. | |
if [[ $1 = '--append' ]]; then | |
printf '\nextension = sqlsrv.so\nextension = pdo_sqlsrv.so\n' >> /conf/php/$_PHP_VER*/php.ini | |
else | |
echo '' | |
echo 'Add the following to your conf/php/X.X.X/php.ini file:' | |
echo '[sqlsrv]' | |
echo 'extension = sqlsrv.so' | |
echo '[pdo_sqlsrv]' | |
echo 'extension = pdo_sqlsrv.so' | |
echo '' | |
echo 'Afterwards, run php -m to see if they have been enabled.' | |
fi | |
echo 'Installation completed. Please restart the container.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
More info:
--append
to automatically modify your php.ini file and enable it.site/app
, and execute by opening SSH and running/app/install-mssql.sh
.