Skip to content

Install and configuration

Jenny Tam edited this page May 19, 2017 · 34 revisions

Contents

End to End Installation instructions

Common installation and configuration issues

Mac OS X

If you like to install the latest version of PHP 7.1.x, please unlink the older versions of PHP first. For example,

brew unlink php56

brew unlink php70

If on the other hand you already have an older version of PHP 7.1.x installed, such as PHP 7.1.0, and now the latest is PHP 7.1.4, then you will need to brew upgrade --cleanup php71 (likewise with PHP 7.0.x).

If brew install php70 --with-pear or brew install php71 --with-pear fails, one possible reason is you have pear installed previously but not using brew. In this case, you can uninstall pear or simply install PHP using brew without the --with-pear option. Then, after PHP is successfully installed, take the following steps to install pear:

curl -O http://pear.php.net/go-pear.phar

sudo php -d detect_unicode=0 go-pear.phar

You will see a list of options of where to install pear, so

  1. Type 1 and hit return
  2. Type /usr/local/pear

The above step changes the installation base for pear. Then the next step is to change where pear's binaries go:

  1. Type 4 and hit return
  2. Type /usr/local/bin

After these two options have been configured, press return to install pear. When the installation is complete, type pear version and see if it's linked with the latest PHP version (php -v). For details, please read the Getting PEAR package.

If you have problems with pear/pecl, this checking if PEAR works might help.

Linux

-To be updated. Please stay tuned.

Docker files

This section is created and maintained by contributors, and is not officially tested.

Dockerfile for adding pdo_sqlsrv and sqlsrv to official php image.

Originally created by Diego Gullo

This uses Microsoft repos for msodbcsql to simplify the installation process.

FROM php:fpm

# Add Microsoft repo for Microsoft ODBC Driver 13 for Linux
RUN apt-get update && apt-get install -y \
    apt-transport-https \
    && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
    && curl https://packages.microsoft.com/config/debian/8/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 \
    msodbcsql \
    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-4.1.8preview sqlsrv-4.1.8preview \
    && docker-php-ext-enable pdo_sqlsrv sqlsrv

Dockerfile for getting pdo_sqlsrv for PHP 7.0 on Debian in 3 ways

Originally created by Viktor Szépe

# Prove that the Debian how-to works, please choose one of the 3 installation methods
# and optionally save the resulting extension: sudo cp /usr/lib/php/20151012/pdo_sqlsrv.so /opt/results/

FROM szepeviktor/jessie-build

ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive

USER debian
WORKDIR /home/debian
VOLUME ["/opt/results"]

# Add PHP 7 repository
# for Debian jessie
# And System upgrade
RUN echo "deb http://packages.dotdeb.org jessie all" \
    | sudo tee /etc/apt/sources.list.d/dotdeb.list \
    && wget -qO- https://www.dotdeb.org/dotdeb.gpg \
    | sudo apt-key add - \
    && sudo apt-get update \
    && sudo apt-get upgrade -qq

# Install UnixODBC
# Compile odbc_config as it is not part of unixodbc package
RUN sudo apt-get install -y whiptail \
    unixodbc libgss3 odbcinst devscripts debhelper dh-exec dh-autoreconf libreadline-dev libltdl-dev \
    && dget -u -x http://http.debian.net/debian/pool/main/u/unixodbc/unixodbc_2.3.1-3.dsc \
    && cd unixodbc-*/ \
    && dpkg-buildpackage -uc -us -B \
    && sudo cp -v ./exe/odbc_config /usr/local/bin/

# Fake uname for install.sh
RUN printf '#!/bin/bash\nif [ "$*" == "-p" ]; then echo "x86_64"; else /bin/uname "$@"; fi' \
    | sudo tee /usr/local/bin/uname \
    && sudo chmod +x /usr/local/bin/uname

# Microsoft ODBC Driver 13 for Linux
# Note: There's a copy of this tar on my hubiC
RUN wget -nv -O msodbcsql-13.0.0.0.tar.gz \
    "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" \
    && tar -xf msodbcsql-13.0.0.0.tar.gz \
    && cd msodbcsql-*/ \
    && ldd lib64/libmsodbcsql-13.0.so.0.0 \
    && sudo ./install.sh install --accept-license \
    && ls -l /opt/microsoft/msodbcsql/ \
    && odbcinst -q -d -n "ODBC Driver 13 for SQL Server"

