Public Repository

Last pushed: 3 months ago
Short Description
Ubuntu 14.04.3 LTS, Trusty Tahr / php5.6 (fpm/cli)
Full Description

Dockerfile

FROM phusion/baseimage:0.9.18

# Default baseimage settings
ENV HOME /root
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
CMD ["/sbin/my_init"]
ENV DEBIAN_FRONTEND noninteractive

# Add the PPA for PHP 5.6
RUN apt-get install software-properties-common
RUN add-apt-repository ppa:ondrej/php -y

# Update software list and install php + nginx
RUN apt-get update -y --force-yes \
#  && apt-get upgrade -y --force-yes \
  && apt-get install -y --force-yes \
  php5.6 \
  php5.6-common \
  php5.6-fpm \
  php5.6-cli \
  php5.6-mysql \
  php5.6-mcrypt \
  php5.6-curl \
  php5.6-gd \
  php5.6-intl \
  php5.6-xml \
  php5.6-mbstring \
  mysql-client \
  wget

# Clear cache
RUN apt-get clean \
  && rm -rf /var/lib/apt/lists/* \
  /tmp/* \
  /var/tmp/*

# Configure nginx
RUN mkdir -p /path/to/your-projects

# Configure PHP
RUN sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/5.6/fpm/php.ini
RUN sed -i "s/;date.timezone =.*/date.timezone = Pacific\/Auckland/" /etc/php/5.6/fpm/php.ini
RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php/5.6/fpm/php-fpm.conf
RUN sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/5.6/cli/php.ini
RUN sed -i "s/;date.timezone =.*/date.timezone = Pacific\/Auckland/" /etc/php/5.6/cli/php.ini
RUN sed -i "s/listen = \/run\/php\/php5.6-fpm.sock/listen = 127.0.0.1:9056/" /etc/php/5.6/fpm/pool.d/www.conf
RUN sed -i "s/user = www\-data/user = 1000/" /etc/php/5.6/fpm/pool.d/www.conf
RUN sed -i "s/group = www\-data/group = 1000/" /etc/php/5.6/fpm/pool.d/www.conf
RUN phpenmod mcrypt
RUN service php5.6-fpm start

# clear cache.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Add nginx volumes
VOLUME ["/path/to/your-projects"]

# Set the work directory
WORKDIR /path/to/your-projects

#CMD wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
#CMD tar xfz ioncube_loaders_lin_x86-64.tar.gz
#CMD cp ioncube/ioncube_loader_lin_5.6.so /usr/lib/php/20131226/
#CMD sed  -i '1i zend_extension = /usr/lib/php/20131226/ioncube_loader_lin_5.6.so' /etc/php/5.6/fpm/php.ini
#CMD service php5.6-fpm restart

Build

docker build -t danielyang/php5.6 .


Run

docker run -d --name php5.6fpm --restart=always --net=host -p 9056:9056 -v /path/to/your-projects:/path/to/your-projects danielyang/php5.6 php-fpm5.6


Add upstream in nginx.conf under http

upstream php56 {
        server 127.0.0.1:9056;
    }

Add to project config to be run by nginx

fastcgi_pass php56;


Run bash

docker exec -it ps_id bash


Install ioncube (when needed) in the container

wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar xfz ioncube_loaders_lin_x86-64.tar.gz
cp ioncube/ioncube_loader_lin_5.6.so /usr/lib/php/20131226/
sed  -i '1i zend_extension = /usr/lib/php/20131226/ioncube_loader_lin_5.6.so' /etc/php/5.6/fpm/php.ini
service php5.6-fpm restart

PHP CLI

If you want to use php cli in your host, put this script somewhere and alias it in /usr/sbin/

#!/bin/bash

sudo docker run --rm --name=php5.6-cli --net=host \
    -v `pwd`:`pwd` \
    -v /media/daniel/data/git:/media/daniel/data/git \
    -w `pwd` \
    danielyang/php5.6 php "$@"

exit 0;
Docker Pull Command
Owner
danielyang

Comments (0)