Docker Compose - Installing php-fpm with MySQLi, MySQLnd and PDO extensions

Viewed 5076

I am trying to setup docker on computer (Mac) and I am unable to compile PDO_mysql extension.

My docker-compose file looks like following

version: '2'
  services:
    nginx:
        image: tutum/nginx
        ports:
            - "80:80"
        links:
            - phpfpm
        volumes:
            - ./nginx/conf:/etc/nginx/sites-available/
            - ./nginx/conf:/etc/nginx/sites-enabled/

            - ./logs/nginx-error.log:/var/log/nginx/error.log
            - ./logs/nginx-access.log:/var/log/nginx/access.log
    phpfpm:
        build: ./php
        ports:
            - "9000:9000"
        volumes:
            - ./Sites:/usr/share/nginx/html
    mysql:
      image: mysql
      environment:
        MYSQL_ROOT_PASSWORD: admin
      ports:
        - "3306:3306" 

My Dockfile looks like following:

FROM php:5.6-fpm
RUN apt-get update && apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
    && docker-php-ext-install -j$(nproc) iconv mcrypt mysqli \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd 

The above files work fine, BUT if in the 3rd last file, if I add mysqlnd I cannot build my php.

            Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20131226/
            Installing header files:           /usr/local/include/php/
            find . -name \*.gcno -o -name \*.gcda | xargs rm -f
            find . -name \*.lo -o -name \*.o | xargs rm -f
            find . -name \*.la -o -name \*.a | xargs rm -f 
            find . -name \*.so | xargs rm -f
            find . -name .libs -a -type d|xargs rm -rf
            rm -f libphp.la       modules/* libs/*
            + cd mysqlnd
            + phpize
            Cannot find config.m4. 
            Make sure that you run '/usr/local/bin/phpize' in the top level source directory of the module

            ERROR: Service 'phpfpm' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y       libfreetype6-dev        libjpeg62-turbo-dev         libmcrypt-dev       libpng12-dev    && docker-php-ext-install -j$(nproc) iconv mcrypt mysqli mysqlnd    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/  && docker-php-ext-install -j$(nproc) gd' returned a non-zero code: 1

What am I doing wrong?

Please advise.

Thanks

3 Answers

I just discarded tutum image and used Quay.io image

image: quay.io/ignited/php-nginx-fpm:5.6.30-latest

This one line did wonders for me. I got php-fpm with all the required libraries which are usually pre-installed on the hosting servers.

I hope it helps anyone who has wasted few days trying to figure out.

Related