# (1) Install PDO driver from pecl
RUN sudo apt-get install -y unixodbc-dev php7.0-dev php-pear \
    && sudo pecl channel-update pecl.php.net \
    && sudo pecl install pdo_sqlsrv \
    && printf "; priority=20\nextension=pdo_sqlsrv.so" \
    | sudo tee /etc/php/7.0/mods-available/pdo_sqlsrv.ini \
    && sudo phpenmod pdo_sqlsrv \
    && php --rextinfo pdo_sqlsrv \
    && sudo phpdismod pdo_sqlsrv \
    && sudo pecl uninstall pdo_sqlsrv

# (2) Or Build PDO driver with phpize
RUN sudo apt-get install -y unixodbc-dev php7.0-dev \
    && wget -nv "https://github.com/Microsoft/msphpsql/archive/PHP-7.0-Linux.tar.gz" \
    && tar -xf PHP-7.0-Linux.tar.gz \
    && cd msphpsql-PHP-7.0-Linux/source/ \
    && cp -r shared/ pdo_sqlsrv/ \
    && cd pdo_sqlsrv/ \
    && phpize \
    && ./configure CXXFLAGS=-std=c++11 \
    && make \
    && sudo make "INSTALL=$(pwd)/build/shtool install -c --mode=0644" install \
    && printf "; priority=20\nextension=pdo_sqlsrv.so" \
    | sudo tee /etc/php/7.0/mods-available/pdo_sqlsrv.ini \
    && sudo phpenmod pdo_sqlsrv \
    && php --rextinfo pdo_sqlsrv \
    && sudo phpdismod pdo_sqlsrv \
    && sudo rm -f /usr/lib/php/20151012/pdo_sqlsrv.so

# (3) Or Download precompiled pdo_sqlsrv extension binaries
RUN sudo apt-get install -y php7.0-cli \
    &&wget -nv "https://github.com/Microsoft/msphpsql/releases/download/4.0.8-Linux/Ubuntu15.tar" \
    && tar -xf Ubuntu15.tar \
    && sudo cp -v ./Ubuntu15/php_pdo_sqlsrv_7_nts.so /usr/lib/php/20151012/pdo_sqlsrv.so \
    && printf "; priority=20\nextension=pdo_sqlsrv.so" \
    | sudo tee /etc/php/7.0/mods-available/pdo_sqlsrv.ini \
    && sudo phpenmod pdo_sqlsrv \
    && php --rextinfo pdo_sqlsrv \
    && sudo phpdismod pdo_sqlsrv \
    && sudo rm -f /usr/lib/php/20151012/pdo_sqlsrv.so

Installing pdo_sqlsrv using Docker image php:7.1

Originally created by Remco

    FROM php:7.1-apache
    
    RUN apt-get install -y whiptail \
        unixodbc libgss3 odbcinst devscripts debhelper dh-exec dh-autoreconf libreadline-dev libltdl-dev \
        && dget -u -x http://http.debian.net/debian/pool/main/u/unixodbc/unixodbc_2.3.1-3.dsc \
        && cd unixodbc-*/ \
        && dpkg-buildpackage -uc -us -B \
        && cp -v ./exe/odbc_config /usr/local/bin/
    
    RUN printf '#!/bin/bash\nif [ "$*" == "-p" ]; then echo "x86_64"; else /bin/uname "$@"; fi' \
        | tee /usr/local/bin/uname \
        && chmod +x /usr/local/bin/uname
    
    RUN apt-get install -y wget \
        && wget -nv -O msodbcsql-13.0.0.0.tar.gz \
        "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" \
        && tar -xf msodbcsql-13.0.0.0.tar.gz \
        && cd msodbcsql-*/ \
        && ldd lib64/libmsodbcsql-13.0.so.0.0 \
        && ./install.sh install --accept-license \
        && ls -l /opt/microsoft/msodbcsql/ \
        && odbcinst -q -d -n "ODBC Driver 13 for SQL Server"
    
    RUN apt-get install -y apt-transport-https lsb-release ca-certificates \
        && wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
        && echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
        && apt-get update
        
    RUN apt-get install -y unixodbc-dev php7.1-dev php-pear \
        && pecl channel-update pecl.php.net \
        && pecl install pdo_sqlsrv-4.1.6.1 \
        && printf "; priority=20\nextension=/usr/lib/php/20160303/pdo_sqlsrv.so" | tee /etc/php/7.1/mods-available/pdo_sqlsrv.ini \
        && echo "extension=pdo_sqlsrv.so" > /usr/local/etc/php/conf.d/pdo_sqlsrv.ini
Clone this wiki locally