Skip to content

Day 2 Solution

#https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017

apt-get install update

add-apt-repository ppa:ondrej/php -y
apt-get update
apt-get install php7.2 php7.2-dev php7.2-xml -y –allow-unauthenticated

apt-get install gnupg gnupg2 gnupg1
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add –
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list

apt-get update
ACCEPT_EULA=Y apt-get install msodbcsql17
ACCEPT_EULA=Y apt-get install mssql-tools

echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bash_profile
echo ‘export PATH=”$PATH:/opt/mssql-tools/bin”‘ >> ~/.bashrc
source ~/.bashrc

apt install -y unixodbc-utf16 unixodbc-dev-utf16 2> /dev/null
sudo apt-get install php-pear
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv

#had to modify the location
phpini=”/usr/local/lib/php.ini”

echo “” >> $phpini
echo “# Extensions for Microsoft SQL Server Driver” >> $phpini
echo “extension=sqlsrv.so” >> $phpini
echo “extension=pdo_sqlsrv.so” >> $phpini
echo “” >> $phpini

#I didn’t had CLI?!
#phpini=”/etc/php/7.2/cli/php.ini”

#echo “” >> $phpini
#echo “# Extensions for Microsoft SQL Server Driver” >> $phpini
#echo “extension=sqlsrv.so” >> $phpini
#echo “extension=pdo_sqlsrv.so” >> $phpini
#echo “” >> $phpini

echo “Installing Microsoft ODBC Driver for SQL Server”

# Originally from: http://packages.microsoft.com/ubuntu/16.04/prod/pool/main/m/msodbcsql/
apt install -y libc6 libstdc++6 libkrb5-3 libcurl3 openssl debconf unixodbc unixodbc-dev

#doesn’t work: $basedir is not set, but also none of the (sub)directories exist on my setup
#sudo ACCEPT_EULA=Y dpkg -i $basedir/config/php-extensions/mssql/bin/debs/current/*.deb

# Create symlinks for tools
#had to change the source filenames to sqlcmd and bcp because with -13.0.1.0 suffix the files were not found
ln -sfn /opt/mssql-tools/bin/sqlcmd /usr/bin/sqlcmd
ln -sfn /opt/mssql-tools/bin/bcp /usr/bin/bcp

service php7.2-fpm restart
#https://github.com/Microsoft/msphpsql/issues/522

 

or

 

Lets make sure that you have your SSL installed and updated:

Now lets fix the naming of the file by creating a link:

make sure that extension=pdo_sqlsrv.so is loaded in 30-pdo_sqlsrv.ini instead of php.ini

debugging do ldd pdo_sqlsrv.so or any other .so files

Published inUncategorized

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *