-
-
Save labmorales/2cc6f9ab3006716fa3b55164e09300ad to your computer and use it in GitHub Desktop.
Install Official MSSQL driver for Unbuntu 14.04 - pdo_sqlsrv
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 | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
sudo apt-get update | |
sudo -i export CPPFLAGS="-DSIZEOF_LONG_INT=8" | |
sudo apt-get -y install gcc-5 g++-5 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5 | |
cd ~ | |
echo "Configuring the unixODBC 2.3.1 Driver Manager" | |
wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.1.tar.gz | |
tar -xzf unixODBC-2.3.1.tar.gz | |
cd unixODBC-2.3.1/ | |
./configure --prefix=/usr --libdir=/usr/lib64 --sysconfdir=/etc --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-iconv-ucode-enc=UTF16LE 1> odbc_con.log 2> make_err.log | |
echo "Building and Installing the unixODBC 2.3.1 Driver Manager" | |
sudo make 1> make_std.log 2> make_err.log | |
sudo make install 1> makeinstall_std.log 2> makeinstall_err.log | |
cd ~ | |
echo "Downloading the Microsoft ODBC Driver 13 for SQL Server - Ubuntu" | |
wget "https://meetsstorenew.blob.core.windows.net/contianerhd/Ubuntu%2013.0%20Tar/msodbcsql-13.0.0.0.tar.gz?st=2016-10-18T17%3A29%3A00Z&se=2022-10-19T17%3A29%3A00Z&sp=rl&sv=2015-04-05&sr=b&sig=cDwPfrouVeIQf0vi%2BnKt%2BzX8Z8caIYvRCmicDL5oknY%3D" -O msodbcsql-13.0.0.0.tar.gz | |
tar -xzf msodbcsql-13.0.0.0.tar.gz | |
cd msodbcsql-13.0.0.0/ | |
echo "Installing Dependencies" | |
sudo apt-get -y install libssl1.0.0 | |
sudo apt-get -y install libgss3 | |
sudo echo "/usr/lib64" >> /etc/ld.so.conf | |
sudo ldconfig | |
echo "Installing the Microsoft ODBC Driver 13 for SQL Server - Ubuntu" | |
sudo bash ./install.sh install --force --accept-license | |
cd ~ | |
echo "Compiling PHP driver" | |
sudo apt-get -y install php7.0-dev | |
wget https://github.com/Microsoft/msphpsql/archive/4.0.6-Linux.tar.gz | |
tar -xzf 4.0.6-Linux.tar.gz | |
cd msphpsql-4.0.6-Linux/source/pdo_sqlsrv/ | |
phpize && ./configure CXXFLAGS=-std=c++11 && make | |
sudo make install | |
echo "Enabling Driver for php7.0-fpm and CLI" | |
sudo bash -c 'echo -e "; configuration for php common module \n; priority=10 \nextension=pdo_sqlsrv.so" > /etc/php/7.0/mods-available/pdo_sqlsrv.ini' | |
sudo ln -s /etc/php/7.0/mods-available/pdo_sqlsrv.ini /etc/php/7.0/fpm/conf.d/20-pdo_sqlsrv.ini | |
sudo ln -s /etc/php/7.0/mods-available/pdo_sqlsrv.ini /etc/php/7.0/cli/conf.d/20-pdo_sqlsrv.ini | |
cd ~ | |
echo "Cleaning up.." | |
sudo rm -rf msphpsql-4.0.6-Linux/ | |
sudo rm -rf unixODBC-2.3.1/ | |
sudo rm -rf msodbcsql-13.0.0.0/ | |
sudo rm 4.0.6-Linux.tar.gz | |
sudo rm msodbcsql-13.0.0.0.tar.gz | |
sudo rm unixODBC-2.3.1.tar.gz | |
echo "All done, please be sure to test via the CLI & restart php7.0-fpm once complete." | |
php -i | grep 'PDO drivers' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! Saved my day! =)