[TOC]
Compose 是一个工具,定义和运行复杂Docker应用。使用Compose,你定义多容器应用在当个文件中,然后将你的所有应用联系在一起,通过单一命令就可以完成运行这么多容器应用的事情。
3个版本的php会有大量的编译过程,已全部推送至阿里镜像仓库。下面2种安装方式选一即可
版本 | 远程地址 |
---|---|
php5.6 | registry.cn-shanghai.aliyuncs.com/ibaotu/php |
php7.1 | registry.cn-shanghai.aliyuncs.com/ibaotu/php7.1 |
php7.2 | registry.cn-shanghai.aliyuncs.com/ibaotu/php7.2 |
php8.1.4 | registry.cn-shanghai.aliyuncs.com/ibaotu/php8.1.4 |
- 下载发布文件
- 启动 docker-compose
cd 到docker-compose.yml 同级目录 执行 ./docker-run.sh
- 访问 http://127.0.0.1/ 查看是否正常启动
- git拉取docker-compose
git clone git@github.com:zhangjunjie6b/phpdocker.git
- 启动 docker-compose
cd 到docker-compose.yml 同级目录 执行 ./docker-run.sh
-
访问 http://127.0.0.1/ 查看是否正常启动
-
根据项目需求配置相应项目(见技术群内项目包)
操作系统 | 是否支持 |
---|---|
win10 专业版 | Y |
MAC | Y |
Linux | Y |
├── README.md
├── docker-compose.yml //compose文件
├── mysql
│ ├── Dockerfile
│ ├── conf
│ │ └── mysql.cnf
│ └── data //数据库文件映射
├── nginx
│ ├── Dockerfile
│ ├── conf.d //默认会读取此文件 *.conf
│ │ ├── default.conf
│ │ └── test.conf //127.0.0.1 测试配置
│ └── log
│ ├── access.log //访问日志
│ └── error.log //错误日志
├── php
│ ├── Dockerfile
| └── php-fpm.d //php-fpm 配置文件
│ └── conf
│ ├── php-fpm.conf
│ └── php.ini
├── redis
│ ├── Dockerfile
│ ├── data //redis持久化文件存储映射
│ └── redis-6379.conf
└── www //git 忽略下面所有文件
|
└── www_test //测试项目文件
版本 mysql:5.6 docker 基础镜像
本地 1.13.12 nginx 基础镜像
版本 5.6.35-fpm-jessie
已安装扩展
PHP5.6
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
gmp
hash
iconv
json
libxml
mbstring
mcrypt
mysql
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
scws
session
SimpleXML
soap
SPL
sqlite3
standard
swoole
tokenizer
xdebug
xml
xmlreader
xmlwriter
Zend OPcache
zlib
[Zend Modules]
Xdebug
Zend OPcache
PHP7.1
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
gmp
hash
iconv
imagick
json
libxml
mbstring
mcrypt
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
scws
session
SimpleXML
SPL
sqlite3
standard
swoole
tokenizer
xdebug
xml
xmlreader
xmlwriter
Zend OPcache
zlib
[Zend Modules]
Xdebug
Zend OPcache
swoole
swoole support => enabled
Version => 4.0.1
Author => tianfeng.han[email: mikan.tenny@gmail.com]
coroutine => enabled
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
openssl => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608
PHP7.2
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
grpc
hash
iconv
imagick
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
swoole
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
php8.1.4
[PHP Modules]
bcmath
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
grpc
hash
iconv
imagick
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
版本3.2.11 注:线上redis版本2.8 redis 基础镜像
redis 持久化配置分快照和写日志 这边只介绍写日志的配置,公司用的阿里服务所以有兴趣的同学可以私下交流
AOF:每次redis操作会写出操作日志,AOF会重写这些命令 减少磁盘占用量,加速恢复速度
命令 | always | everysec | no |
---|---|---|---|
优点 | 不丢失数据 | 每秒一次fsync丢一秒 | 不用惯 |
缺点 | IO开销较大,一般sata盘只有几百TPS | 丢一秒数据 | 不可控 |
- always (写命令刷新的缓冲区然后到硬盘)
- everysec (每秒写到硬盘)
- no(交给操作系统)
配置 | 含义 |
---|---|
auto-aof-rewrite-min-szie | AOF文件重新需要的尺寸 |
auto-aof-rewrite-percentage | AOF文件增长率 |
统计名 | 含义 |
---|---|
aof_current_size | AOF当前尺寸(单位:字节) |
aof_base_size | AOF上次启动和重写的尺寸(单位:字节) |
appendonly yes
appendfilename "appendonly-${port}.aof"
**appendfsync** everysec
dir /bigdiskpath
no-appendfsync-on-rewrite yes
服务名 | 宿主机 | 容器 |
---|---|---|
nginx | 80 443 | 80 433 |
mysql | 3308 | 3306 |
redis | 6378 | 6379 |
git pull docker-compose build docker-compose up
- 添加环境变量
export DOCKERHOST=$(ifconfig | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" | grep -v 127.0.0.1 | awk '{ print $2 }' | cut -f2 -d: | head -n1) \
- docker-compose.yml 配置相应的 环境变量 映射关系
- 如非 './docker-run.sh' 脚本启动,请屏蔽docker-compose.yml的环境变量映射关系