tp5 下载地址:http://www.thinkphp.cn/down.html

    创建目录 docker-environment,再分别创建 compose 文件夹(存放 compose 配置文件)和 www文件夹(项目目录),然后使用 unzip 将 tp5 解压到 docker-environment/www目录下。

    一般来说可以将 public 目录作为web目录,nginx 中只要挂载 public 目录,php-fpm 中则需要挂载整个目录。

一、Compose 编排

version: "3"
services:
  nginx:
    image: nginx:1.15.1-alpine
    container_name: nginx
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ../www/public:/var/www/html/public:rw
      - ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./conf/nginx/conf.d:/etc/nginx/conf.d:ro
      - ../logs/nginx:/var/log/nginx:rw
    networks:
      - net-php
    restart: always
    command: nginx -g 'daemon off;'

  php:
    image: registry.cn-qingdao.aliyuncs.com/php_fpm/5.6.37:v1
    container_name: php
    ports:
      - "9000:9000"
    volumes:
      - ../www:/var/www/html:rw
      - ./conf/php/php.ini:/usr/local/etc/php/php.ini:ro
      - ../logs/php:/usr/local/var/log:rw
    networks:
      - net-php
      - net-mysql
      - net-redis
    restart: always
    command: php-fpm

  mysql:
    image: mysql:5.6.40
    container_name: mysql
    ports:
      - "3306:3306"
    volumes:
      - ./conf/mysql/mysql.cnf:/etc/mysql/conf.d/mysql.cnf:ro
      - ../data/mysql:/var/lib/mysql:rw
    networks:
      - net-mysql
    environment:
      MYSQL_ROOT_PASSWORD: 123456
      MYSQL_DATABASE: eshop
      MYSQL_USER: djs
      MYSQL_PASSWORD: 111111
    restart: always
    command: "--character-set-server=utf8"

  redis:
    image: redis:3.2.11-alpine
    container_name: redis
    ports:
      - "6379:6379"
    volumes:
      - ../data/redis:/data:rw
    networks:
      - net-redis
    restart: always

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    container_name: phpmyadmin
    ports:
      - "8080:80"
    networks:
      - net-mysql
    environment:
      - PMA_HOST=mysql
      - PMA_PORT=3306

networks:
  net-php:
  net-mysql:
  net-redis:

    1、数据库连接错误

docker-compose安装lnmp+redis+thinkphp5-LMLPHP

        ~/docker-compose/www

        vi .evn

APP_NAMESPACE=app
[database]
type=mysql
hostname=mysql #mysql容器名
database=eshop #创建的数据库
username=djs #数据库账号
password=111111 #数据库密码
hostport=3306
charset=utf8
prefix=jz_
debug=true
03-02 00:41