DockerFile部署lnmp+memcached+redis+mongodb开发环境for PHP(三)

1、下载基础镜像centos
1
docker pull centos:6
2、查看一下大小
1
2
3
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos 6 70b5d81549ec 2 months ago 195MB
3、创建文件夹存放PHP的Dockerfile,以及源码包等等,为后期docker-compose做准备
1
mkdir -p /data/docker/lnmp-test/dockerfile/php
4、创建PHP的Dockerfile
1
vim /data/docker/lnmp-test/dockerfile/php/Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
FROM centos:6

LABEL maintainer="1012405802@qq.com" description="PHP image"

ENV PHP_VERSION 5.6.25

COPY extensions/ /root/extensions

RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6 \
&& yum install -y epel-release \
&& rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6 \
&& CONFIG="\
--prefix=/usr/local/php \
--with-config-file-path=/etc/php \
--with-config-file-scan-dir=/etc/php/conf.d \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-short-tags \
--enable-mbstring \
--with-curl \
--enable-sockets \
--enable-zip \
--enable-pcntl \
--with-bz2 \
--enable-inline-optimization \
--with-openssl \
--with-mhash \
--with-mcrypt \
--enable-mbregex \
--with-pcre-regex \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gd \
--with-jpeg-dir \
--with-zlib \
--with-png-dir \
--disable-rpath \
--enable-bcmath" \
&& yum install -y \
gcc \
gcc-c++ \
bison \
re2c \
libxml2-devel \
openssl-devel \
bzip2-devel \
libcurl-devel \
libjpeg-devel \
libpng-devel \
libmcrypt-devel \
unzip \
libmemcached-devel \
cyrus-sasl-devel \
ImageMagick-devel \
&& groupadd www \
&& useradd -s /sbin/nologin -M -g www www \
&& tar -zxvf /root/extensions/php-$PHP_VERSION.tar.gz -C /root/extensions/ \
&& cd /root/extensions/php-$PHP_VERSION \
&& ./configure $CONFIG \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& mkdir -p /etc/php/conf.d \
&& cp /root/extensions/php-$PHP_VERSION/php.ini-development /etc/php/php.ini \
&& cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
&& sed -i 's|^;\?pid\s*=\s*\(.\+\)|pid = \1|g; s|^;\?listen\s*=\s*.\+|listen = 9000|g' /usr/local/php/etc/php-fpm.conf \
&& sed -i 's|^;\?error_log\s*=\s*\(.\+\)|error_log = \1|g; s|^;\?daemonize\s*=\s*.\+|daemonize = no|g' /usr/local/php/etc/php-fpm.conf \
&& sed -i 's|^;\?slowlog\s*=\s*\(.\+\)|slowlog = \1|g; s|^;\?catch_workers_output\s*=\s*.\+|catch_workers_output = yes|g' /usr/local/php/etc/php-fpm.conf \
&& ln -s /usr/local/php/bin/* /usr/local/bin/ \
&& ln -s /usr/local/php/sbin/* /usr/local/sbin/ \
&& cd /root/extensions/ \
&& unzip igbinary-1.0.2.zip \
&& cd igbinary-1.0.2 \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& cd /root/extensions/ \
&& tar -zxvf libmemcached-1.0.18.tar.gz \
&& cd libmemcached-1.0.18 \
&& ./configure --prefix=/usr/local/libmemcached \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& cd /root/extensions/ \
&& unzip php-memcached-2.2.0.zip \
&& cd php-memcached-2.2.0 \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached/ \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& cd /root/extensions/ \
&& unzip cphalcon-3.0.3.zip \
&& cd cphalcon-3.0.3/build/php5/64bits/ \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& cd /root/extensions/ \
&& unzip phpredis-2.2.8.zip \
&& cd phpredis-2.2.8 \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& cd /root/extensions/ \
&& tar -zxvf imagick-3.1.1.tgz \
&& cd imagick-3.1.1 \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& cd /root/extensions/php-$PHP_VERSION/ext/bcmath/ \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& cd /root/extensions/ \
&& unzip apcu-4.0.8.zip \
&& cd apcu-4.0.8 \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& cd /root/extensions/ \
&& tar -zxvf mongodb-1.3.2.tgz \
&& cd mongodb-1.3.2 \
&& /usr/local/php/bin/phpize \
&& ./configure --with-php-config=/usr/local/php/bin/php-config \
&& make -j $(getconf _NPROCESSORS_ONLN) \
&& make install \
&& rm -rf /root/extensions/ \
&& yum clean all

EXPOSE 9000

CMD ["/usr/local/php/sbin/php-fpm", "-F", "-c", "/etc/php/php.ini"]
5、把php源码包和扩展包上传到/data/docker/lnmp-test/dockerfile/php/目录下
6、创建镜像
1
2
cd /data/docker/lnmp-test/dockerfile/php/
docker build -t centos6:php .
7、查看镜像大小
1
2
3
4
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
centos6 php 1d483171ba08 4 seconds ago 734MB
centos 6 70b5d81549ec 2 months ago 195MB
8、启动容器测试是否成功
1
docker run -d -p 9000:9000 --name php centos6:php

iSgR10.png

9、宿主机开启防火墙9000端口
1
2
firewall-cmd --add-port=9000/tcp --permanent
systemctl restart firewalld
博主QQ:1012405802
技术交流QQ群:830339411
版权声明:网站内容有原创和转载,如有侵权,请联系删除,谢谢!!
感谢打赏,93bok因你们而精彩!!(支付宝支持花呗)
0%