Categories

Debian – Docker Container Apache2 – PHP7

Create container – Apach2 and PHP7

  1. Create Dockerfile

root@debian8:~/GISPRO# more Dockerfile

#Docker file Apache 2 + PHP 7.0

FROM debian

MAINTAINER khanh dinh / docker-apache2-php7.0

RUN  export DEBIAN_FRONTEND=noninteractive

ENV  DEBIAN_FRONTEND noninteractive

RUN  dpkg-divert –local –rename –add /sbin/initctl

RUN apt-get update

RUN apt-get install -y wget apt-utils

#add

RUN echo “deb http://packages.dotdeb.org jessie all” > /etc/apt/sources.list.d/dotdeb.list

RUN wget https://www.dotdeb.org/dotdeb.gpg

RUN apt-key add dotdeb.gpg

RUN apt-get update && apt-get -y upgrade && apt-get dist-upgrade -y

RUN apt-get install -y  sudo xauth htop curl apache2 apache2-mpm-event  libapache2-mod-fcgid

RUN apt-get install -y –force-yes php7.0 php7.0-fpm

RUN apt-get install -y –force-yes php7.0-gd php7.0-sqlite php7.0-curl php7.0-xmlrpc python-simplejson  php7.0-json php7.0-fpm python-software-properties php7.0-

xml php7.0-cgi

#active

RUN a2enmod actions fcgid

RUN a2enmod proxy_fcgi setenvif

RUN a2enconf php7.0-fpm

#remove PHP5

RUN apt-get remove libapache2-mod-php*

COPY fcgid.conf /etc/apache2/mods-enabled/fcgid.conf

RUN mkdir -p /var/tmp/mod_fcgid

RUN chmod 777 /var/tmp/mod_fcgid

COPY mpm_event.conf /etc/apache2/mods-available/mpm_event.conf

RUN a2enmod headers

COPY deflate.conf /etc/apache2/mods-available/deflate.conf

COPY info.php /var/www/html/

COPY start.sh /

RUN chmod 0755 /start.sh

CMD /start.sh

root@debian8:~/GISPRO#


  1. start.sh

root@debian8:~/GISPRO# cat start.sh 

#!/bin/bash

#generate config file

# Apache gets grumpy about PID files pre-existing

rm -f /var/run/apache2/apache2.pid

bash /etc/init.d/php7.0-fpm start

exec /usr/sbin/apachectl -D FOREGROUND

root@debian8:~/GISPRO#


  1. Build docker image
  2. #docker build -t apache2php7 .
  3. Run docker
    #docker run –name “test” -p 81:80 -d -t apache2php7

Connect to container :

#docker exec -ti test /bin/bash


Test

http://192.168.56.101:81 –> Apache

http://192.168.56.101:81/info.php. –> PHP info

 

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  

  

  

This site uses Akismet to reduce spam. Learn how your comment data is processed.