码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2018-09-21 10:57:48      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:group   redis   启动   分享   zip2   tar.gz   imp   class   efault   

本文源链接地址:https://www.93bok.com

1、下载基础镜像centos
docker pull centos:6
2、查看一下大小
docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              6                   70b5d81549ec        2 months ago        195MB
3、创建文件夹存放PHP的Dockerfile,以及源码包等等,为后期docker-compose做准备
mkdir -p /data/docker/lnmp-test/dockerfile/php
4、创建PHP的Dockerfile
vim /data/docker/lnmp-test/dockerfile/php/Dockerfile
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、创建镜像
cd /data/docker/lnmp-test/dockerfile/php/
docker build -t centos6:php .
7、查看镜像大小
docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos6             php                 1d483171ba08        4 seconds ago       734MB
centos              6                   70b5d81549ec        2 months ago        195MB
8、启动容器测试是否成功
docker run -d -p 9000:9000 --name php centos6:php

技术分享图片

9、宿主机开启防火墙9000端口
firewall-cmd --add-port=9000/tcp --permanent
systemctl restart firewalld

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

标签:group   redis   启动   分享   zip2   tar.gz   imp   class   efault   

原文地址:https://www.cnblogs.com/93bok/p/9684826.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!