博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Docker Compose部署lnmp
阅读量:5160 次
发布时间:2019-06-13

本文共 3748 字,大约阅读时间需要 12 分钟。

参考:

一、简介

  使用Dcoekr镜像部署lnmp(Linux、Nginx、MySQL、PHP7)。

  1.1 结构     

app└── src    └── index.phpdocker-compose.yml etc└── localtimemysql├── conf│   └── my.cnf└── mysqldbnginx├── ca│   ├── server.crt│   └── server.key├── conf.d│   └── test.conf└── nginx.confphp-fpm├── Dockerfile├── php-7.2.3.tar.gz├── php-fpm.conf├── php.ini├── var│   ├── log│   │   │   └── run│     └── www.conf# app 静态文件# /etc/localtime 同步时区# mysqldb 数据存储

  

二、部署

  2.1 php-fpm Dockerfile  

FROM centos:latestMAINTAINER bigbergRUN yum -y install gcc gcc-c++ gd-devel libxml2 libxml2-devel libcurl-devel \    openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng  \    freestyle freestyle-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-develADD php-7.2.3.tar.gz /tmp/RUN cd /tmp/php-7.2.3 \    && ./configure --prefix=/usr/local/php \    --with-curl --with-freetype-dir --with-gd \    --with-gettext --with-iconv-dir --with-kerberos \    --with-libdir=lib64 --with-libxml-dir --with-mysqli \    --with-openssl --with-pcre-regex --with-pdo-mysql \    --with-pdo-sqlite --with-pear --with-png-dir \    --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib \    --with-bz2 --with-mhash --enable-fpm --enable-bcmath \    --enable-libxml --enable-inline-optimization --enable-gd-native-ttf \    --enable-mbregex --enable-mbstring --enable-opcache \    --enable-pcntl --enable-shmop --enable-soap --enable-sockets \    --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip \    && make && make install \    && cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm \    && chmod a+x /etc/init.d/php-fpm \    && groupadd -g 1001 www \    && useradd -g 1001 -u 1001 wwwEXPOSE 9000CMD ["/usr/local/php/sbin/php-fpm", "--nodaemonize"]
Dockerfile

  2.2 docker-compose.yml

version: '3'services:  # web server  nginx:    image: nginx:latest    ports:      - "80:80"      - "443:443"    volumes:      # app,挂在目录      - ./app/src:/usr/share/nginx/html      # ngnix configs      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro      - ./nginx/conf.d/:/etc/nginx/conf.d/:ro      # certificates      - ./nginx/ca/server.crt/:/etc/nginx/server.crt:ro      - ./nginx/ca/server.key/:/etc/nginx/server.key:ro      - ./etc/localtime:/etc/localtime:ro    links:      - php:php-cgi  # PHP-FPM  php:    build: ./php-fpm    volumes:      - ./app/src:/usr/share/nginx/html      # php.ini      - ./php-fpm/php.ini:/usr/local/php/etc/php.ini:ro      - ./php-fpm/php-fpm.conf:/usr/local/php/etc/php-fpm.conf:ro      - ./php-fpm/www.conf:/usr/local/php/etc/php-fpm.d/www.conf:ro      - ./php-fpm/var:/usr/local/php/var      - ./etc/localtime:/etc/localtime:ro    links:      - mysql:mysql    ports:      - "9000:9000"    stdin_open: true    tty: true  # database  mysql:    image: mysql:latest    ports:      # Allow client to access 3306      - "3306:3306"    volumes:      # my.cnf      - ./mysql/conf/my.cnf:/etc/mysql/conf.d/my.cnf      # your data will be stored in ./mysql      - ./mysql/mysqldb:/var/lib/mysql      - ./etc/localtime:/etc/localtime:ro    environment:      - MYSQL_ROOT_PASSWORD=123456
View Code

  2.3 构建  

$ docker-compose up --build

  2.4 查看

$ docker-compose ps       Name                      Command               State                    Ports                  -------------------------------------------------------------------------------------------------------composelnmp_mysql_1   docker-entrypoint.sh mysqld      Up      0.0.0.0:3306->3306/tcp                  composelnmp_nginx_1   nginx -g daemon off;             Up      0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcpcomposelnmp_php_1     /usr/local/php/sbin/php-fp ...   Up      0.0.0.0:9000->9000/tcp

  相关文档:https://github.com/Bigberg/docker/tree/master/compose-lnmp

 

转载于:https://www.cnblogs.com/bigberg/p/8492197.html

你可能感兴趣的文章
wcf系列5天速成——第二天 binding的使用(2)
查看>>
Windows推包脚本
查看>>
CSS盒子模型
查看>>
PYthon帮助
查看>>
学习Javascript闭包(Closure)
查看>>
神经网络加速器应用实例:图像分类
查看>>
AtCoder Regular Contest 081
查看>>
Ant+Subversion总结
查看>>
H5 + 3D + AR/VR 综述
查看>>
HTML5新属性在Google浏览器中不能显示的问题
查看>>
Java 泛型初识
查看>>
Core Bluetooth Programming Guiding - Performing Common Central Role Tasks 粗译
查看>>
深复制和浅复制
查看>>
DP ZOJ 2745 01-K Code
查看>>
微信开发之消息接收--文本消息(五)
查看>>
Nginx+uWSGI+Django环境配置
查看>>
黑盒白盒测试方法
查看>>
《基础排序算法练习题》
查看>>
类Lisp解释器JavaScript实现
查看>>
关于字符串查找 charindex ,Patindex 还有一个like
查看>>