add fpm-php7
This commit is contained in:
parent
9852484282
commit
17163c9b3d
|
@ -46,7 +46,7 @@ echo
|
||||||
tmpsed="/etc/php5/php.ini"
|
tmpsed="/etc/php5/php.ini"
|
||||||
sed -ir 's/expose_php = On/expose_php = Off/' $tmpsed
|
sed -ir 's/expose_php = On/expose_php = Off/' $tmpsed
|
||||||
sed -i "s|;*date.timezone =.*|date.timezone = ${TZ}|i" $tmpsed
|
sed -i "s|;*date.timezone =.*|date.timezone = ${TZ}|i" $tmpsed
|
||||||
sed -i "s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= 0|i" /etc/php5/php.ini
|
sed -i "s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= 0|i" $tmpsed
|
||||||
tmpsed="/etc/php5/php-fpm.conf"
|
tmpsed="/etc/php5/php-fpm.conf"
|
||||||
sed -i "s|;*daemonize\s*=\s*yes|daemonize = no|g" $tmpsed
|
sed -i "s|;*daemonize\s*=\s*yes|daemonize = no|g" $tmpsed
|
||||||
sed -i "s|;*listen\s*=\s*127.0.0.1:9000|listen = 9000|g" $tmpsed
|
sed -i "s|;*listen\s*=\s*127.0.0.1:9000|listen = 9000|g" $tmpsed
|
||||||
|
|
|
@ -5,5 +5,5 @@
|
||||||
apk --update add apache2 apache2-proxy \
|
apk --update add apache2 apache2-proxy \
|
||||||
php7-apache2 php7-mbstring php7-session php7-phar php7-zlib php7-zip php7-ctype \
|
php7-apache2 php7-mbstring php7-session php7-phar php7-zlib php7-zip php7-ctype \
|
||||||
php7-mysqli php7-xml php7-pdo_mysql php7-opcache php7-pdo php7-json php7-curl \
|
php7-mysqli php7-xml php7-pdo_mysql php7-opcache php7-pdo php7-json php7-curl \
|
||||||
php7-gd php7-mcrypt php7-openssl php7-\dom \
|
php7-gd php7-mcrypt php7-openssl php7-dom \
|
||||||
# php-pdo_odbc php-soap php-pgsql
|
# php-pdo_odbc php-soap php-pgsql
|
||||||
|
|
20
pluie/alpine-fpm-php7/Dockerfile
Normal file
20
pluie/alpine-fpm-php7/Dockerfile
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# @app pluie/alpine-apache
|
||||||
|
# @author a-Sansara https://git.pluie.org/pluie/docker-images
|
||||||
|
|
||||||
|
FROM pluie/alpine
|
||||||
|
|
||||||
|
MAINTAINER a-Sansara https://github.com/a-sansara
|
||||||
|
|
||||||
|
ADD files.tar /scripts
|
||||||
|
|
||||||
|
ENV SHENV_NAME=Php7 \
|
||||||
|
SHENV_COLOR=67 \
|
||||||
|
HTTP_SERVER_NAME=php7.docker \
|
||||||
|
WWW_DIR=www \
|
||||||
|
WWW_INDEX=index.php \
|
||||||
|
FIX_OWNERSHIP=1 \
|
||||||
|
TZ=Europe/Paris
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
|
||||||
|
RUN bash /scripts/install.sh
|
96
pluie/alpine-fpm-php7/README.md
Normal file
96
pluie/alpine-fpm-php7/README.md
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
# pluie/alpine-apache-php7
|
||||||
|
|
||||||
|
- [index][1]
|
||||||
|
- [pluie/alpine][2] ( < 10 MB ) Alpine/3.4
|
||||||
|
- [pluie/alpine-apache][3] ( ~ 50 MB ) Apache/2.4.23 Php/5.6.24
|
||||||
|
- [pluie/alpine-apache-fpm][7] ( ~ 50 MB ) Apache/2.4.23 Php/5.6.24 Fpm
|
||||||
|
- [pluie/alpine-symfony][6] ( ~ 82 MB ) Symfony2.8 or 3.1
|
||||||
|
- [pluie/alpine-apache-php7][8] ( ~ 50 MB ) Apache/2.4.25 Php/7.0.15
|
||||||
|
- [pluie/alpine-symfony-php7][9] ( ~ 82 MB ) Symfony2.8 or 3.2 Php/7.0.15
|
||||||
|
- [pluie/alpine-mysql][4] ( ~172 MB ) Mysql/5.5.47 ( MariaDB )
|
||||||
|
- [docker tips][5]
|
||||||
|
|
||||||
|
Extend pluie/alpine with __apache 2.4.25__ and __php 7.0.15__
|
||||||
|
|
||||||
|
- error log are attached to stdout
|
||||||
|
- no need port redirection
|
||||||
|
- you can use env var at container creation : __HTTP_SERVER_NAME__ (default : site.docker ortherwise edit /app/vhost later)
|
||||||
|
- you can still use ever your local http & sql server while your container(s) are running
|
||||||
|
|
||||||
|
|
||||||
|
## Image Size
|
||||||
|
|
||||||
|
- image ~ 50 MB
|
||||||
|
|
||||||
|
## ENV variables
|
||||||
|
|
||||||
|
```
|
||||||
|
HTTP_SERVER_NAME=site.docker # apache ServerName
|
||||||
|
WWW_DIR=www # DocumentRoot relative to volume
|
||||||
|
WWW_INDEX=index.php # DirectoryIndex
|
||||||
|
FIX_OWNERSHIP=1 #
|
||||||
|
```
|
||||||
|
|
||||||
|
### Inherit ENV variables
|
||||||
|
|
||||||
|
```
|
||||||
|
SHENV_CTX=LOCAL # LOCAL|INT|PROD change context bg color
|
||||||
|
SHENV_NAME=Php7 # container name
|
||||||
|
SHENV_COLOR=67 # ANSI EXTENDED COLOR CODE
|
||||||
|
TZ=Europe/Paris # TIMEZONE
|
||||||
|
```
|
||||||
|
|
||||||
|
## Image Volumes
|
||||||
|
|
||||||
|
__/app__ directory is a docker volume bind to your app project (silex/symfony etc)
|
||||||
|
|
||||||
|
__/app/$WWW_DIR__ is the documentRoot.
|
||||||
|
put only your entry point and static files to the documentRoot directory, no your app sources
|
||||||
|
(__/app__ directory is design for this).
|
||||||
|
|
||||||
|
__/app/vhost__ is your app vhost configuration file (with a serverName directive).
|
||||||
|
by default it use the apache rewrite module to redirect all uri to entry point $WWW_INDEX
|
||||||
|
|
||||||
|
```
|
||||||
|
/app/ # your application directory
|
||||||
|
|
|
||||||
|
|---- $WWW_DIR/ # documentRoot
|
||||||
|
|
|
||||||
|
|---- vhost # apache app vhost
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Image Usage
|
||||||
|
|
||||||
|
chdir to your project directory
|
||||||
|
```
|
||||||
|
$ docker run --name php7 -it --link=mysql:db -v $(pwd):/app pluie/alpine-apache
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```
|
||||||
|
$ docker run --name php7 -it --link=mysql:db -e HTTP_SERVER_NAME=yourServerName -v $(pwd):/app pluie/alpine-apache-php7
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Controling http server
|
||||||
|
|
||||||
|
```
|
||||||
|
# reload
|
||||||
|
$ docker exec -it php7 "httpd -k graceful"
|
||||||
|
# restart
|
||||||
|
$ docker exec -it php7 "httpd -k restart"
|
||||||
|
```
|
||||||
|
for more commands :
|
||||||
|
```
|
||||||
|
$ docker exec -it php7 "httpd -h"
|
||||||
|
```
|
||||||
|
|
||||||
|
[1]: https://github.com/pluie-org/docker-images
|
||||||
|
[2]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine
|
||||||
|
[3]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-apache
|
||||||
|
[4]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-mysql
|
||||||
|
[7]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-apache-fpm
|
||||||
|
[5]: https://github.com/pluie-org/docker-images/blob/master/DOCKER.md
|
||||||
|
[6]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-symfony
|
||||||
|
[8]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-apache-php7
|
||||||
|
[9]: https://github.com/pluie-org/docker-images/tree/master/pluie/alpine-symfony-php7
|
22
pluie/alpine-fpm-php7/build
Executable file
22
pluie/alpine-fpm-php7/build
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# @app pluie/alpine-apache
|
||||||
|
# @author a-Sansara https://git.pluie.org/pluie/docker-images
|
||||||
|
|
||||||
|
Ctitle="\033[1;38;5;15;1;48;5;30m"
|
||||||
|
Citem="\033[1;38;5;36m"
|
||||||
|
Coff="\033[m"
|
||||||
|
DOCKDIR=$(dirname "$(readlink -f ${BASH_SOURCE[0]})")
|
||||||
|
DOCKBUILD=$(basename $DOCKDIR)
|
||||||
|
DOCKREPO=$(basename $(dirname $DOCKDIR))
|
||||||
|
DOCKTAG=${1:-"latest"}
|
||||||
|
TMPPWD=$(pwd)
|
||||||
|
indent=" "
|
||||||
|
cd $DOCKDIR
|
||||||
|
echo -e "\n ${Ctitle} Preparing files : ${Coff}${Citem}\n"
|
||||||
|
|
||||||
|
tar -cvf files.tar *.sh pre-init.d/ install.d/ | sed "s/^/${indent}↠ /"
|
||||||
|
|
||||||
|
echo -e "\n ${Ctitle} Proceed Dockerfile build : ${Coff}\n
|
||||||
|
"
|
||||||
|
docker build --force-rm -t ${DOCKREPO}/${DOCKBUILD}:${DOCKTAG} . | sed "s/^/${indent}/"
|
||||||
|
cd $TMPPWD
|
BIN
pluie/alpine-fpm-php7/files.tar
Normal file
BIN
pluie/alpine-fpm-php7/files.tar
Normal file
Binary file not shown.
8
pluie/alpine-fpm-php7/install.d/00-repo.sh
Normal file
8
pluie/alpine-fpm-php7/install.d/00-repo.sh
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# @app pluie/alpine-apache-php7
|
||||||
|
# @author a-Sansara https://git.pluie.org/pluie/docker-images
|
||||||
|
#
|
||||||
|
echo "http://dl-cdn.alpinelinux.org/alpine/edge/community
|
||||||
|
http://dl-cdn.alpinelinux.org/alpine/edge/main
|
||||||
|
http://dl-cdn.alpinelinux.org/alpine/edge/testing
|
||||||
|
" > /etc/apk/repositories
|
9
pluie/alpine-fpm-php7/install.d/10-apache.sh
Executable file
9
pluie/alpine-fpm-php7/install.d/10-apache.sh
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# @app pluie/alpine-apache
|
||||||
|
# @author a-Sansara https://git.pluie.org/pluie/docker-images
|
||||||
|
|
||||||
|
apk --update add apache2 apache2-proxy apache2-proxy-html apache-mod-fcgid php7-fpm \
|
||||||
|
php7-apache2 php7-mbstring php7-session php7-phar php7-zlib php7-zip php7-ctype \
|
||||||
|
php7-mysqli php7-xml php7-pdo_mysql php7-opcache php7-pdo php7-json php7-curl \
|
||||||
|
php7-gd php7-mcrypt php7-openssl php7-dom \
|
||||||
|
# php-pdo_odbc php-soap php-pgsql
|
60
pluie/alpine-fpm-php7/install.d/50-fix-apache.sh
Executable file
60
pluie/alpine-fpm-php7/install.d/50-fix-apache.sh
Executable file
|
@ -0,0 +1,60 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# @app pluie/alpine-apache
|
||||||
|
# @author a-Sansara https://git.pluie.org/pluie/docker-images
|
||||||
|
|
||||||
|
function a2setModule(){
|
||||||
|
local enable=${1:-''}
|
||||||
|
local path=${3:-'/etc/apache2/httpd.conf'}
|
||||||
|
local scom=''
|
||||||
|
local rcom='\#'
|
||||||
|
if [ ! -z $1 ] && [ ! -z "$2" ]; then
|
||||||
|
if [ "$enable" = 1 ]; then
|
||||||
|
scom='\#'
|
||||||
|
rcom=''
|
||||||
|
fi
|
||||||
|
echo "$2"
|
||||||
|
sed -i "s#${scom}LoadModule $2_module modules/mod_$2.so#${rcom}LoadModule $2_module modules/mod_$2.so#" "$path"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
if [ ! -f /usr/bin/php ]; then
|
||||||
|
ln -s /usr/bin/php7 /usr/bin/php
|
||||||
|
fi
|
||||||
|
if [ ! -f /usr/lib/libxml2.so ]; then
|
||||||
|
ln -s /usr/lib/libxml2.so.2 /usr/lib/libxml2.so
|
||||||
|
fi
|
||||||
|
if [ ! -d /app/$WWW_DIR ]; then
|
||||||
|
mkdir -p /app/$WWW_DIR
|
||||||
|
fi
|
||||||
|
if [ ! -d /run/apache2 ]; then
|
||||||
|
mkdir /run/apache2
|
||||||
|
fi
|
||||||
|
chown -R 1000:apache /app/$WWW_DIR
|
||||||
|
chmod -R 755 /scripts/pre-init.d
|
||||||
|
mkdir -p /run/apache2
|
||||||
|
chown apache:apache /run/apache2
|
||||||
|
|
||||||
|
tmpsed='s#^DocumentRoot ".*#DocumentRoot "/app/'$WWW_DIR'"#g'
|
||||||
|
sed -i "$tmpsed" /etc/apache2/httpd.conf
|
||||||
|
sed -i 's#AllowOverride none#AllowOverride All#' /etc/apache2/httpd.conf
|
||||||
|
|
||||||
|
initTitle "Apache" "Loading Modules"
|
||||||
|
a2setModule 1 "rewrite"
|
||||||
|
a2setModule 1 "mpm_event"
|
||||||
|
a2setModule 1 "slotmem_shm"
|
||||||
|
a2setModule 1 "heartmonitor"
|
||||||
|
a2setModule 1 "watchdog"
|
||||||
|
initTitle "Apache" "Removing Modules"
|
||||||
|
a2setModule 0 "mpm_prefork"
|
||||||
|
a2setModule 0 "proxy_fdpass" /etc/apache2/conf.d/proxy.conf
|
||||||
|
echo
|
||||||
|
tmpsed="/etc/php7/php.ini"
|
||||||
|
sed -ir 's/expose_php = On/expose_php = Off/' $tmpsed
|
||||||
|
sed -i "s|;*date.timezone =.*|date.timezone = ${TZ}|i" $tmpsed
|
||||||
|
sed -i "s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= 0|i" $tmpsed
|
||||||
|
tmpsed="/etc/php7/php-fpm.conf"
|
||||||
|
sed -i "s|;*daemonize\s*=\s*yes|daemonize = no|g" $tmpsed
|
||||||
|
sed -i "s|;*listen\s*=\s*127.0.0.1:9000|listen = 9000|g" $tmpsed
|
||||||
|
sed -i "s|;*listen\s*=\s*/||g" $tmpsed
|
||||||
|
sed -i "s|pm = dynamic|pm = ondemand|g" $tmpsed
|
||||||
|
echo -e "\nIncludeOptional /app/vhost" >> /etc/apache2/httpd.conf
|
||||||
|
unset tmpsed
|
8
pluie/alpine-fpm-php7/main.sh
Executable file
8
pluie/alpine-fpm-php7/main.sh
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# @app pluie/alpine-apache
|
||||||
|
# @author a-Sansara https://git.pluie.org/pluie/docker-images
|
||||||
|
|
||||||
|
. /scripts/common.sh
|
||||||
|
|
||||||
|
initTitle "Starting" "Apache Daemon"
|
||||||
|
httpd -D FOREGROUND
|
11
pluie/alpine-fpm-php7/pre-init.d/10-apache.sh
Executable file
11
pluie/alpine-fpm-php7/pre-init.d/10-apache.sh
Executable file
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
# @app pluie/alpine-apache
|
||||||
|
# @author a-Sansara https://git.pluie.org/pluie/docker-images
|
||||||
|
|
||||||
|
if [ ! -z "$FIX_OWNERSHIP" ] && [ "$FIX_OWNERSHIP" -eq 1 ] && [ -d /app/$WWW_DIR ]; then
|
||||||
|
chown -R 1000:apache /app/$WWW_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch /var/log/apache2/error.log
|
||||||
|
|
||||||
|
tail -F /var/log/apache2/error.log &
|
27
pluie/alpine-fpm-php7/pre-init.d/10-vhost.sh
Executable file
27
pluie/alpine-fpm-php7/pre-init.d/10-vhost.sh
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
# @app pluie/alpine-apache
|
||||||
|
# @author a-Sansara https://git.pluie.org/pluie/docker-images
|
||||||
|
|
||||||
|
if [ ! -z "/app/vhost" ]; then
|
||||||
|
cat <<EOF > "/app/vhost"
|
||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName $HTTP_SERVER_NAME
|
||||||
|
SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
SetHandler proxy:fcgi://127.0.0.1:9000
|
||||||
|
</FilesMatch>
|
||||||
|
<Directory /app/$WWW_DIR>
|
||||||
|
AllowOverride None
|
||||||
|
Require all granted
|
||||||
|
DirectoryIndex $WWW_INDEX
|
||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
Options -MultiViews +FollowSymlinks
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteRule ^ $WWW_INDEX [QSA,L]
|
||||||
|
</IfModule>
|
||||||
|
</Directory>
|
||||||
|
</VirtualHost>
|
||||||
|
# IncludeOptional /app/vhost2
|
||||||
|
EOF
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user