Skip to content

Instantly share code, notes, and snippets.

@esenthil2018
Created June 12, 2022 05:36
Show Gist options
  • Save esenthil2018/f68750b277be44b255c83301ba79adc2 to your computer and use it in GitHub Desktop.
Save esenthil2018/f68750b277be44b255c83301ba79adc2 to your computer and use it in GitHub Desktop.
# php-mssql
# PHP runtime with pdo_sqlsrv to connect to SQL Server
FROM ubuntu:16.04
# apt-get and system utilities
RUN apt-get update && apt-get install -y \
curl apt-utils apt-transport-https debconf-utils gcc build-essential g++-5\
&& rm -rf /var/lib/apt/lists/*
# adding custom MS repository
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
# install SQL Server drivers
RUN apt-get update && ACCEPT_EULA=Y apt-get install -y unixodbc-dev msodbcsql
# php libraries
RUN apt-get update && apt-get install -y \
php7.0 libapache2-mod-php7.0 mcrypt php7.0-mcrypt php-mbstring php-pear php7.0-dev \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# install necessary locales
RUN apt-get install -y locales \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen
# install SQL Server PHP connector module
RUN pecl install sqlsrv pdo_sqlsrv
# initial configuration of SQL Server PHP connector
RUN echo "extension=/usr/lib/php/20151012/sqlsrv.so" >> /etc/php/7.0/cli/php.ini
RUN echo "extension=/usr/lib/php/20151012/pdo_sqlsrv.so" >> /etc/php/7.0/cli/php.ini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment