Skip to content

Commit

Permalink
Preliminar support for php72
Browse files Browse the repository at this point in the history
With sqlsrv latest 5.2-RC1 drivers and MSODBC 17 preview
it seems that it's possible to make the extension to work
under Debian 9.

it requires to install MSODBC 13, uninstall it and then install
MSODBC 17, but seems to be working ok.

oci also requires some little changes, have been updated to
12.2 libraries and is using proper ENV for both interactive
and non-interactive sessions.

and, finally, what I've been unable to fix/make work is solr. it
seems that still is not ready, so I've disabled it for now.

This will help fixing moodlehq#16.
  • Loading branch information
stronk7 committed Jan 21, 2018
1 parent c0df519 commit aaf7d05
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 31 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM php:7.1-apache
FROM php:7.2-apache

ADD root/ /
# Fix the original permissions of /tmp, the PHP default upload tmp dir.
RUN chmod 777 /tmp && chmod +t /tmp
# Setup the required extensions.
ARG DEBIAN_FRONTEND=noninteractive
RUN /tmp/setup/php-extensions.sh
RUN /tmp/setup/oci8-extension.sh
ENV LD_LIBRARY_PATH /usr/local/instantclient

RUN mkdir /var/www/moodledata && chown www-data /var/www/moodledata && \
mkdir /var/www/phpunitdata && chown www-data /var/www/phpunitdata && \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ A Moodle PHP environment configured for Moodle development based on [Official PH

| PHP Version | Tag | Status |
|--------------|-----|--------|
| PHP 7.2 | 7.2 | [![Build Status](https://travis-ci.org/moodlehq/moodle-php-apache.svg?branch=php72)](https://travis-ci.org/moodlehq/moodle-php-apache)|
| PHP 7.1 | 7.1 | [![Build Status](https://travis-ci.org/moodlehq/moodle-php-apache.svg?branch=php71)](https://travis-ci.org/moodlehq/moodle-php-apache)|
| PHP 7.0 | 7.0 | [![Build Status](https://travis-ci.org/moodlehq/moodle-php-apache.svg?branch=php70)](https://travis-ci.org/moodlehq/moodle-php-apache)|
|PHP 5.6 | 5.6 | [![Build Status](https://travis-ci.org/moodlehq/moodle-php-apache.svg?branch=php56)](https://travis-ci.org/moodlehq/moodle-php-apache)|
Expand Down
35 changes: 20 additions & 15 deletions root/tmp/setup/oci8-extension.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
set -e

echo "Downloading oracle files"
curl https://raw.githubusercontent.com/AminMkh/docker-php7-oci8-apache/b7c740638776552f00178a5d12905cefb50c7848/oracle/instantclient-basic-linux.x64-12.1.0.2.0.zip\
-o /tmp/instantclient-basic-linux.x64-12.1.0.2.0.zip
curl https://raw.githubusercontent.com/AminMkh/docker-php7-oci8-apache/b7c740638776552f00178a5d12905cefb50c7848/oracle/instantclient-sdk-linux.x64-12.1.0.2.0.zip\
-o /tmp/instantclient-sdk-linux.x64-12.1.0.2.0.zip
curl https://raw.githubusercontent.com/AminMkh/docker-php7-oci8-apache/b7c740638776552f00178a5d12905cefb50c7848/oracle/instantclient-sqlplus-linux.x64-12.1.0.2.0.zip\
-o /tmp/instantclient-sqlplus-linux.x64-12.1.0.2.0.zip

unzip /tmp/instantclient-basic-linux.x64-12.1.0.2.0.zip -d /usr/local/
rm /tmp/instantclient-basic-linux.x64-12.1.0.2.0.zip
unzip /tmp/instantclient-sdk-linux.x64-12.1.0.2.0.zip -d /usr/local/
rm /tmp/instantclient-sdk-linux.x64-12.1.0.2.0.zip
unzip /tmp/instantclient-sqlplus-linux.x64-12.1.0.2.0.zip -d /usr/local/
rm /tmp/instantclient-sqlplus-linux.x64-12.1.0.2.0.zip

ln -s /usr/local/instantclient_12_1 /usr/local/instantclient

curl https://raw.githubusercontent.com/bumpx/oracle-instantclient/6aa46afa7a/instantclient-basic-linux.x64-12.2.0.1.0.zip \
-o /tmp/instantclient-basic-linux.x64-12.2.0.1.0.zip
unzip /tmp/instantclient-basic-linux.x64-12.2.0.1.0.zip -d /usr/local/
rm /tmp/instantclient-basic-linux.x64-12.2.0.1.0.zip

curl https://raw.githubusercontent.com/bumpx/oracle-instantclient/6aa46afa7a/instantclient-sdk-linux.x64-12.2.0.1.0.zip \
-o /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip
unzip /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /usr/local/
rm /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip

curl https://raw.githubusercontent.com/bumpx/oracle-instantclient/6aa46afa7a/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip \
-o /tmp/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip
unzip /tmp/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip -d /usr/local/
rm /tmp/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip

ln -s /usr/local/instantclient_12_2 /usr/local/instantclient
ln -s /usr/local/instantclient/libclntsh.so.12.1 /usr/local/instantclient/libclntsh.so
ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus

#echo 'export LD_LIBRARY_PATH="/usr/local/instantclient"' >> /root/.bashrc
#echo 'umask 002' >> /root/.bashrc

echo 'instantclient,/usr/local/instantclient' | pecl install oci8 && docker-php-ext-enable oci8
echo 'oci8.statement_cache_size = 0' >> /usr/local/etc/php/conf.d/docker-php-ext-oci8.ini
23 changes: 9 additions & 14 deletions root/tmp/setup/php-extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

set -e

echo "Installing apt depdencies"
echo "Installing apt dependencies"

BUILD_PACKAGES="gettext libcurl4-openssl-dev libpq-dev libmysqlclient-dev libldap2-dev libxslt-dev \
BUILD_PACKAGES="gettext libcurl4-openssl-dev libpq-dev default-libmysqlclient-dev libldap2-dev libxslt-dev \
libxml2-dev libicu-dev libfreetype6-dev libjpeg62-turbo-dev libmemcached-dev \
zlib1g-dev libpng12-dev unixodbc-dev"
zlib1g-dev libpng-dev unixodbc-dev gnupg2"

LIBS="locales libaio1 libcurl3 libgss3 libicu52 libmysqlclient18 libpq5 libmemcached11 libmemcachedutil2 libldap-2.4-2 libxml2 libxslt1.1 unixodbc libmcrypt-dev"
LIBS="locales libaio1 libcurl3 libgss3 libicu57 libpq5 libmemcached11 libmemcachedutil2 libldap-2.4-2 libxml2 libxslt1.1 unixodbc libmcrypt-dev"

apt-get update
apt-get install -y --no-install-recommends $BUILD_PACKAGES $LIBS unzip ghostscript locales apt-transport-https
Expand All @@ -34,19 +34,14 @@ docker-php-ext-install -j$(nproc) gd
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/
docker-php-ext-install -j$(nproc) ldap

pecl install solr memcached redis apcu igbinary
docker-php-ext-enable solr memcached redis apcu igbinary
pecl install memcached redis apcu igbinary
docker-php-ext-enable memcached redis apcu igbinary

This comment has been minimized.

Copy link
@scara

scara Jan 23, 2018

Hi @stronk7,
solr 2.4.0 tarball doesn't contain the fixes required for 7.2, why not adding a temporary script to compile it from git e.g

pecl install memcached redis apcu igbinary
/tmp/setup/solr-extension.sh
docker-php-ext-enable solr memcached redis apcu igbinary

?
/tmp/setup/solr-extension.sh should look like the commands below just tested on the same base image:

[root@vm-docker01 ~]# docker run -it --rm php:7.2-apache bash
# Prerequisites already in the Moodle image.
root@7287d75f6c08:/var/www/html# apt-get update
root@7287d75f6c08:/var/www/html# apt-get install libcurl4-openssl-dev libxml2-dev
# Git is required and should be added in the prereqs.
root@7287d75f6c08:/var/www/html# apt-get install -y git
root@7287d75f6c08:/var/www/html# cd /tmp
root@7287d75f6c08:/tmp# git clone https://github.com/php/pecl-search_engine-solr
root@7287d75f6c08:/tmp# cd pecl-search_engine-solr/
# Fix the code to a 'known' version 'till a 2.5.0 version of solr will be shipped.
root@7287d75f6c08:/tmp/pecl-search_engine-solr# git reset --hard de1d724299780d927cb9ed14268449ac8a28204b
root@7287d75f6c08:/tmp/pecl-search_engine-solr# phpize && ./configure && make && make install
# This command will be executed as part of the current list of extension to be enabled.
root@7287d75f6c08:/tmp/pecl-search_engine-solr# docker-php-ext-enable solr
root@7287d75f6c08:/tmp/pecl-search_engine-solr# php -m | grep solr
solr

Would you like me to push an extra commit on top of yours?

TIA,
Matteo

This comment has been minimized.

Copy link
@stronk7

stronk7 Jan 25, 2018

Author Owner

Hey Matteo,

sure 100% welcome! Later can move to simpler extension whenever available. I really did not know it was compilable at all. Super^3, thanks!

This comment has been minimized.

Copy link
@stronk7

stronk7 Jan 25, 2018

Author Owner

OT: Trying to imagine why I did not get any notification about your comment above... I just arrived here from the open issue (because you provided a link). uhm...

This comment has been minimized.

Copy link
@scara

scara Jan 25, 2018

SPAM 🤣


echo 'apc.enable_cli = On' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini

# Install Microsoft depdencises for sqlsrv
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/8/prod.list -o /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get install -y msodbcsql

pecl install sqlsrv-4.3.0
docker-php-ext-enable sqlsrv
# Go for sqlsrv extension now (kept apart for clarity, still need to be run here
# before some build packages are deleted.
/tmp/setup/sqlsrv-extension.sh

# Keep our image size down..
pecl clear-cache
Expand Down
33 changes: 33 additions & 0 deletions root/tmp/setup/sqlsrv-extension.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -e

# Install Microsoft dependencies for sqlsrv
# Debian 9 requires ODBC driver 17, still not package available in repos, so followed this
# https://github.com/Microsoft/msphpsql/wiki/Install-and-configuration#user-content-odbc-17-linux-installation
echo "Downloading sqlsrv files"
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/debian/8/prod.list -o /etc/apt/sources.list.d/mssql-release.list
apt-get update

echo "Install msodbcsql"
ACCEPT_EULA=Y apt-get install -y msodbcsql

# now remove ODBC driver 13.1, then download and install 17 from Github
apt-get purge -y msodbcsql

curl https://raw.githubusercontent.com/Microsoft/msphpsql/dev/ODBC%2017%20binaries%20preview/Debian%209/msodbcsql_17.0.0.5-1_amd64.deb \
-o /tmp/msodbcsql_17.0.0.5-1_amd64.deb
curl https://raw.githubusercontent.com/Microsoft/msphpsql/dev/ODBC%2017%20binaries%20preview/Debian%209/mssql-tools_17.0.0.5-1_amd64.deb \
-o /tmp/mssql-tools_17.0.0.5-1_amd64.deb

ACCEPT_EULA=Y dpkg -i /tmp/msodbcsql_17.0.0.5-1_amd64.deb
ACCEPT_EULA=Y dpkg -i /tmp/mssql-tools_17.0.0.5-1_amd64.deb

rm /tmp/msodbcsql_17.0.0.5-1_amd64.deb
rm /tmp/mssql-tools_17.0.0.5-1_amd64.deb

ln -fsv /opt/mssql-tools/bin/* /usr/bin

pecl install sqlsrv-5.2.0RC1
docker-php-ext-enable sqlsrv
2 changes: 1 addition & 1 deletion tests/fixtures/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'oci8',
'pgsql',
'redis',
'solr',
# Disabled because it's not available for php72 yet 'solr',
'soap',
'sqlsrv',
'xsl',
Expand Down

0 comments on commit aaf7d05

Please sign in to comment.