Clone project
git clone https://github.com/BurningBright/minishowcase
https://github.com/BurningBright/minishowcase
Pull images
https://hub.docker.com/_/php?tab=tags&page=1&name=5.6
pick version you like in dockerdocker pull php:5.6.40-fpm-alpine
alpine release is not popular as the ‘apk’ command install software is not as usual as debian
fedora
.
so it’s better to pull other version php image likedocker pull php:5.6.40-fpm-jessie
pull stable version nginx version image.docker pull nginx:stable
Prepare
Copy nginx configuration
start nginx container firstdocker run --name nginx-tmp -d nginx:stable
copy default.confdocker cp nginx-tmp:/etc/nginx/confi.d nginx-tmp/
delete tmp containerdocker rm nginx-tmp
Start php container
1 | docker run --name php-mini \ |
run image mapping container port 9000 to host port 9000, mapping host project file to container.
check php inner ip1
docker inspect --format='{{.NetworkSettings.IPAddress}}' php-mini
https://www.runoob.com/docker/docker-install-php.html
Start nginx container
modify conf.d/default.conf
1 | user nginx; |
https://www.jianshu.com/p/5edfbb2af389
fastcgi_pass 172.17.0.2:9000;
this line is php’s inner address.
start nginx1
2
3
4docker run --name nginx-mini \
-p 80:80 -v /Users/root/minishowcase:/var/www \
-v /Users/root/nginx-mini/conf.d:/etc/nginx/conf.d \
-d nginx:stable
check php status
add info.php
check php status http://127.0.0.1/info.php
1 |
|
Install php extenstion
minishowcase needs php ‘gd’ extenstion, it be used to make thumbnail picture.
cause i use apline version php image, it wasted alot of time to insatll.
firt apt
yum
is not command to install dependency in apline, apk
is the key.
https://blog.csdn.net/flame1980/article/details/98851803
get into php containerdocker exec -it php-mini bash
install gd and it’s dependencies1
2
3
4
5
6
7
8
9
10apk upgrade --update && apk add \
coreutils \
freetype-dev \
libjpeg-turbo-dev \
libltdl \
libmcrypt-dev \
libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
it’s better to write a Dockerfile
to build a integrated image
1 | FROM php:5.6.40-fpm-alpine |
check gd status
add gd.php
to checkout gd extenstion.1
2
3
4
5
6
7
8<?php
if(extension_loaded('gd')) {
echo 'gd ready';
foreach(gd_info() as $cate=>$value)
echo "$cate: $value";
} else
echo 'no gd';
?>
https://blog.csdn.net/wt1286331074/article/details/91425518
https://www.jb51.cc/php/139142.html