Last active
July 23, 2024 12:52
-
-
Save empirefx/8527705981f94b069f5366dc06582678 to your computer and use it in GitHub Desktop.
Docker apache php mssql
This file contains hidden or 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
FROM php:7.0-apache | |
COPY src/ /var/www/html/ | |
# Add Microsoft repo for Microsoft ODBC Driver 13 for Linux | |
RUN apt-get update && apt-get install -y \ | |
apt-transport-https \ | |
gnupg \ | |
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \ | |
&& curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \ | |
&& apt-get update | |
# Install Dependencies | |
RUN ACCEPT_EULA=Y apt-get install -y \ | |
unixodbc \ | |
unixodbc-dev \ | |
libgss3 \ | |
odbcinst \ | |
msodbcsql17 \ | |
locales \ | |
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen | |
# Install pdo_sqlsrv and sqlsrv from PECL. Replace pdo_sqlsrv-4.1.8preview with preferred version. | |
RUN pecl install pdo_sqlsrv-5.3.0 sqlsrv-5.3.0 \ | |
&& docker-php-ext-enable pdo_sqlsrv sqlsrv |
This file contains hidden or 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
<?php | |
//Test | |
$hostname='localhost,1433'; | |
$dbname='DB'; | |
$username='sa'; | |
$password='pwd'; | |
$dbDB = new PDO("sqlsrv:Server=$hostname;Database=$database", $username, $password); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Me sirvio de 10, ganaste una estrella :)