coding_python 阅读(5) 评论(0)

 好久没写blog   做什么?   复习nginx  zabbix  docker-compos mariadb  学习 jenkins ansible ELK  搭了一下k8s (kubeadm)  也该好好静下心来整理整理   好了不说了 上demo

 

最近看到微信公众号一篇  

https://mp.weixin.qq.com/s?__biz=MzAwNTM5Njk3Mw==&mid=2247484709&idx=1&sn=155d4bbe0e3f5bd26193f519aeee8673&chksm=9b1c05a7ac6b8cb18de3236b5f0a0b9476300ff5262088da8830ed62e63434832dee830460a5&mpshare=1&scene=23&srcid=0710RUm3nqWCZExVCEVK3yxx#rd

   已事我就想拿来配个php-fpm 镜像来搭个LNMP 但事已愿为  到docker,hub   docker stroe.  阿里镜像 折腾了好几个小时 不是nginx php-fpm 就是 nginx ph[-fpm mysql 或就是 php not php-mysql    心累 无语 找不到自己心仪镜像  为有自己动手 来构建一下  php-fpm images

 

准备环境

宿主机(172.16.0.66)已编译了 

nginx-1.14    /usr/local/nginx

 php-5.3.29   /usr/local/php (先在基础镜像内构建php 扩展插件: gd php-mysql ..... 后CP二进制包进容器run)

mariadb   172.16.0.30:3306

project    /usr/www/html (网站配置文件已做修改connect DB)

docker version 17.05.0-ce

实现方式:

  宿主机启动 nginx , 连接方式 容器内 php ,  php  连接后端DB mariadb   172.16.0.30:3306  数据库已导入

dockerfile

# This is a commit

FROM ansible/centos7-ansible:latest 

MAINTAINER love coding <2373673@qq.com>

USER root

RUN  groupadd -g 1000 www 

RUN  useradd -u1001 -g www  -s  /bin/bash www

RUN  yum   install -y  supervisor  libcurl  curl-devel  bzip2 bzip2-devel  openssl-devel   libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel   libxml2 libxml2-devel gcc make libmcrypt-devel && yum clean all && rm -rf /var/cache/yum/* 

RUN  mkdir -p /usr/www/html && chown -R www:www /usr/www/html && mkdir -p /usr/local

COPY  php  /usr/local/php 

RUN   cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf &&chmod -R  o+x /usr/local/php

COPY  supervisord.conf /etc/supervisord.conf

RUN chown -R www:www /usr/local/php && sed -i "s/127.0.0.1/0.0.0.0/g" /usr/local/php/etc/php-fpm.conf

EXPOSE 9000

#CMD ["/usr/local/php-fpm/sbin/php-fpm"]
ENTRYPOINT ["/usr/bin/supervisord","-c","/etc/supervisord.conf"]

 

vim   /etc/supervisord.conf

 

[supervisord]
nodaemon=true

[program:php-fpm]
command=/usr/local/php/sbin/php-fpm

docker build -it php-fpm:v6 .

 

docker run -d -p 9000:9000 --name php-fpm-api -v /usr/www/html:/usr/www/html  php-fpm:v6  #运行php-fpm 容器

 /usr/local/nginx/sbin/nginx  #宿主机运行nginx