### docker-compose:lnmp+redis+mongo服务,php加载扩展,直接复制下方代码即可
```
version : '3.3'
services:
# mysql容器
mysql:
container_name: lnmp_mysql
image: mysql:5.7
restart: always
ports:
- 33061:3306
volumes:
# - ./mysql/my.cnf:/etc/mysql/my.cnf
- ./mysql/data:/var/lib/mysql #挂载数据目录到本地
- ./mysql/log:/var/log/mysql
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=256M
--default-authentication-plugin=mysql_native_password
--sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: '123456'
MYSQL_DATABASE: 'bjl_local_db'
MYSQL_USER: 'bjl_local_db'
MYSQL_PASSWORD: '123456'
privileged: true
#这里本人还配置了phpmyadmin容器,相当于连接mysql的客户端工具
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: lnmp_phpmyadmin
restart: always
ports:
- 8888:80
environment:
PMA_ARBITRARY: 1
TZ: Asia/Shanghai
UPLOAD_LIMIT: 500M
MYSQL_USERNAME: root
MYSQL_ROOT_PASSWORD: 123456
PMA_HOST: lnmp_mysql
privileged: true
# redis容器
redis:
container_name: lnmp_redis
image: redis:7.0
restart: always
# image: daocloud.io/library/redis:6.0.5-alpine
# image: redis:5.0
ports:
- 5000:6379
volumes:
# - ./redis/data:/data #挂载数据目录到本地
- ./redis/redis.conf:/etc/redis/redis.conf
- ./redis/logs:/logs
command: [ "redis-server","/etc/redis/redis.conf" ]
# privileged:true【使用该参数,container内的root拥有真正的root权限。否则,container内的root只是外部的一个普通用户权限】
privileged: true
# nginx容器
nginx:
container_name: lnmp_nginx
image: nginx
ports:
- 8080:80
- 4000:443
working_dir: /wwwroot
volumes_from:
- php #继承phpfpm挂载目录
volumes:
- ./html:/usr/share/nginx/html
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/conf.d:/etc/nginx/conf.d
- ./nginx/logs:/var/log/nginx
depends_on:
- php
links:
- php:php
restart: always
logging:
driver: 'json-file'
options:
max-size: '10g'
privileged: true
# mongoDb容器
mongo:
hostname: lnmp_mongo
container_name: lnmp_mongo
image: mongo:4.4.6
restart: always
command: mongod
logging:
driver: 'json-file'
options:
max-size: '10g'
volumes:
- ./mongo/config/mongod.conf:/etc/mongod.conf:rw
- ./mongo/configdb:/data/configdb:rw
- ./mongo/db:/data/db:rw
ports:
- "27000:27017"
environment:
TZ: Asia/Shanghai
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: 123456
privileged: true
# php容器
php:
container_name: lnmp_php
build:
context: ./php # dockerfile文件路径
dockerfile: Dockerfile # 指定dockerfile文件名称
ports:
- 9000:9000
tmpfs: /var/temp #上传临时文件夹
# links:
# - mysql
# - redis
# - mongo
links:
- mysql:mysql
- redis:redis
- mongo:mongo
environment:
TZ: Asia/Shanghai
working_dir: /wwwroot
volumes:
- ./wwwroot:/wwwroot #程序运行目录
- ./php/logs:/usr/local/var/log
restart: always
logging:
driver: 'json-file'
options:
max-size: '10g'
privileged: true
```
- Docker容器化部署使用说明书
- 环境部署
- Windows系统
- Windows部署Docker
- 安装过程可能碰到的问题总结
- Docker部署环境
- Docker hub操作
- Docker 部署 laravel5.5问题总结
- Docker处理中文乱码问题
- Linux系统
- Centos7.2部署Docker
- Linux部署Docker准备前工作
- 部署docker问题总结
- Linux部署Docker粗略笔记
- 安装git
- Docker命令大全
- 问题
- php7.4 安装xlswriter扩展
- php7.2 DockerFile文件
- dockerFile和docker-composer区别
- docker-compose的使用
- docker-compose的使用问题总结
- docker-compose
- Windows系统
- docker-compose.yml编写
- nginx目录如下
- conf.d
- default.conf
- nginx.conf
- php目录如下
- Dockerfile
- redis目录如下
- redis.conf
- docker-compose使用说明
- Linux系统
- /workspace/html/config_dev
- html
- index.html
- index.php
- nginx
- conf
- nginx.production.conf
- conf.d
- default.conf
- log
- access.log
- error.log
- Dockerfile
- php
- conf
- php.production.ini
- php-fpm.conf
- log(目录)
- php-fpm.d
- www.conf
- supervisor
- conf
- log
- Dockerfile
- .env
- docker-compose.yml