├── .dockerignore ├── .gitattributes ├── .github ├── FUNDING.yml └── workflows │ ├── blank.yml │ └── docker.yml ├── .gitignore ├── PHP_INSTALL.md ├── README.md ├── backup ├── mysql_auto_backup.sh └── nginx_log_cut.sh ├── conf ├── conf.d │ ├── 443.conf.sample │ ├── 80.conf │ ├── fastcgi.conf │ ├── fastcgi_params │ ├── localhost.lua.conf.sample │ ├── localhost.php.56.conf.sample │ ├── localhost.php.72.conf.sample │ ├── localhost.php.74.conf │ └── mime.types ├── etcd │ └── etcd.conf.yml ├── letsencrypt │ └── .gitignore ├── lua │ ├── bin │ │ ├── log.lua │ │ ├── resty-limit-req.lua │ │ └── resty-limit-traffic.lua │ └── test │ │ ├── http.lua │ │ ├── test.lua │ │ ├── test_mysql.lua │ │ └── test_redis_file.lua ├── mariadb │ └── my.cnf ├── mysql │ ├── my.cnf │ └── my8.0.cnf ├── nginx.conf ├── php │ ├── php-fpm.conf │ ├── php-fpm.d │ │ └── www.conf │ └── php.ini └── redis │ └── redis.conf ├── data ├── etcd │ └── .gitignore ├── mariadb │ └── .gitignore ├── mysql │ └── .gitignore └── redis │ └── .gitignore ├── docker-compose.yml ├── env.example ├── images ├── Docker_Install_mostov_twitter-_-facebook-2.png ├── SQL审核平台.png ├── dnmp-mysql.gif ├── docker-composer-https.png ├── docker-composer-lnmp.png ├── docker-data-clear.png ├── engine-components-flow.png └── scheduler-crontab.png ├── img └── engine-components-flow.png ├── log ├── nacos │ └── .gitignore ├── nginx │ └── .gitignore ├── php │ └── .gitignore └── redis │ └── .gitignore ├── services ├── nacos │ ├── Dockerfile │ ├── bin │ │ └── docker-startup.sh │ ├── conf │ │ └── application.properties │ ├── env │ │ ├── mysql.env │ │ ├── nacos-embedded.env │ │ ├── nacos-hostname.env │ │ ├── nacos-ip.env │ │ └── nacos-standlone-mysql.env │ ├── init.d │ │ └── custom.properties │ └── nacos-mysql.sql ├── php │ ├── Dockerfile │ └── extensions │ │ ├── amqp-1.9.4.tgz │ │ ├── event-2.5.3.tgz │ │ ├── grpc-1.33.1.tgz │ │ ├── install-php-extensions │ │ ├── install.sh │ │ ├── protobuf-3.13.0.1.tgz │ │ ├── rdkafka-6.0.1.tgz │ │ ├── redis-4.3.0.tgz │ │ ├── redis-5.3.4.tgz │ │ ├── swoole-4.6.7.tgz │ │ ├── xdebug-2.5.5.tgz │ │ ├── xdebug-2.9.0.tgz │ │ └── yaf-2.3.5.tgz └── php8 │ ├── Dockerfile │ └── extensions │ ├── event-3.0.6.tgz │ ├── install-php-extensions │ ├── install.sh │ └── redis-5.3.5.tgz ├── start.sh └── www └── site └── index.php /.dockerignore: -------------------------------------------------------------------------------- 1 | log/ 2 | mysql/ 3 | www/ -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | 3 | *.png binary 4 | *.jpg binary 5 | *.tgz binary 6 | *.zip binary 7 | *.gz binary -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | github: Tinywan 3 | custom: https://paypal.me/Tinywan 4 | -------------------------------------------------------------------------------- /.github/workflows/blank.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: Run a one-line script 13 | run: echo Hello, world! 14 | - name: Run a multi-line script 15 | run: | 16 | echo Add other actions to build, 17 | echo test, and deploy your project. 18 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: Run a one-line script 13 | run: echo Hello, world! 14 | - name: Run a multi-line script 15 | run: | 16 | echo Add other actions to build, 17 | echo test, and deploy your project. 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /dev/nginx/v2/www/tp5.1 2 | /dev/nginx/v2/www/tp5.2 3 | runtime 4 | thinkphp 5 | vendor 6 | /.idea 7 | /dnmp/*.env 8 | /dnmp/.env 9 | /.env 10 | -------------------------------------------------------------------------------- /PHP_INSTALL.md: -------------------------------------------------------------------------------- 1 | ## Docker php安装扩展步骤 2 | 3 | ### Docker 中的PHP容器安装扩展的方式有 4 | * 通过pecl方式安装 5 | * 通过php 容器中自带的几个特殊命令来安装,这些特殊命令可以在Dockerfile中的RUN命令中进行使用。 6 | 7 | 这里,我们主要讨论的是第二种方案,如何通过PHP容器中的几个特殊命令来安装PHP扩展 8 | 9 | #### PHP中安装扩展有几个特殊的命令 10 | * docker-php-source 11 | * docker-php-ext-install 12 | * docker-php-ext-enable 13 | * docker-php-ext-configure 14 | 15 | #### docker-php-source 16 | > 此命令,实际上就是在PHP容器中创建一个/usr/src/php的目录,里面放了一些自带的文件而已。我们就把它当作一个从互联网中下载下来的PHP扩展源码的存放目录即可。事实上,所有PHP扩展源码扩展存放的路径: /usr/src/php/ext 里面。 17 | 18 | 格式: 19 | 20 | ``` 21 | docker-php-source extract | delete 22 | ``` 23 | 24 | 参数说明: 25 | * extract : 创建并初始化 /usr/src/php目录 26 | * delete : 删除 /usr/src/php目录 27 | 28 | 案例: 29 | 30 | ```shell 31 | root@803cbcf702a4:/usr/src# ls -l 32 | total 11896 #此时,并没有php目录 33 | -rw-r--r-- 1 root root 12176404 Jun 28 03:23 php.tar.xz 34 | -rw-r--r-- 1 root root 801 Jun 28 03:23 php.tar.xz.asc 35 | 36 | root@803cbcf702a4:/usr/src# docker-php-source extract 37 | root@803cbcf702a4:/usr/src# ls -l 38 | total 11900 #此时,生产了php目录,里面还有一些文件,由于篇幅问题,就不进去查看了 39 | drwxr-xr-x 14 root root 4096 Aug 9 09:01 php 40 | -rw-r--r-- 1 root root 12176404 Jun 28 03:23 php.tar.xz 41 | -rw-r--r-- 1 root root 801 Jun 28 03:23 php.tar.xz.asc 42 | 43 | root@803cbcf702a4:/usr/src# docker-php-source delete 44 | root@803cbcf702a4:/usr/src# ls -l 45 | total 11896 #此时,将已创建 php 目录给删除了 46 | -rw-r--r-- 1 root root 12176404 Jun 28 03:23 php.tar.xz 47 | -rw-r--r-- 1 root root 801 Jun 28 03:23 php.tar.xz.asc 48 | 49 | root@803cbcf702a4:/usr/src# 50 | ``` 51 | 52 | #### docker-php-ext-enable 53 | 54 | 这个命令,就是用来启动 PHP扩展 的。使用pecl安装PHP扩展的时候,默认是没有启动这个扩展的,如果想要使用这个扩展必须要在php.ini这个配置文件中去配置一下才能使用这个PHP扩展。而 docker-php-ext-enable 这个命令则是自动给我们来启动PHP扩展的,不需要你去php.ini这个配置文件中去配置。 55 | 56 | **案例** 57 | 58 | ```shell 59 | # 查看现有可以启动的扩展 60 | root@517b9c67507a:/usr/local/etc/php# ls /usr/local/lib/php/extensions/no-debug-non-zts-20170718/ 61 | opcache.so redis.so sodium.so 62 | root@517b9c67507a:/usr/local/etc/php# 63 | 64 | # 查看redis 扩展是否可以启动 65 | root@517b9c67507a:/usr/local/etc/php# php -m | grep redis 66 | root@517b9c67507a:/usr/local/etc/php# 67 | 68 | # 启动 redis 扩展 69 | root@517b9c67507a:/usr/local/etc/php# docker-php-ext-enable redis 70 | # 启动 成功 71 | root@517b9c67507a:/usr/local/etc/php# php -m | grep redis 72 | redis 73 | root@517b9c67507a:/usr/local/etc/php# 74 | 75 | #说明,php容器中默认是没有php.ini配置文件的,加载原理如下所示 76 | 77 | root@517b9c67507a:/usr/local/etc/php# php -i | grep -A 5 php.ini 78 | Configuration File (php.ini) Path => /usr/local/etc/php 79 | Loaded Configuration File => (none) 80 | # 核心是 /usr/local/etc/php/conf.d 目录下的扩展配置文件 81 | Scan this dir for additional .ini files => /usr/local/etc/php/conf.d 82 | Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-redis.ini, 83 | /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini 84 | 85 | root@517b9c67507a:/usr/local/etc/php# 86 | ``` 87 | 88 | #### docker-php-ext-install 89 | 90 | 这个命令,是用来安装并启动PHP扩展的。 91 | 命令格式: 92 | 93 | ```dockerfile 94 | docker-php-ext-install “源码包目录名” 95 | ``` 96 | 97 | 注意点: 98 | 99 | “源码包“需要放在 `/usr/src/php/ext` 下。默认情况下,PHP容器没有 `/usr/src/php`这个目录,需要使用 `docker-php-source extract`来生成。 100 | `docker-php-ext-install` 安装的扩展在安装完成后,会自动调用`docker-php-ext-enable`来启动安装的扩展。 101 | 卸载扩展,直接删除/usr/local/etc/php/conf.d 对应的配置文件即可。 102 | 103 | 案例 104 | 105 | ```shell 106 | # 卸载redis 扩展 107 | root@803cbcf702a4:/usr/local# rm -rf /usr/local/etc/php/conf.d/docker-php-ext-redis.ini 108 | root@803cbcf702a4:/usr/local# php -m 109 | [PHP Modules] 110 | Core 111 | ctype 112 | curl 113 | date 114 | ... 115 | session 116 | zlib 117 | 118 | [Zend Modules] 119 | 120 | root@803cbcf702a4:/usr/local# 121 | 122 | #PHP容器默认是没有redis扩展的。所以我们通过docker-php-ext-install安装redis扩展 123 | 124 | root@803cbcf702a4:/# curl -L -o /tmp/reids.tar.gz https://codeload.github.com/phpredis/phpredis/tar.gz/5.0.2 125 | 126 | root@803cbcf702a4:/# cd /tmp 127 | root@517b9c67507a:/tmp# tar -xzf reids.tar.gz 128 | root@517b9c67507a:/tmp# ls 129 | phpredis-5.0.2 reids.tar.gz 130 | root@517b9c67507a:/tmp# docker-php-source extract 131 | root@517b9c67507a:/tmp# mv phpredis-5.0.2 /usr/src/php/ext/phpredis 132 | 133 | #检查移过去的插件源码包是否存在 134 | root@517b9c67507a:/tmp# ls -l /usr/src/php/ext | grep redis 135 | drwxrwxr-x 6 root root 4096 Jul 29 15:04 phpredis 136 | root@517b9c67507a:/tmp# docker-php-ext-install phpredis 137 | 138 | # 检查redis 扩展是否已经安装上 139 | root@517b9c67507a:/tmp# php -m | grep redis 140 | redis 141 | root@517b9c67507a:/tmp# 142 | ``` 143 | 144 | ### docker-php-ext-configure 145 | 146 | 一般都是需要跟 `docker-php-ext-install`搭配使用的。它的作用就是,当你安装扩展的时候,需要自定义配置时,就可以使用它来帮你做到。 147 | 148 | 案例 149 | 150 | ```dockerfile 151 | FROM php:7.1-fpm 152 | RUN apt-get update \ 153 | # 相关依赖必须手动安装 154 | && apt-get install -y \ 155 | libfreetype6-dev \ 156 | libjpeg62-turbo-dev \ 157 | libmcrypt-dev \ 158 | libpng-dev \ 159 | # 安装扩展 160 | && docker-php-ext-install -j$(nproc) iconv mcrypt \ 161 | # 如果安装的扩展需要自定义配置时 162 | && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ 163 | && docker-php-ext-install -j$(nproc) gd 164 | ``` 165 | 166 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![images](images/docker-composer-lnmp.png) 2 | 3 | [![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu) 4 | [![Build status](https://github.com/Tinywan/dnmp/workflows/CI/badge.svg)]() 5 | 6 | ## 快速使用 7 | 8 | 拉取代码 [国内Gitee地址](https://gitee.com/Tinywan/dnmp) 9 | 10 | ```php 11 | git clone git@github.com:Tinywan/dnmp.git 12 | cd dnmp 13 | ``` 14 | 15 | 新建配置文件 16 | ```php 17 | cp env.example .env 18 | ``` 19 | 20 | 开启容器服务 21 | 22 | ```php 23 | docker-compose up 24 | ``` 25 | > 守护进程 `docker-compose up -d` 26 | 27 | 单独重启容器服务 28 | ```php 29 | docker-compose up --no-deps -d nginx -- php74 30 | ``` 31 | > 如:在配置 `docker-compose.yml`中增加了nginx的端口号映射 32 | 33 | 打开浏览器访问 34 | 35 | [http://127.0.0.1](http://127.0.0.1) 36 | 37 | ## phpy 安装 38 | 39 | 修改`services/php8/Dockerfile` 找到一下文件,去掉注释 40 | ```ts 41 | # phpy install https://github.com/swoole/phpy 42 | RUN apk add python3 43 | RUN apk add autoconf gcc g++ make python3-dev 44 | ``` 45 | 修改`.env` 的 `PHP8.2`扩展`PHP82_EXTENSIONS=gd,phpy` 46 | 47 | ## :book: 目录 48 | 49 | - [快速使用](#快速使用) 50 | - [:book: 目录](#book-目录) 51 | - [Docker简介](#docker简介) 52 | - [为什么使用Docker](#为什么使用docker) 53 | - [如何清理您的Docker数据](#如何清理您的docker数据) 54 | - [1. 使用情况统计信息](#1-使用情况统计信息) 55 | - [2. 定期修剪](#2-定期修剪) 56 | - [3. 全面清理启动](#3-全面清理启动) 57 | - [4. 使用情况](#4-使用情况) 58 | - [项目结构](#项目结构) 59 | - [Nginx管理](#nginx管理) 60 | - [MySQL管理](#mysql管理) 61 | - [8.0 配置(2021.12.15)](#80-配置20211215) 62 | - [`.env`](#env) 63 | - [无法远程连接](#无法远程连接) 64 | - [PHP管理](#php管理) 65 | - [Redis管理](#redis管理) 66 | - [Composer管理](#composer管理) 67 | - [使用Docker安装](#使用docker安装) 68 | - [Linux环境](#linux环境) 69 | - [Windows环境](#windows环境) 70 | - [容器内](#容器内) 71 | - [宿主机](#宿主机) 72 | - [Crontab管理](#crontab管理) 73 | - [执行方案](#执行方案) 74 | - [宿主机执行任务(推荐)](#宿主机执行任务推荐) 75 | - [容器内执行任务](#容器内执行任务) 76 | - [配置任务调度器 scheduler](#配置任务调度器-scheduler) 77 | - [WebSocket管理](#websocket管理) 78 | - [phpMyAdmin管理](#phpmyadmin管理) 79 | - [容器管理](#容器管理) 80 | - [容器导出和导入](#容器导出和导入) 81 | - [save 导出镜像](#save-导出镜像) 82 | - [load 导入镜像](#load-导入镜像) 83 | - [证书管理](#证书管理) 84 | - [本地生成 HTTPS](#本地生成-https) 85 | - [Docker 生成 HTTPS](#docker-生成-https) 86 | - [Openresty专题](#openresty专题) 87 | - [RabbitMQ专题](#rabbitmq专题) 88 | - [Nacos专题](#nacos专题) 89 | - [配置数据库](#配置数据库) 90 | - [访问连接](#访问连接) 91 | - [SQL审核平台](#sql审核平台) 92 | - [MySQL 配置](#mysql-配置) 93 | - [etcd 一个高可用的分布式键值(key-value)数据库](#etcd-一个高可用的分布式键值key-value数据库) 94 | - [XDebug管理](#xdebug管理) 95 | - [遇到的问题](#遇到的问题) 96 | - [参考](#参考) 97 | - [mycli 工具安装使用](#mycli-工具安装使用) 98 | - [Git](#git) 99 | 100 | ## Docker简介 101 | 102 | Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。 103 | 104 | ## 为什么使用Docker 105 | 106 | - [x] 加速本地的开发和构建流程,容器可以在开发环境构建,然后轻松地提交到测试环境,并最终进入生产环境 107 | - [x] 能够在让独立的服务或应用程序在不同的环境中得到相同的运行结果 108 | - [x] 创建隔离的环境来进行测试 109 | - [x] 高性能、超大规划的宿主机部署 110 | - [x] 从头编译或者扩展现有的 OpenShift 或 Cloud Foundry 平台来搭建自己的 PaaS 环境 111 | ## 如何清理您的Docker数据 112 | Docker不会对您的系统进行任何配置更改,但是它会占用大量的磁盘空间 113 | 114 | ### 1. 使用情况统计信息 115 | ```powershell 116 | $ docker system df 117 | TYPE TOTAL ACTIVE SIZE RECLAIMABLE 118 | Images 25 13 9.467GB 4.368GB (46%) 119 | Containers 13 8 235MB 19.47MB (8%) 120 | Local Volumes 14 2 6.45GB 5.869GB (90%) 121 | Build Cache 0 0 0B 0B 122 | ``` 123 | ### 2. 定期修剪 124 | 为了安全地删除已停止的容器,未使用的网络和悬挂的图像,最好每隔一段时间运行以下命令 125 | ```powershell 126 | $ docker system prune 127 | WARNING! This will remove: 128 | - all stopped containers 129 | - all networks not used by at least one container 130 | - all dangling images 131 | - all dangling build cache 132 | 133 | Are you sure you want to continue? [y/N] y 134 | Deleted Containers: 135 | 5096cc97946c148450214a4330e35a67035289ecacc2806e9f693a0d46ebe75e 136 | ``` 137 | ### 3. 全面清理启动 138 | 可以使用单个命令擦除每个未使用的容器,图像,卷和网络 139 | ```powershell 140 | $ docker system prune -a --volumes 141 | WARNING! This will remove: 142 | - all stopped containers 143 | - all networks not used by at least one container 144 | - all volumes not used by at least one container 145 | - all images without at least one container associated to them 146 | - all build cache 147 | 148 | Are you sure you want to continue? [y/N] y 149 | Deleted Volumes: 150 | d8827bb292a529057fc972acb982a6f13b6608ed10132b9e9a689959cafec30e 151 | ... 152 | Deleted Images: 153 | untagged: dnmp_php72:latest 154 | deleted: sha256:1b29834e4f9054d78a0d5e91e114e40b865ad8ddce06a3c7ba3703f9911775e6 155 | 156 | Total reclaimed space: 12.71GB 157 | ``` 158 | ### 4. 使用情况 159 | 160 | ![docker-data-clear.png](images/docker-data-clear.png) 161 | 162 | [How to clean your Docker data](https://dockerwebdev.com/tutorials/clean-up-docker/) 163 | ## 项目结构 164 | 165 | ```powershell 166 | dnmp 167 | ├── docker-compose.yml -- 基础配置文件 168 | ├── env.example -- 环境配置文件,拷贝 env.example 为 .env 169 | ├── services -- 服务目录 170 | │   ├── php 171 | │   │   └── extensions -- 扩展目录 172 | │   │   └── Dockerfile -- 镜像构建文件 173 | │   ├── nacos 174 | │   │   └── conf -- 配置文件目录 175 | │   │   └── env -- 环境变量目录 176 | │   │   └── Dockerfile -- 镜像构建文件(构建比较耗时,不推荐) 177 | ├── conf 178 | │   ├── nginx.conf -- Nginx 主配置文件 179 | │   ├── conf.d 180 | │   │   └── 80.conf -- HTTP 80 虚拟主机扩展配置文件 181 | │   │   └── 443.conf -- HTTPS 虚拟主机扩展配置文件 182 | │   │   └── lua.conf -- Lua 配置虚拟主机扩展配置文件 183 | │   ├── letsencrypt -- Nginx 证书目录 184 | │   ├── mysql 185 | │ │   └── my.cnf -- MySQL 配置文件 186 | │   ├── etcd 187 | │ │   └── etcd.conf.yml -- Etcd 配置文件 188 | │   ├── redis 189 | │ │   └── redis.conf -- Redis 配置文件 190 | │   ├── php 191 | │ │   ├── php.ini -- PHP 运行核心配置文件 192 | │ │   ├── php-fpm.conf -- PHP-FPM 进程服务的配置文件 193 | │ │   └── php-fpm.d 194 | │ │    └── www.conf -- PHP-FPM 扩展配置文件 195 | │   └──lua -- Lua 脚本目录 196 | │      └── bin 197 | │      │ └── limit.lua -- 核心库脚本 198 | │      └── test 199 | │      └── http.lua -- 测试脚本 200 | ├── data -- 数据目录 201 | │   ├── redis 202 | │   │   ├── appendonly.aof -- AOF 数据库保存文件 203 | │   │   ├── dump.rdb -- RDB 数据库保存文件 204 | │   │   └── redis.log -- Redis 日志文件 205 | │   └── mysql -- MySQL 数据目录 206 | ├── log 207 | ├ ├── nginx -- Nginx 系统错误日志 208 | │ │   ├── access.log 209 | │ │   └── error.log 210 | │ └──redis -- Redis错误日志 211 | │ └──nacos -- Nacos错误日志 212 | │ └──php -- PHP错误日志 213 | └── www -- 项目代码目录 214 | └── site -- 具体项目目录 215 |    └──index.php 216 | ``` 217 | ## Nginx管理 218 | 219 | - 配置文件端口必须和 `docker-compose.yml`的`ports - 8088:80`中的映射出来的端口一一对应 220 | 221 | > 列如:`conf/conf.d/www.conf`中配置端口为 `80`,则映射端口也`80`,对应的映射端口为:`8088:80` 222 | 223 | - 重新加载配置文件 `docker exec -it dnmp-nginx nginx -s reload` 224 | 225 | > 或者 `docker exec dnmp-nginx nginx -s reload` 226 | 227 | - 在容器内执行 shell 命令:`docker exec -it dnmp-nginx sh -c "ps -aef | grep nginx | grep -v grep | grep master |awk '{print $2}'"` 228 | 229 | - [Nginx 日志定时备份和删除](./dnmp/backup/nginx_log_cut.sh) 230 | 231 | - 容器时间跟宿主机时间不一致 232 | - 原因:宿主机采用了 CST 时区。容器采用了 UTC 时区。 233 | - 复制主机的`localtime`: `docker cp /etc/localtime lnmp-nginx:/etc/` 234 | - 重启容器:`docker restart lnmp-nginx` 235 | 236 | ## MySQL管理 237 | 238 | - 进入容器:`docker exec -it dnmp-mysql /bin/bash` 239 | 240 | > Windows 环境使用:`docker exec -it dnmp-mysql bash` 241 | 242 | - 修改配置文件 `my.cnf`,重新加载:`docker-compose restart mysql` 243 | - 容器内连接:`mysql -uroot -p123456` 244 | - 外部宿主机连接:`mysql -h 127.0.0.1 -P 3308 -uroot -p123456` 245 | - 数据-备份-恢复 246 | - 导出(备份) 247 | - 导出数据库中的所有表结构和数据:`docker exec -it dnmp-mysql mysqldump -uroot -p123456 test > test.sql` 248 | - 只导结构不导数据:`docker exec -it dnmp-mysql mysqldump --opt -d -uroot -p123456 test > test.sql` 249 | - 只导数据不导结构:`docker exec -it dnmp-mysql mysqldump -t -uroot -p123456 test > test.sql` 250 | - 导出特定表的结构:`docker exec -it dnmp-mysql mysqldump -t -uroot -p123456 --table user > user.sql` 251 | - 导入(恢复)`docker exec -i dnmp-mysql -uroot -p123456 test < /home/www/test.sql` 252 | 253 | > 如果导入不成功,检查 sql 文件头部:`mysqldump: [Warning] Using a password on the command line interface can be insecure.`是否存在该内容,有则删除即可 254 | - [MySQL 备份小脚本](./dnmp/backup/nginx_log_cut.sh) 255 | > Crontab 任务:`55 23 * * * bash /backup/mysql_auto_backup.sh >/dev/null 2>&1` 256 | > 注意:crontab 定时执行 Docker 任务的时候是不需要添加参数 `-it`。`-t`是分配一个伪终端,但是 crontab 执行的时候实际是不需要的。 257 | - 项目配置文件建议: 258 | - root 默认不开开启远程访问 259 | - 新建项目用户 `www`,配置主机`Host`字段值为 MySQL 容器 ip 段`172.18.0.%` 260 | - 查看容器 IP address:`docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dnmp-mysql` 261 | 262 | ### 8.0 配置(2021.12.15) 263 | 264 | #### `.env` 265 | 266 | 修改配置 `MYSQL_CONF_FILE=./conf/mysql/my8.0.cnf` 267 | 268 | #### 无法远程连接 269 | 270 | 进入容器 271 | ``` 272 | docker exec -it dnmp-mysql bash 273 | ``` 274 | 275 | 连接MySQL 276 | ``` 277 | root@dnmp-mysql:\# msyql 278 | 279 | > use mysql; 280 | > update user set host = '%' where user = 'root'; 281 | > FLUSH PRIVILEGES; 282 | > alter user 'root'@'%' identified with mysql_native_password by '123456'; 283 | > FLUSH PRIVILEGES; 284 | 285 | ``` 286 | > 上面修改之后和重新连接即可 287 | 288 | ## PHP管理 289 | 290 | - docker安装PHP扩展常用命令 291 | 292 | - docker-php-source 293 | 294 | > 此命令,实际上就是在PHP容器中创建一个/usr/src/php的目录,里面放了一些自带的文件而已。我们就把它当作一个从互联网中下载下来的PHP扩展源码的存放目录即可。事实上,所有PHP扩展源码扩展存放的路径: /usr/src/php/ext 里面。 295 | 296 | - docker-php-ext-install 297 | 298 | > 这个命令,就是用来启动 PHP扩展 的。我们使用pecl安装PHP扩展的时候,默认是没有启动这个扩展的,如果想要使用这个扩展必须要在php.ini这个配置文件中去配置一下才能使用这个PHP扩展。而 docker-php-ext-enable 这个命令则是自动给我们来启动PHP扩展的,不需要你去php.ini这个配置文件中去配置。 299 | 300 | - docker-php-ext-enable 301 | 302 | > 这个命令,是用来安装并启动PHP扩展的。命令格:`docker-php-ext-install “源码包目录名”` 303 | 304 | - docker-php-ext-configure 305 | 306 | > 一般都是需要跟 docker-php-ext-install搭配使用的。它的作用就是,当你安装扩展的时候,需要自定义配置时,就可以使用它来帮你做到。 307 | 308 | - [Docker php安装扩展步骤](PHP_INSTALL.md) 309 | 310 | - 进入 php 容器 `docker exec -it dnmp-php /bin/bash` 311 | 312 | > 如果提示:`bash: export: [/bin/bash,': not a valid identifier`。删除配置文件`vim ~/.bashrc`末尾部分:`[/bin/bash, -c, source ~/.bashrc]` 313 | - 重启 php 服务 `docker-compose restart php` 314 | 315 | > 修改核心配置文件 `php.ini`,可使用该命令重新加载配置文件。 316 | > 修改扩展配置文件 `www.conf`,可使用该命令重新加载配置文件。 317 | 318 | - 服务管理 319 | 320 | - 配置测试:`docker exec -it dnmp-php bash -c "/usr/local/php/sbin/php-fpm -t"` 321 | - 启动:`docker exec -it dnmp-php bash -c "/usr/local/php/sbin/php-fpm"` 322 | - 关闭:`docker exec -it dnmp-php bash -c "kill -INT 1"` 323 | - 重启:`docker exec -it dnmp-php bash -c "kill -USR2 1"` 324 | - 查看 php-fpm 进程数:`docker exec -it dnmp-php bash -c "ps aux | grep -c php-fpm"` 325 | - 查看 PHP 版本:`docker exec -it dnmp-php bash -c "/usr/local/php/bin/php -v"` 326 | 327 | - 编译安装扩展 328 | 329 | - 1、下载:`cd /opt && git clone https://github.com/php/pecl-encryption-mcrypt.git` 330 | - 2、生成配置文件:`/usr/local/php/bin/phpize --with-php-config=/usr/local/php/bin/php-config` 331 | - 3、检测配置文件:`./configure --with-php-config=/usr/local/php/bin/php-config` 332 | - 4、编译:`make -j2` 333 | - 5、安装:`make install` 334 | - 6、修改`php.ini`配置文件:`vim /usr/local/php/etc/php.ini` 335 | - 7、重启`php-fpm`:`kill -USR2 1` 336 | 337 | - 服务器开机自动启 PHP 容器,[Ubuntu 18.04 rc.local systemd 设置](https://blog.csdn.net/dahuzix/article/details/80785691) 338 | 339 | ```powershell 340 | #!/bin/sh -e 341 | 342 | # docker-compose php container 343 | /usr/local/bin/docker-compose -f /home/www/dnmp/docker-compose.yml up -d 344 | 345 | # docker tab cron start 346 | sleep 10; docker exec lnmp-php bash -c "/etc/init.d/cron start" 347 | 348 | exit 0 349 | ``` 350 | 351 | > 编辑文件`vim /etc/rc.local`,添加以上内容 352 | > 以上主要是解决服务器重启后,PHP 容器不能够重启以及 PHP 容器之内的 Crontab 服务不能够启动的的问题,目前没有其他解决方案 353 | 354 | ## Redis管理 355 | 356 | - 连接 Redis 容器:`docker exec -it dnmp-redis redis-cli -h 127.0.0.1 -p 63789` 357 | - 通过容器连接:`docker exec -it dnmp-redis redis-cli -h dnmp-redis -p 63789` 358 | - 单独重启 redis 服务 `docker-compose up --no-deps -d redis` 359 | - 外部宿主机连接:`redis-cli -h 127.0.0.1 -p 63789` 360 | 361 | ## Composer管理 362 | 363 | ### 使用Docker安装 364 | 365 | #### Linux环境 366 | 367 | 进入项目目录,执行以下命令安装 368 | 369 | ``` 370 | docker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer install --ignore-platform-reqs 371 | ``` 372 | 373 | > `--ignore-platform-reqs` 参数表示官方 docker composer 库没有包含当前 PHP 版本 374 | 375 | #### Windows环境 376 | 377 | 安装一个新的 composer 包 378 | 379 | ```powershell 380 | E:\dnmp> docker run --rm --interactive --tty -v e:/dnmp/www/thinkphp_3.2:/app composer require tinywan/load-balancing --ignore-platform-reqs 381 | ``` 382 | 383 | > `tinywan/load-balancing` 为需要安装的包名 384 | 385 | 执行执行项目的绝对路径 386 | 387 | ```powershell 388 | E:\dnmp> docker run --rm --interactive --tty -v e:/dnmp/www/tp6:/app composer install --ignore-platform-reqs 389 | ``` 390 | 391 | > `tp6` 为项目目录 392 | 393 | ### 容器内 394 | 395 | - 需要进入`dnmp-php`容器: `docker exec -it dnmp-php /bin/bash` 396 | - 查看 `composer`版本:`composer --version` 397 | - 修改 composer 的全局配置文件(推荐方式) 398 | 399 | ```powershell 400 | composer config -g repo.packagist composer https://packagist.phpcomposer.com 401 | // 或者 402 | composer config -g repo.packagist composer https://packagist.laravel-china.org 403 | ``` 404 | 405 | > 如果你是墙内客户,务必添加以上国内镜像。否则会出现`file could not be downloaded (HTTP/1.1 404 Not Found)` 406 | 407 | - 更新框架或者扩展 408 | 409 | ```java 410 | /var/www/tp5.1# apt update 411 | /var/www/tp5.1# apt install sudo 412 | /var/www/tp5.1# sudo -u www-data sh -c "/usr/local/php/bin/php /usr/local/bin/composer install" 413 | ``` 414 | 415 | > 请使用`www-data` 更新安装包,而不是默认直接使用`root`账户, 416 | > 尽量使用`composer install` 更新安装包,而不是`composer update`, 417 | 418 | ### 宿主机 419 | 420 | 建议在主机 HOST 中使用 composer,避免 PHP 容器变得庞大,[Docker Official Images](https://hub.docker.com/_/composer) 421 | 422 | > 宿主机直接使用命令:`docker exec dnmp-php bash -c "cd /var/www/p2p_wallet; /usr/local/php/bin/php /usr/local/sbin/composer update"` 423 | 424 | - 1、在主机创建一个目录,用以保存 composer 的配置和缓存文件 425 | ``` 426 | mkdir ~/dnmp/composer 427 | ``` 428 | - 2、打开主机的 ~/.bashrc 或者 ~/.zshrc 文件,加上 429 | ```powershell 430 | composer () { 431 | tty= 432 | tty -s && tty=--tty 433 | docker run \ 434 | $tty \ 435 | --interactive \ 436 | --rm \ 437 | --user $(id -u):$(id -g) \ 438 | --volume ~/dnmp/composer:/tmp \ 439 | --volume /etc/passwd:/etc/passwd:ro \ 440 | --volume /etc/group:/etc/group:ro \ 441 | --volume $(pwd):/app \ 442 | composer "$@" 443 | } 444 | ``` 445 | - 3、让文件起效 446 | 447 | ```shell 448 | source ~/.bashrc 449 | ``` 450 | 451 | - 4、在主机的任何目录下就能用`composer`了 452 | ```powershell 453 | cd ~/dnmp/www/ 454 | composer create-project topthink/think tp5.2 455 | composer update topthink/framework 456 | ``` 457 | > 第一次执行提示:`Unable to find image 'composer:latest' locally`,不要慌,稍等片刻 458 | 459 | ## Crontab管理 460 | 461 | ### 执行方案 462 | 463 | - 1、使用主机的 cron 实现定时任务(推荐) 464 | - 2、创建一个新容器专门执行定时任务,[crontab for docker ](https://hub.docker.com/r/willfarrell/crontab) 465 | - 3、在原有容器上安装 cron,里面运行 2 个进程 466 | 467 | ### 宿主机执行任务(推荐) 468 | 469 | ```powershell 470 | # 2019年2月14日 @add Tinywan 获取图表数据 每3分钟执行一次 471 | */30 * * * * docker exec dnmp-php echo " Hi Lnmp " >> /var/www/crontab.log 472 | ``` 473 | 474 | > `dnmp-php` 为容器名称 475 | 476 | ### 容器内执行任务 477 | 478 | - 需要进入`dnmp-php`容器: `docker exec -it dnmp-php /bin/bash` 479 | - 手动启动 crontab,`/etc/init.d/cron start` 480 | - 添加 Crontab 任务 `crontab -e` 481 | - 添加任务输出日志到映射目录:`* * * * * echo " Hi dnmp " >> /var/www/crontab.log` 482 | - 定时执行 ThinkPHP5 自带命令行命令:`*/30 * * * * /usr/local/php/bin/php /var/www/tp5.1/think jobs hello` 483 | 484 | ### 配置任务调度器 scheduler 485 | 486 | 将下面内容添加到 crontab 计划任务中: 487 | 488 | ```php 489 | * * * * * /usr/local/bin/php /var/www/www.tinywan.com/scheduler.php 1>> /dev/null 2>&1 490 | ``` 491 | 492 | > 默认crontab 服务是没有启动的。需要启动Crontab 任务 `/var/www # crond start` 493 | 494 | ![images](images/scheduler-crontab.png) 495 | 496 | ## WebSocket管理 497 | 498 | 在项目中难免会用到 [workerman](https://github.com/walkor/Workerman) 499 | 500 | - 进入`dnmp-php`容器:`docker exec -it dnmp-php /bin/bash` 501 | - 以 daemon(守护进程)方式启动 workerman :`php ../workerman/start.php start -d` 502 | - 宿主机平滑重启 workerman :`docker exec -it dnmp-php bash -c "/usr/local/php/bin/php /var/www/site/think worker:gateway reload"` 503 | - 配置`docker-compose.yml` 文件中对应的映射端口 504 | 505 | ```powershell 506 | php: 507 | ports: 508 | - "9000:9000" 509 | - "9502:9502" # workerman 映射端口 510 | - "1239:1239" # Gateway 客户端 511 | ``` 512 | 513 | - 防火墙问题,如果使用阿里云 ESC,请在[安全组](https://ecs.console.aliyun.com/?spm=5176.2020520001#/securityGroup/region/cn-shanghai)增加**入方向**和**出方向**端口配置 514 | 515 | ```powershell 516 | 协议类型:自定义 TCP 517 | 端口范围:9502/9502 518 | 授权对象:0.0.0.0/0 519 | ``` 520 | 521 | - 宿主机可以查看对应端口号是否已经映射成功 522 | 523 | ```powershell 524 | ps -aux|grep 9502 525 | WorkerMan: worker process AppGateway websocket://0.0.0.0:9502 526 | ``` 527 | 528 | - 通过`telnet`命令检测远程端口是否打开 529 | 530 | ```powershell 531 | telnet 127.0.0.1 9502 532 | Trying 127.0.0.1... 533 | Connected to 127.0.0.1. 534 | Escape character is '^]'. 535 | ``` 536 | 537 | > 出现`Connected`表示连通了 538 | 539 | - 通过 Console 测试是否支持外网访问 540 | 541 | ```js 542 | var ws = new WebSocket('ws://宿主机公网ip:9502/'); 543 | ws.onmessage = function(event) { 544 | console.log('MESSAGE: ' + event.data); 545 | }; 546 | ƒ (event) { 547 | console.log('MESSAGE: ' + event.data); 548 | } 549 | MESSAGE: {"type":"docker","text":"Hi Tinywan"} 550 | ``` 551 | 552 | ## phpMyAdmin管理 553 | 554 | 主机上访问 phpMyAdmin 的地址:`http://localhost:8082`或者`http://宿主机Ip地址:8082` 555 | 556 | > 默认登录账户:`root`,密码:`123456` 557 | 558 | ## 容器管理 559 | 560 | ![images](images/engine-components-flow.png) 561 | 562 | - 查看容器网络 563 | 564 | ```powershell 565 | $ docker network ls 566 | ``` 567 | - 连接容器到用户自定义网桥 568 | 569 | ```powershell 570 | $ docker run -itd --name dnmp_yearning --network dnmp_backend -p 8000:8000 -e MYSQL_ADDR=dnmp-mysql:3306 zhangsean/yearning 571 | ``` 572 | 573 | - 重新单独构建镜像 574 | 575 | ```powershell 576 | $ docker-compose build # 重建全部服务 577 | $ docker-compose build php74 # 重建单个服务 578 | ``` 579 | 580 | - 进入 Docker 容器 581 | 582 | - Linux 环境 `$ docker exec -it dnmp-php bash` 583 | - Windows 环境 `$ winpty docker exec -it dnmp-php bash` 584 | 585 | - 关闭容器并删除服务`docker-compose down` 586 | 587 | - 单独重启 redis 服务 `docker-compose up --no-deps -d redis` 588 | 589 | > 如果用户只想重新部署某个服务,可以使用 `docker-compose up --no-deps -d ` 来重新创建服务并后台停止旧服务,启动新服务,并不会影响到其所依赖的服务。 590 | 591 | - 单独加载配置文件,列如修改了 nginx 配置文件`www.conf`中的内容,如何即使生效,请使用以下命令重启容器内的 Nginx 配置文件生效: 592 | 593 | ```powershell 594 | docker exec -it lnmp-nginx nginx -s reload 595 | ``` 596 | 597 | > `lnmp-nginx`为容器名称(`NAMES`),也可以指定容器的 ID 。`nginx`为服务名称(`docker-compose.yml`) 598 | 599 | - 修改`docker-compose.yml`文件之后,如何使修改的`docker-compose.yml`生效? 600 | 601 | ```powershell 602 | docker-compose up --no-deps -d nginx 603 | ``` 604 | 605 | > 以上表示只是修改了`docker-compose.yml`中关于 Nginx 相关服务器的配置 606 | 607 | - 容器资源使用情况 608 | 609 | - 所有运行中的容器资源使用情况:`docker stats` 610 | - 查看多个容器资源使用:`docker stats dnmp-nginx dnmp-php dnmp-mysql dnmp-redis` 611 | - 自定义格式的 docker 统计信息:`docker stats --all --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" dnmp-nginx dnmp-php` 612 | 613 | - docker-compose 常用命令 614 | 615 | - 启动`docker-compose.yml`定义的所有服务:`docker-compose up` 616 | - 重启`docker-compose.yml`中定义的所有服务:`docker-compose restart` 617 | - 停止`docker-compose.yml`中定义的所有服务(当前目录配置):`docker-compose stop` 618 | - 停止现有 docker-compose 中的容器:`docker-compose down`(重要) 619 | 620 | > 如果你修改了`docker-compose.yml`文件中的内容,请使用该命令,否则配置文件不会生效 621 | 622 | > 例如:Nginx 或者 MySQL 配置文件的端口 623 | 624 | - 重新拉取镜像:`docker-compose pull` 625 | - 后台启动 docker-compose 中的容器:`docker-compose up -d` 626 | 627 | - 查看容器详细信息 628 | - 获取实例的 IP 地址:`docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID` 629 | - 获取实例的 MAC 地址:`docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID` 630 | - 获取实例的日志路径:`docker inspect --format='{{.LogPath}}' $INSTANCE_ID` 631 | - 获取实例的镜像名称:`docker inspect --format='{{.Config.Image}}' $INSTANCE_ID` 632 | 633 | ### 容器导出和导入 634 | 635 | Docker镜像的导入导出,用于迁移、备份、升级等场景。涉及的命令有export、import、save、load 636 | 637 | #### save 导出镜像 638 | 639 | ```shell 640 | docker save -o composer-1.10.16.tar composer:1.10.16 641 | ``` 642 | 643 | > 注:composer:1.10.16 是本地已经存在的镜像。完成后会在本地生成一个 `composer-1.10.16.tar` 压缩包文件 644 | 645 | #### load 导入镜像 646 | 647 | 导入之前先删除本地已经有的镜像 648 | 649 | ```powershell 650 | $ docker rmi composer:1.10.16 651 | Untagged: composer:1.10.16 652 | Untagged: composer@sha256:b78ead723780b67237069394745f85284cd153ab6176b85f4be65b02db484224 653 | Deleted: sha256:eb14965007ad5c4427d4a3d9747b221a9ff9a2592e114db26280f434658f3dc8 654 | ``` 655 | 656 | 开始导入镜像 657 | 658 | ```bash 659 | $ docker load -i composer-1.10.16.tar 660 | ace0eda3e3be: Loading layer [==================================================>] 5.843MB/5.843MB 661 | 4f34707acc6f: Loading layer [==================================================>] 3.025MB/3.025MB 662 | c84148fa85b6: Loading layer [==================================================>] 11.78kB/11.78kB 663 | ea7d729a7e1b: Loading layer [==================================================>] 5.12kB/5.12kB 664 | 84dc4b3d5140: Loading layer [==================================================>] 10.37MB/10.37MB 665 | f2721b9bd68e: Loading layer [==================================================>] 4.096kB/4.096kB 666 | 8757a2dd4b44: Loading layer [==================================================>] 63.18MB/63.18MB 667 | 1a7224379637: Loading layer [==================================================>] 12.29kB/12.29kB 668 | de8d4e13caf2: Loading layer [==================================================>] 60.42kB/60.42kB 669 | cd74717e6911: Loading layer [==================================================>] 94.64MB/94.64MB 670 | 58d1af8009b9: Loading layer [==================================================>] 510kB/510kB 671 | 209722ef17f3: Loading layer [==================================================>] 4.096kB/4.096kB 672 | 8ae1fee25a6c: Loading layer [==================================================>] 2.005MB/2.005MB 673 | 644ab4ff51a2: Loading layer [==================================================>] 2.56kB/2.56kB 674 | b56d854a67b1: Loading layer [==================================================>] 1.536kB/1.536kB 675 | Loaded image: composer:1.10.16 676 | ``` 677 | 678 | 使用命令`docker images` 查看已经导入镜像 679 | 680 | > 注意:`export `和 `import` 导出的是一个容器的快照, 不是镜像本身, 也就是说没有 layer。你的 dockerfile 里的 workdir, entrypoint 之类的所有东西都会丢失,commit 过的话也会丢失。快照文件将丢弃所有的历史记录和元数据信息(即仅保存容器当时的快照状态),而镜像存储文件将保存完整记录,体积也更大。 681 | 682 | **区别和联系** 683 | 684 | - docker save 保存的是镜像(image),docker export 保存的是容器(container) 685 | - docker load 用来载入镜像包,docker import 用来载入容器包,但两者都会恢复为镜像 686 | - docker load 不能对载入的镜像重命名,而 docker import 可以为镜像指定新名称 687 | 688 | ## 证书管理 689 | 690 | ### 本地生成 HTTPS 691 | 692 | 生成本地 HTTPS 加密证书的工具 [mkcert](https://github.com/FiloSottile/mkcert),一个命令就可以生成证书,不需要任何配置。 693 | 694 | - 本地本地`C:\Windows\System32\drivers\etc\hosts`文件,添加以下内容 695 | 696 | ```powershell 697 | 127.0.0.1 dnmp.com 698 | 127.0.0.1 www.dnmp.org 699 | 127.0.0.1 www.dnmp.cn 700 | ``` 701 | 702 | - 一键生成证书。进入证书存放目录:`$ cd etc/letsencrypt/` 703 | 704 | - 首次运行时,先生成并安装根证书 705 | 706 | ```powershell 707 | $ mkcert --install 708 | Using the local CA at "C:\Users\tinywan\AppData\Local\mkcert" ✨ 709 | ``` 710 | 711 | - 自定义证书签名 712 | 713 | ```powershell 714 | $ mkcert dnmp.com "*.dnmp.org" "*.dnmp.cn" localhost 127.0.0.1 715 | Using the local CA at "C:\Users\tinywan\AppData\Local\mkcert" ✨ 716 | 717 | Created a new certificate valid for the following names 📜 718 | - "dnmp.com" 719 | - "*.dnmp.org" 720 | - "*.dnmp.cn" 721 | - "localhost" 722 | - "127.0.0.1" 723 | 724 | Reminder: X.509 wildcards only go one level deep, so this won't match a.b.dnmp.org ℹ️ 725 | 726 | The certificate is at "./dnmp.com+4.pem" and the key at "./dnmp.com+4-key.pem" ✅ 727 | ``` 728 | 729 | - 已经生成的证书 730 | 731 | ``` 732 | $ ls etc/letsencrypt/ 733 | dnmp.com+4.pem dnmp.com+4-key.pem 734 | ``` 735 | 736 | - 配置 Nginx 虚拟主机配置文件 737 | 738 | ```nginx 739 | server { 740 | listen 443 ssl http2; 741 | server_name www.dnmp.cn; 742 | 743 | ssl_certificate /etc/letsencrypt/dnmp.com+4.pem; 744 | ssl_certificate_key /etc/letsencrypt/dnmp.com+4-key.pem; 745 | ... 746 | } 747 | ``` 748 | 749 | - 浏览器访问效果 750 | 751 | ![images](images/docker-composer-https.png) 752 | 753 | ### Docker 生成 HTTPS 754 | 755 | ```powershell 756 | $ docker run --rm -it -v "D:\Git\docker-lnmp\dev\nginx\v5\etc\letsencrypt":/acme.sh \ 757 | -e Ali_Key="LTAIn" -e Ali_Secret="zLzA" neilpang/acme.sh --issue --dns dns_ali \ 758 | -d tinywan.top -d *.tinywan.top -d *.frps.tinywan.top 759 | ``` 760 | 761 | > 保存目录 762 | 763 | - Linux 环境 : `/home/www/openssl` 764 | - Windows 环境 : `D:\Git\docker-lnmp\dev\nginx\v5\etc\letsencrypt` 765 | 766 | > 参数详解(阿里云后台获取的密钥) 767 | 768 | - `Ali_Key` 阿里云 AccessKey ID 769 | - `Ali_Secret` 阿里云 Access Key Secret 770 | 771 | ## Openresty专题 772 | 773 | > 这里默认镜像标签为:`bionic` 774 | 775 | - 注意:如果你使用`alpine` and `stretch` 镜像标签,请单独安装`opm`,按照下面步骤安装既可 776 | 777 | - Usage:`cd dnmp/dev/openresty/v1 && docker-compose.exe up` 778 | 779 | - Installation [OPM](https://github.com/openresty/opm) `docker exec -it dnmp-openresty apk add --no-cache curl perl` 780 | 781 | > Windows `winpty docker exec -it dnmp-openresty apk add --no-cache curl perl` 782 | 783 | - 通过 opm install extend 784 | 785 | > search redis package `docker exec -it dnmp-openresty opm search redis` 786 | 787 | > install redis package `docker exec -it dnmp-openresty opm get openresty/lua-resty-redis` 788 | 789 | > install to specification directory `/usr/local/openresty/lualib/resty` 790 | 791 | ``` 792 | docker exec -it dnmp-openresty sh -c "opm --install-dir=/usr/local/openresty get ledgetech/lua-resty-http" 793 | ``` 794 | 795 | - 配置文件 796 | 797 | > 测试配置是否正确 `docker exec -it dnmp-openresty nginx -t` 798 | 799 | > 重新加载配置文件 `docker exec -it dnmp-openresty nginx -s reload` 800 | 801 | > 获取 Redis 容器的 IP 地址 `docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dnmp-redis-v2` 802 | 803 | > Nginx 日志时间时间不一致 804 | 805 | - 复制主机的 localtime `docker cp etc/localtime dnmp-openresty:/etc/` 806 | - 重启容器 `docker-compose restart openresty` 807 | 808 | ## RabbitMQ专题 809 | 810 | 管理界面地址:[http://127.0.0.1:15672/](http://127.0.0.1:15672/) 811 | 812 | ## Nacos专题 813 | 814 | Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。 815 | 816 | [官方地址:https://nacos.io/zh-cn/docs/what-is-nacos.html](https://nacos.io/zh-cn/docs/what-is-nacos.html) 817 | 818 | #### 配置数据库 819 | 820 | 数据库配置文件(单节点):`dnmp\services\nacos\env\nacos-standlone-mysql.env` 821 | 822 | 新建数据库:nacos 823 | 824 | 导入SQL文件:`dnmp\services\nacos\nacos-mysql.sql` 825 | 826 | #### 访问连接 827 | 828 | http://127.0.0.1:8848/nacos 829 | 830 | ## SQL审核平台 831 | 832 | https://guide.yearning.io/ 833 | 834 | 连接到网络 `dnmp_backend` 835 | ``` 836 | docker run -itd --name dnmp_yearning --network dnmp_backend -p 8000:8000 -e MYSQL_ADDR=dnmp-mysql:3306 -e MYSQL_USER=root -e MYSQL_PASSWORD=123456 -e MYSQL_DB=test zhangsean/yearning 837 | ``` 838 | ![images](images/SQL审核平台.png) 839 | 840 | 打开浏览器 http://127.0.0.1:8000 841 | 842 | 默认账号/密码:`admin/Yearning_admin` 843 | 844 | **二进制安装** 845 | 846 | ```shell 847 | wget https://github.com/cookieY/Yearning/releases/download/2.3.2.1/Yearning-2.3.2.2-linux-amd64.zip 848 | unzip Yearning-2.3.2.2-linux-amd64.zip 849 | vim conf.toml // 修改连接的数据库 850 | ./Yearning --help 851 | ./Yearning install 852 | ./Yearning run -port "8099" 853 | ``` 854 | 855 | 打开浏览器 http://127.0.0.1:8099 856 | 857 | ## MySQL 配置 858 | 859 | 1、新建数据库 `nacos` 860 | 2、切换数据库为 `nacos`,导入`./services/nacos/nacos-mysql.sql`文件 861 | 3、修改数据库配置文件 `./services/nacos/env/nacos-standlone-mysql.env` 862 | 4、重新启动 863 | ## [etcd](https://github.com/etcd-io/etcd) 一个高可用的分布式键值(key-value)数据库 864 | 865 | 1、安装 `sudo apt-get install etcd` 866 | 867 | 2、开启服务 `sudo service etcd start` 868 | 869 | 3、etcdctl 命令进行测试 870 | 871 | (1)设置和获取键值 testkey: "hello Tinywan",检查 etcd 服务是否启动成功 872 | 873 | (2)命令行执行 874 | 875 | ```powershell 876 | # etcdctl set testkey "hello Tinywan" # 设置 877 | hello Tinywan 878 | 879 | # etcdctl get testkey # 获取 880 | hello Tinywan 881 | 882 | # etcdctl rm testkey # 删除 883 | PrevNode.Value: hello Tinywan 884 | 885 | #etcdctl get testkey1 # 重新获取 886 | Error: 100: Key not found (/testkey1) [13] 887 | 888 | # # etcdctl set testkey "hello Tinywan" --ttl 10 # 设置一个过期时间 889 | ``` 890 | 891 | > 说明 etcd 服务已经成功启动了 892 | 893 | 4、通过 HTTP 访问本地 2379 或 4001 端口的方式来进行操作,例如查看 testkey 的值 894 | 895 | ``` 896 | # curl -L http://localhost:2379/v2/keys/testkey 897 | {"action":"get","node":{"key":"/testkey","value":"hello Tinywan","modifiedIndex":12,"createdIndex":12}} 898 | ``` 899 | 900 | 5、member 901 | 通过 list、add、remove 命令列出、添加、删除 etcd 实例到 etcd 集群中。 902 | 启动一个 etcd 服务实例后,可以用如下命令进行查看 903 | 904 | ``` 905 | # etcdctl member list 906 | 8e9e05c52164694d: name=8c831881add4 peerURLs=http://localhost:2380 clientURLs=http://localhost:2379 isLeader=true 907 | ``` 908 | 909 | ## XDebug管理 910 | 911 | - 镜像:`docker pull registry.cn-beijing.aliyuncs.com/tinywan/dnmp:php5.6-v2` 912 | - 配置文件映射路径: 913 | 914 | ```powershell 915 | volumes: 916 | - ./www:/var/www 917 | - ./etc/php.ini:/usr/local/etc/php/php.ini:ro 918 | - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf:rw 919 | - ./log:/var/log/php 920 | ``` 921 | 922 | - Google 浏览器安装 Xdebug 插件:[xdebug-helper](https://github.com/mac-cain13/xdebug-helper-for-chrome) 923 | 924 | - PHPStrom 默认配置就可以,打断点开始调试,默认不需要添加参数 925 | 926 | - Postman 断点调试(API接口),直接在后面增加`?XDEBUG_SESSION_START=PHPSTORM`参数,即:`http://www.tinywan.top:8007?XDEBUG_SESSION_START=PHPSTORM` 927 | 928 | ## 遇到的问题 929 | 930 | - 编译问题 `repository does not exist or may require 'docker login': denied: requested `,请检查`docker-compose.yml`文件格式 931 | 932 | - 连接 Redis 报错:`Connection refused`,其他客户端可以正常连接 933 | 934 | > 容器之间相互隔绝,在进行了端口映射之后,宿主机可以通过 127.0.0.1:6379 访问 redis,但 php 容器不行。在 php 中可以直接使用`hostname: lnmp-redis` 来连接 redis 容器。[原贴地址](https://stackoverflow.com/questions/42360356/docker-redis-connection-refused/42361204) 935 | 936 | - Windows 10 启动错误 `Error starting userland proxy: Bind for 127.0.0.1:3306: unexpected error Permission denied` 937 | 938 | > 检查本地是否有 MySQL 已经启动或者端口被占用。关闭即可 939 | 940 | - Linux 环境启动的时候,MySQL 总是`Restarting`:`lnmp-mysql docker-entrypoint.sh --def ... Restarting` 941 | 942 | > 解决办法:`cd etc/mysql`,查看文件权限。最暴力的:`rm -r data && mkdir data`解决问题 943 | 944 | - 权限问题 945 | - 遇到`mkdir(): Permission denied`问题,解决办法:`sudo chmod -R 777 runtime` 946 | - ThinkPHP5,`ErrorException in File.php line 29 mkdir(): Permission denied` 无法权限被拒绝 947 | - 执行命令:`chmod -R 777 runtime` 948 | - 如果图片上传也有问题:`chmod -R 777 upload` 949 | - `docker-compose.yml`文件格式错误 950 | 951 | ``` 952 | ERROR: yaml.scanner.ScannerError: while scanning for the next token 953 | found character '\t' that cannot start any token 954 | in "./docker-compose.yml", line 68, column 1 955 | ``` 956 | 957 | > 这里的原因是`docker-compose.yml`中最前面用了`tab`,改成空格就好了。对 yaml 文件格式要求严格 958 | 959 | - PHP 容器更新源或者使用 Composer 出现以下错误,请重启 Docekr(Windows 10 环境很容易出现这个问题) 960 | 961 | ``` 962 | # apt-get update 963 | Err:1 http://mirrors.163.com/ubuntu bionic InRelease 964 | Temporary failure resolving 'mirrors.163.com' 965 | ``` 966 | 967 | - Windows10 环境自动构建遇到的问题:`ERROR: http://mirrors.aliyun.com/..: temporary error (try again later)` 968 | 969 | > 解决办法:重启 Docker 服务 970 | 971 | ## 参考 972 | 973 | - [Dockerise your PHP application with Nginx and PHP7-FPM](http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/) 974 | - [docker-openresty](https://github.com/openresty/docker-openresty) 975 | - [Docker Volume 之权限管理(转)](https://www.cnblogs.com/jackluo/p/5783116.html) 976 | - [bind-mount 或者 COPY 时需要注意 用户、文件权限 的问题](https://segmentfault.com/a/1190000015233229) 977 | - [write in shared volumes docker](https://stackoverflow.com/questions/29245216/write-in-shared-volumes-docker) 978 | 979 | ![images](images/Docker_Install_mostov_twitter-_-facebook-2.png) 980 | 981 | ## [mycli](https://github.com/dbcli/mycli) 工具安装使用 982 | 983 | 1、安装vim `apt-get install vim` 984 | 985 | 2、更新源`vim sources.list`, 986 | 987 | (1)中科大源:`sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list` 988 | (2)直接编辑 `/etc/apt/sources.list` 文件 989 | ``` 990 | deb http://mirrors.163.com/debian/ stretch main non-free contrib 991 | deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib 992 | deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib 993 | deb-src http://mirrors.163.com/debian/ stretch main non-free contrib 994 | deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib 995 | deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib 996 | deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib 997 | deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib 998 | ``` 999 | > `degian9` 的163源 1000 | 1001 | 3、更新163源:`apt update` 1002 | 1003 | 4、安装mycli:`apt-get install mycli` 1004 | 1005 | 5、设置默认语言格式: `export LANG=C.UTF-8` 1006 | 1007 | 6、演示如下所示 1008 | 1009 | ![images](images/dnmp-mysql.gif) 1010 | 1011 | 7、直接通过外部连接`docker exec -it dnmp-mysql sh -c "export LANG=C.UTF-8 && mycli -h 127.0.0.1 -p123456"` 1012 | 1013 | 8、连接指定主机和用户 `mycli -h 127.0.0.1 -P 3306 -u www`,输入 www 用户密码即可 1014 | 1015 | 9、配置文件目录 `sudo vim /usr/share/mycli/mycli/myclirc`,官方配置:https://www.mycli.net/syntax 1016 | 1017 | ## Git 1018 | ``` 1019 | docker run -p 10022:22 -p 10080:3000 --name=gogs -v e:/gogs:/data -d gogs/gogs 1020 | ``` 1021 | -------------------------------------------------------------------------------- /backup/mysql_auto_backup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ####################################################### 3 | # $Name: mysql_auto_backup.sh 4 | # $Version: 1.0 5 | # $Function: Backup MySQL Databases Script 6 | # $Author: ShaoBo Wan (Tinywan) 7 | # $organization: https://github.com/Tinywan 8 | # $Description: 定期备份MySQL数据库 9 | # $Crontab: 57 23 * * * bash /tinywan/mysql_auto_backup.sh >/dev/null 2>&1 10 | ####################################################### 11 | 12 | # Shell Env 13 | SHELL_NAME="mysql_auto_backup.sh" 14 | 15 | BASE_PATH="/home/www/backup" 16 | 17 | # get current time 18 | CURRENT_TIME=$(date '+%Y-%m-%d-%H:%M:%S') 19 | 20 | # get data eg:201911 21 | DIR_NAME=$(date -d yesterday +"%Y%m") 22 | 23 | # get days eg:03 24 | DAY=$(date -d yesterday +"%d") 25 | 26 | # db name 27 | DB_NAME="juhepay" 28 | 29 | # backup path 30 | BACKUP_PATH=$BASE_PATH/$DB_NAME/$DIR_NAME 31 | 32 | # backup sql file name 33 | BACKUP_NAME=${DAY}".sql" 34 | 35 | # create log directory 36 | mkdir -p $BACKUP_PATH 37 | 38 | # run docker 39 | RES=$(docker exec lnmp-mysql mysqldump -uwww -pWWW@juhepay#2019_112233 $DB_NAME > $BACKUP_PATH/$BACKUP_NAME) 40 | echo $CURRENT_TIME-"备份结果:"$? >> $BACKUP_PATH".log" 41 | -------------------------------------------------------------------------------- /backup/nginx_log_cut.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ####################################################### 4 | # $Name: nginx_log_cut.sh 5 | # $Version: 1.0 6 | # $Function: Nginx Log Cut Script 7 | # $Author: ShaoBo Wan (Tinywan) 8 | # $Description: Nginx日志定时切割 9 | # $Crontab: 55 1 * * * bash /home/tinywan/shell/nginx_log_cut.sh >/dev/null 2>&1 10 | ####################################################### 11 | 12 | # get docker nginx PID 13 | pid=1 14 | 15 | #set the path save nginx log files 16 | base_path="/home/www/backup/logs" 17 | 18 | # get data eg:201611 19 | log_dir_name=$(date -d yesterday +"%Y%m") 20 | 21 | # get days eg:03 22 | DAY=$(date -d yesterday +"%d") 23 | 24 | # create log directory 25 | mkdir -p $base_path/$log_dir_name 26 | 27 | # set the path to nginx log 28 | log_files_path="/home/www/lnmp/log" 29 | 30 | #set nginx log files you want to cut eg: array 31 | log_files_names=(access error) 32 | 33 | #Set how long you want to save eg: 7 days 34 | save_mins=1 35 | 36 | #log file num eg: 2 37 | log_files_num=${#log_files_names[@]} 38 | 39 | #loop cut nginx log files 40 | for log_name in ${log_files_names[*]} 41 | do 42 | mv ${log_files_path}/${log_name}.log ${base_path}/${log_dir_name}/${log_name}_${DAY}.log 43 | done 44 | 45 | #向 Nginx 主进程发送 USR1 信号,USR1 信号是重新打开日志文件 46 | docker exec lnmp-nginx sh -c "kill -USR1 1" 47 | 48 | #delete 7 days ago nginx log files 49 | find $base_path -mindepth 1 -maxdepth 3 -type f -name "*.log" -mmin +$save_mins | xargs rm -rf -------------------------------------------------------------------------------- /conf/conf.d/443.conf.sample: -------------------------------------------------------------------------------- 1 | server { 2 | listen 443 ssl http2; 3 | server_name www.dnmp.cn; 4 | 5 | set $base /var/www; 6 | root $base; 7 | 8 | ssl_certificate /etc/letsencrypt/dnmp.com+4.pem; 9 | ssl_certificate_key /etc/letsencrypt/dnmp.com+4-key.pem; 10 | 11 | location / { 12 | if (!-e $request_filename) { 13 | rewrite ^(.*)$ /index.php?s=$1 last; 14 | break; 15 | } 16 | } 17 | 18 | # . files 19 | location ~ /\.(?!well-known) { 20 | deny all; 21 | } 22 | 23 | # assets, media 24 | location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ { 25 | expires 7d; 26 | access_log off; 27 | } 28 | 29 | # svg, fonts 30 | location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ { 31 | add_header Access-Control-Allow-Origin "*"; 32 | expires 7d; 33 | access_log off; 34 | } 35 | 36 | location ~ \.php$ { 37 | # 404 38 | try_files $fastcgi_script_name =404; 39 | 40 | # default fastcgi_params 41 | include fastcgi_params; 42 | 43 | # fastcgi settings 44 | fastcgi_pass lnmp-php:9000; 45 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 46 | fastcgi_index index.php; 47 | fastcgi_buffers 8 16k; 48 | fastcgi_buffer_size 32k; 49 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 50 | } 51 | 52 | # security headers 53 | add_header X-Frame-Options "SAMEORIGIN" always; 54 | add_header X-XSS-Protection "1; mode=block" always; 55 | add_header X-Content-Type-Options "nosniff" always; 56 | add_header Referrer-Policy "no-referrer-when-downgrade" always; 57 | add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always; 58 | add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; 59 | 60 | # gzip 61 | gzip on; 62 | gzip_vary on; 63 | gzip_proxied any; 64 | gzip_comp_level 6; 65 | gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml; 66 | } 67 | -------------------------------------------------------------------------------- /conf/conf.d/80.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name 127.0.0.1; 4 | root /var/www/site; 5 | 6 | # 被挂在的目录 7 | location / { 8 | if (!-e $request_filename) { 9 | rewrite ^(.*)$ /index.php?s=/$1 last; 10 | } 11 | } 12 | 13 | location ~ /\. { 14 | deny all; 15 | } 16 | 17 | location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { 18 | try_files $uri =404; 19 | } 20 | 21 | location ~* .(jpg|jpeg|png|gif|ico|css|js)$ { 22 | expires 1h; 23 | add_header Cache-Control public; 24 | add_header Pragma public; 25 | add_header Vary Accept-Encoding; 26 | } 27 | 28 | location ~ \.php$ { 29 | # 404 30 | try_files $fastcgi_script_name =404; 31 | # default fastcgi_params 32 | include fastcgi_params; 33 | # fastcgi settings 34 | fastcgi_pass php74:9000; 35 | fastcgi_index index.php; 36 | # fastcgi params 37 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 38 | fastcgi_intercept_errors on; 39 | fastcgi_buffers 8 16k; 40 | fastcgi_buffer_size 32k; 41 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 42 | } 43 | 44 | # security headers 45 | add_header X-Frame-Options "SAMEORIGIN" always; 46 | add_header X-XSS-Protection "1; mode=block" always; 47 | add_header X-Content-Type-Options "nosniff" always; 48 | add_header Referrer-Policy "no-referrer-when-downgrade" always; 49 | add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always; 50 | add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; 51 | # gzip 52 | gzip on; 53 | gzip_vary on; 54 | gzip_proxied any; 55 | gzip_comp_level 6; 56 | gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml; 57 | } 58 | -------------------------------------------------------------------------------- /conf/conf.d/fastcgi.conf: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 3 | fastcgi_param QUERY_STRING $query_string; 4 | fastcgi_param REQUEST_METHOD $request_method; 5 | fastcgi_param CONTENT_TYPE $content_type; 6 | fastcgi_param CONTENT_LENGTH $content_length; 7 | 8 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 | fastcgi_param REQUEST_URI $request_uri; 10 | fastcgi_param DOCUMENT_URI $document_uri; 11 | fastcgi_param DOCUMENT_ROOT $document_root; 12 | fastcgi_param SERVER_PROTOCOL $server_protocol; 13 | fastcgi_param REQUEST_SCHEME $scheme; 14 | fastcgi_param HTTPS $https if_not_empty; 15 | 16 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 17 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 18 | 19 | fastcgi_param REMOTE_ADDR $remote_addr; 20 | fastcgi_param REMOTE_PORT $remote_port; 21 | fastcgi_param SERVER_ADDR $server_addr; 22 | fastcgi_param SERVER_PORT $server_port; 23 | fastcgi_param SERVER_NAME $server_name; 24 | 25 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 26 | fastcgi_param REDIRECT_STATUS 200; 27 | -------------------------------------------------------------------------------- /conf/conf.d/fastcgi_params: -------------------------------------------------------------------------------- 1 | 2 | fastcgi_param QUERY_STRING $query_string; 3 | fastcgi_param REQUEST_METHOD $request_method; 4 | fastcgi_param CONTENT_TYPE $content_type; 5 | fastcgi_param CONTENT_LENGTH $content_length; 6 | 7 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 8 | fastcgi_param REQUEST_URI $request_uri; 9 | fastcgi_param DOCUMENT_URI $document_uri; 10 | fastcgi_param DOCUMENT_ROOT $document_root; 11 | fastcgi_param SERVER_PROTOCOL $server_protocol; 12 | fastcgi_param REQUEST_SCHEME $scheme; 13 | fastcgi_param HTTPS $https if_not_empty; 14 | 15 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 16 | fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; 17 | 18 | fastcgi_param REMOTE_ADDR $remote_addr; 19 | fastcgi_param REMOTE_PORT $remote_port; 20 | fastcgi_param SERVER_ADDR $server_addr; 21 | fastcgi_param SERVER_PORT $server_port; 22 | fastcgi_param SERVER_NAME $server_name; 23 | 24 | # PHP only, required if PHP was built with --enable-force-cgi-redirect 25 | fastcgi_param REDIRECT_STATUS 200; 26 | -------------------------------------------------------------------------------- /conf/conf.d/localhost.lua.conf.sample: -------------------------------------------------------------------------------- 1 | server { 2 | listen 802; 3 | server_name 127.0.0.1; 4 | 5 | # 访问地址:http://127.0.0.1/lua 6 | location /lua { 7 | default_type text/html; 8 | lua_code_cache off; # 关闭缓存 9 | content_by_lua_file conf/lua/test/test.lua; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /conf/conf.d/localhost.php.56.conf.sample: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name 127.0.0.1; 4 | root /var/www/site; 5 | 6 | # 被挂在的目录 7 | location / { 8 | if (!-e $request_filename) { 9 | rewrite ^(.*)$ /index.php?s=/$1 last; 10 | } 11 | } 12 | 13 | location ~ /\. { 14 | deny all; 15 | } 16 | 17 | location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { 18 | try_files $uri =404; 19 | } 20 | 21 | location ~* .(jpg|jpeg|png|gif|ico|css|js)$ { 22 | expires 1h; 23 | add_header Cache-Control public; 24 | add_header Pragma public; 25 | add_header Vary Accept-Encoding; 26 | } 27 | 28 | location ~ \.php$ { 29 | # 404 30 | try_files $fastcgi_script_name =404; 31 | # default fastcgi_params 32 | include fastcgi_params; 33 | # fastcgi settings 34 | fastcgi_pass php56:9000; 35 | fastcgi_index index.php; 36 | # fastcgi params 37 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 38 | fastcgi_intercept_errors on; 39 | fastcgi_buffers 8 16k; 40 | fastcgi_buffer_size 32k; 41 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 42 | } 43 | 44 | # security headers 45 | add_header X-Frame-Options "SAMEORIGIN" always; 46 | add_header X-XSS-Protection "1; mode=block" always; 47 | add_header X-Content-Type-Options "nosniff" always; 48 | add_header Referrer-Policy "no-referrer-when-downgrade" always; 49 | add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always; 50 | add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; 51 | # gzip 52 | gzip on; 53 | gzip_vary on; 54 | gzip_proxied any; 55 | gzip_comp_level 6; 56 | gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml; 57 | } 58 | -------------------------------------------------------------------------------- /conf/conf.d/localhost.php.72.conf.sample: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8072; 3 | server_name 127.0.0.1; 4 | root /var/www/site; 5 | 6 | # 被挂在的目录 7 | location / { 8 | if (!-e $request_filename) { 9 | rewrite ^(.*)$ /index.php?s=/$1 last; 10 | } 11 | } 12 | 13 | location ~ /\. { 14 | deny all; 15 | } 16 | 17 | location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { 18 | try_files $uri =404; 19 | } 20 | 21 | location ~* .(jpg|jpeg|png|gif|ico|css|js)$ { 22 | expires 1h; 23 | add_header Cache-Control public; 24 | add_header Pragma public; 25 | add_header Vary Accept-Encoding; 26 | } 27 | 28 | location ~ \.php$ { 29 | # 404 30 | try_files $fastcgi_script_name =404; 31 | # default fastcgi_params 32 | include fastcgi_params; 33 | # fastcgi settings 34 | fastcgi_pass php72:9000; 35 | fastcgi_index index.php; 36 | # fastcgi params 37 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 38 | fastcgi_intercept_errors on; 39 | fastcgi_buffers 8 16k; 40 | fastcgi_buffer_size 32k; 41 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 42 | } 43 | 44 | # security headers 45 | add_header X-Frame-Options "SAMEORIGIN" always; 46 | add_header X-XSS-Protection "1; mode=block" always; 47 | add_header X-Content-Type-Options "nosniff" always; 48 | add_header Referrer-Policy "no-referrer-when-downgrade" always; 49 | add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always; 50 | add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; 51 | # gzip 52 | gzip on; 53 | gzip_vary on; 54 | gzip_proxied any; 55 | gzip_comp_level 6; 56 | gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml; 57 | } 58 | -------------------------------------------------------------------------------- /conf/conf.d/localhost.php.74.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8074; 3 | server_name 127.0.0.1; 4 | root /var/www/site; 5 | 6 | # 被挂在的目录 7 | location / { 8 | if (!-e $request_filename) { 9 | rewrite ^(.*)$ /index.php?s=/$1 last; 10 | } 11 | } 12 | 13 | location ~ /\. { 14 | deny all; 15 | } 16 | 17 | location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { 18 | try_files $uri =404; 19 | } 20 | 21 | location ~* .(jpg|jpeg|png|gif|ico|css|js)$ { 22 | expires 1h; 23 | add_header Cache-Control public; 24 | add_header Pragma public; 25 | add_header Vary Accept-Encoding; 26 | } 27 | 28 | location ~ \.php$ { 29 | # 404 30 | try_files $fastcgi_script_name =404; 31 | # default fastcgi_params 32 | include fastcgi_params; 33 | # fastcgi settings 34 | fastcgi_pass php74:9000; 35 | fastcgi_index index.php; 36 | # fastcgi params 37 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 38 | fastcgi_intercept_errors on; 39 | fastcgi_buffers 8 16k; 40 | fastcgi_buffer_size 32k; 41 | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 42 | } 43 | 44 | # security headers 45 | add_header X-Frame-Options "SAMEORIGIN" always; 46 | add_header X-XSS-Protection "1; mode=block" always; 47 | add_header X-Content-Type-Options "nosniff" always; 48 | add_header Referrer-Policy "no-referrer-when-downgrade" always; 49 | add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always; 50 | add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; 51 | # gzip 52 | gzip on; 53 | gzip_vary on; 54 | gzip_proxied any; 55 | gzip_comp_level 6; 56 | gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml; 57 | } 58 | -------------------------------------------------------------------------------- /conf/conf.d/mime.types: -------------------------------------------------------------------------------- 1 | 2 | types { 3 | text/html html htm shtml; 4 | text/css css; 5 | text/xml xml; 6 | image/gif gif; 7 | image/jpeg jpeg jpg; 8 | application/javascript js; 9 | application/atom+xml atom; 10 | application/rss+xml rss; 11 | 12 | text/mathml mml; 13 | text/plain txt; 14 | text/vnd.sun.j2me.app-descriptor jad; 15 | text/vnd.wap.wml wml; 16 | text/x-component htc; 17 | 18 | image/png png; 19 | image/svg+xml svg svgz; 20 | image/tiff tif tiff; 21 | image/vnd.wap.wbmp wbmp; 22 | image/webp webp; 23 | image/x-icon ico; 24 | image/x-jng jng; 25 | image/x-ms-bmp bmp; 26 | 27 | application/font-woff woff; 28 | application/java-archive jar war ear; 29 | application/json json; 30 | application/mac-binhex40 hqx; 31 | application/msword doc; 32 | application/pdf pdf; 33 | application/postscript ps eps ai; 34 | application/rtf rtf; 35 | application/vnd.apple.mpegurl m3u8; 36 | application/vnd.google-earth.kml+xml kml; 37 | application/vnd.google-earth.kmz kmz; 38 | application/vnd.ms-excel xls; 39 | application/vnd.ms-fontobject eot; 40 | application/vnd.ms-powerpoint ppt; 41 | application/vnd.oasis.opendocument.graphics odg; 42 | application/vnd.oasis.opendocument.presentation odp; 43 | application/vnd.oasis.opendocument.spreadsheet ods; 44 | application/vnd.oasis.opendocument.text odt; 45 | application/vnd.openxmlformats-officedocument.presentationml.presentation 46 | pptx; 47 | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet 48 | xlsx; 49 | application/vnd.openxmlformats-officedocument.wordprocessingml.document 50 | docx; 51 | application/vnd.wap.wmlc wmlc; 52 | application/x-7z-compressed 7z; 53 | application/x-cocoa cco; 54 | application/x-java-archive-diff jardiff; 55 | application/x-java-jnlp-file jnlp; 56 | application/x-makeself run; 57 | application/x-perl pl pm; 58 | application/x-pilot prc pdb; 59 | application/x-rar-compressed rar; 60 | application/x-redhat-package-manager rpm; 61 | application/x-sea sea; 62 | application/x-shockwave-flash swf; 63 | application/x-stuffit sit; 64 | application/x-tcl tcl tk; 65 | application/x-x509-ca-cert der pem crt; 66 | application/x-xpinstall xpi; 67 | application/xhtml+xml xhtml; 68 | application/xspf+xml xspf; 69 | application/zip zip; 70 | 71 | application/octet-stream bin exe dll; 72 | application/octet-stream deb; 73 | application/octet-stream dmg; 74 | application/octet-stream iso img; 75 | application/octet-stream msi msp msm; 76 | 77 | audio/midi mid midi kar; 78 | audio/mpeg mp3; 79 | audio/ogg ogg; 80 | audio/x-m4a m4a; 81 | audio/x-realaudio ra; 82 | 83 | video/3gpp 3gpp 3gp; 84 | video/mp2t ts; 85 | video/mp4 mp4; 86 | video/mpeg mpeg mpg; 87 | video/quicktime mov; 88 | video/webm webm; 89 | video/x-flv flv; 90 | video/x-m4v m4v; 91 | video/x-mng mng; 92 | video/x-ms-asf asx asf; 93 | video/x-ms-wmv wmv; 94 | video/x-msvideo avi; 95 | } 96 | -------------------------------------------------------------------------------- /conf/etcd/etcd.conf.yml: -------------------------------------------------------------------------------- 1 | # This is the configuration file for the etcd server. 2 | 3 | # Human-readable name for this member. 4 | name: 'default' 5 | 6 | # Path to the data directory. 7 | data-dir: 8 | 9 | # Path to the dedicated wal directory. 10 | wal-dir: 11 | 12 | # Number of committed transactions to trigger a snapshot to disk. 13 | snapshot-count: 10000 14 | 15 | # Time (in milliseconds) of a heartbeat interval. 16 | heartbeat-interval: 100 17 | 18 | # Time (in milliseconds) for an election to timeout. 19 | election-timeout: 1000 20 | 21 | # Raise alarms when backend size exceeds the given quota. 0 means use the 22 | # default quota. 23 | quota-backend-bytes: 0 24 | 25 | # List of comma separated URLs to listen on for peer traffic. 26 | listen-peer-urls: http://127.0.0.1:2380 27 | 28 | # List of comma separated URLs to listen on for client traffic. 29 | listen-client-urls: http://127.0.0.1:2379 30 | 31 | # Maximum number of snapshot files to retain (0 is unlimited). 32 | max-snapshots: 5 33 | 34 | # Maximum number of wal files to retain (0 is unlimited). 35 | max-wals: 5 36 | 37 | # Comma-separated white list of origins for CORS (cross-origin resource sharing). 38 | cors: 39 | 40 | # List of this member's peer URLs to advertise to the rest of the cluster. 41 | # The URLs needed to be a comma-separated list. 42 | initial-advertise-peer-urls: http://127.0.0.1:2380 43 | 44 | # List of this member's client URLs to advertise to the public. 45 | # The URLs needed to be a comma-separated list. 46 | advertise-client-urls: http://127.0.0.1:2379 47 | 48 | # Discovery URL used to bootstrap the cluster. 49 | discovery: 50 | 51 | # Valid values include 'exit', 'proxy' 52 | discovery-fallback: 'proxy' 53 | 54 | # HTTP proxy to use for traffic to discovery service. 55 | discovery-proxy: 56 | 57 | # DNS domain used to bootstrap initial cluster. 58 | discovery-srv: 59 | 60 | # Initial cluster configuration for bootstrapping. 61 | initial-cluster: 62 | 63 | # Initial cluster token for the etcd cluster during bootstrap. 64 | initial-cluster-token: 'etcd-cluster' 65 | 66 | # Initial cluster state ('new' or 'existing'). 67 | initial-cluster-state: 'new' 68 | 69 | # Reject reconfiguration requests that would cause quorum loss. 70 | strict-reconfig-check: false 71 | 72 | # Accept etcd V2 client requests 73 | enable-v2: true 74 | 75 | # Enable runtime profiling data via HTTP server 76 | enable-pprof: true 77 | 78 | # Valid values include 'on', 'readonly', 'off' 79 | proxy: 'off' 80 | 81 | # Time (in milliseconds) an endpoint will be held in a failed state. 82 | proxy-failure-wait: 5000 83 | 84 | # Time (in milliseconds) of the endpoints refresh interval. 85 | proxy-refresh-interval: 30000 86 | 87 | # Time (in milliseconds) for a dial to timeout. 88 | proxy-dial-timeout: 1000 89 | 90 | # Time (in milliseconds) for a write to timeout. 91 | proxy-write-timeout: 5000 92 | 93 | # Time (in milliseconds) for a read to timeout. 94 | proxy-read-timeout: 0 95 | 96 | client-transport-security: 97 | # Path to the client server TLS cert file. 98 | cert-file: 99 | 100 | # Path to the client server TLS key file. 101 | key-file: 102 | 103 | # Enable client cert authentication. 104 | client-cert-auth: false 105 | 106 | # Path to the client server TLS trusted CA cert file. 107 | trusted-ca-file: 108 | 109 | # Client TLS using generated certificates 110 | auto-tls: false 111 | 112 | peer-transport-security: 113 | # Path to the peer server TLS cert file. 114 | cert-file: 115 | 116 | # Path to the peer server TLS key file. 117 | key-file: 118 | 119 | # Enable peer client cert authentication. 120 | client-cert-auth: false 121 | 122 | # Path to the peer server TLS trusted CA cert file. 123 | trusted-ca-file: 124 | 125 | # Peer TLS using generated certificates. 126 | auto-tls: false 127 | 128 | # Enable debug-level logging for etcd. 129 | debug: false 130 | 131 | logger: zap 132 | 133 | # Specify 'stdout' or 'stderr' to skip journald logging even when running under systemd. 134 | log-outputs: [stderr] 135 | 136 | # Force to create a new one member cluster. 137 | force-new-cluster: false 138 | 139 | auto-compaction-mode: periodic 140 | auto-compaction-retention: "1" 141 | -------------------------------------------------------------------------------- /conf/letsencrypt/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /conf/lua/bin/log.lua: -------------------------------------------------------------------------------- 1 | local ctx = ngx.ctx 2 | local lim = ctx.limit_conn 3 | if lim then 4 | -- if you are using an upstream module in the content phase, 5 | -- then you probably want to use $upstream_response_time 6 | -- instead of $request_time below. 7 | local latency = tonumber(ngx.var.request_time) 8 | local key = ctx.limit_conn_key 9 | assert(key) 10 | local conn, err = lim:leaving(key, latency) 11 | if not conn then 12 | ngx.log(ngx.ERR, 13 | "failed to record the connection leaving ", 14 | "request: ", err) 15 | return 16 | end 17 | end -------------------------------------------------------------------------------- /conf/lua/bin/resty-limit-req.lua: -------------------------------------------------------------------------------- 1 | --[[----------------------------------------------------------------------- 2 | * | Copyright (C) Shaobo Wan (Tinywan) 3 | * |------------------------------------------------------------------------ 4 | * | Author: Tinywan 5 | * | Date Time : 2019/5/28 16:25 6 | * | Email: Overcome.wan@Gmail.com 7 | * | Desc: 网关接口限流 8 | * | 1. Redis 白名单过滤 9 | * | 2. limit 限流 10 | * |------------------------------------------------------------------------ 11 | --]] 12 | 13 | local redis = require "resty.redis" 14 | local limit_req = require "resty.limit.req" 15 | local var = ngx.var 16 | 17 | local rate = 1 --固定平均速率2r/s 18 | local burst = 3 --桶容量 19 | local error_status = 503 20 | local nodelay = false --是否需要不延迟处理 21 | 22 | -- redis config 23 | local redis_host = "172.19.0.1" 24 | local redis_port = 6379 25 | local redis_timeout = 1000 26 | local red = redis:new() 27 | red:set_timeout(redis_timeout) 28 | local ok, err = red:connect(redis_host, redis_port) 29 | if not ok then 30 | ngx.log(ngx.ERR, "connect to redis error : ", err) 31 | end 32 | 33 | -- filter ip 34 | local ip = ngx.var.remote_addr 35 | ngx.log(ngx.ERR, "remote_addr: "..ip) 36 | --ngx.log(ngx.ERR, "referrer: "..var.referrer) 37 | local black_key = "IP:BLACK:LIST" 38 | local is_ok = red:SISMEMBER(black_key,ip) 39 | if (tonumber(is_ok) == 1) then 40 | --ngx.exit(ngx.HTTP_FORBIDDEN) 41 | ngx.redirect("https://github.com/Tinywan", 302) 42 | end 43 | 44 | -- limit rate 45 | local lim, err = limit_req.new("my_req_store", rate, burst) 46 | if not lim then --没定义共享字典 47 | ngx.exit(error_status) 48 | end 49 | 50 | local key = ngx.var.binary_remote_addr --IP维度限流 51 | --请求流入,如果你的请求需要被延迟则返回delay>0 52 | local delay, err = lim:incoming(key, true) 53 | 54 | if not delay then 55 | if err == "rejected" then 56 | -- add ip to black_list 57 | -- red:add(black_key,ip) 58 | ngx.log(ngx.ERR, "ip : ", ip) 59 | ngx.log(ngx.ERR, "redis: add ", red:sadd(black_key,ip)) 60 | ngx.log(ngx.ERR, "error: 503 ", err) 61 | return ngx.exit(503) 62 | end 63 | ngx.log(ngx.ERR, "failed to limit traffic: ", err) 64 | return ngx.exit(500) 65 | end 66 | 67 | if delay > 0 then --根据需要决定延迟或者不延迟处理 68 | if nodelay then 69 | --直接突发处理 70 | ngx.log(ngx.ERR,"直接突发处理") 71 | else 72 | ngx.log(ngx.ERR,"延迟处理") 73 | ngx.sleep(delay) --延迟处理 74 | end 75 | end 76 | 77 | -------------------------------------------------------------------------------- /conf/lua/bin/resty-limit-traffic.lua: -------------------------------------------------------------------------------- 1 | --[[----------------------------------------------------------------------- 2 | * | Copyright (C) Shaobo Wan (Tinywan) 3 | * |------------------------------------------------------------------------ 4 | * | Author: Tinywan 5 | * | Date Time : 2019/5/28 16:25 6 | * | Email: Overcome.wan@Gmail.com 7 | * | Desc: 网关接口限流 https://github.com/openresty/lua-resty-limit-traffic 8 | * |------------------------------------------------------------------------ 9 | --]] 10 | 11 | local limit_conn = require "resty.limit.conn" 12 | local limit_req = require "resty.limit.req" 13 | local limit_traffic = require "resty.limit.traffic" 14 | 15 | local lim1, err = limit_req.new("my_req_store", 3, 2) 16 | assert(lim1, err) 17 | local lim2, err = limit_req.new("my_req_store", 2, 1) 18 | assert(lim2, err) 19 | local lim3, err = limit_conn.new("my_conn_store", 10, 10, 0.5) 20 | assert(lim3, err) 21 | 22 | local limiters = {lim1, lim2, lim3} 23 | 24 | local host = ngx.var.host 25 | local client = ngx.var.binary_remote_addr 26 | local keys = {host, client, client} 27 | 28 | local states = {} 29 | 30 | local delay, err = limit_traffic.combine(limiters, keys, states) 31 | if not delay then 32 | if err == "rejected" then 33 | return ngx.exit(503) 34 | end 35 | ngx.log(ngx.ERR, "failed to limit traffic: ", err) 36 | return ngx.exit(500) 37 | end 38 | 39 | if lim3:is_committed() then 40 | local ctx = ngx.ctx 41 | ctx.limit_conn = lim3 42 | ctx.limit_conn_key = keys[3] 43 | end 44 | 45 | print("sleeping ", delay, " sec, states: ", 46 | table.concat(states, ", ")) 47 | 48 | if delay >= 0.001 then 49 | ngx.sleep(delay) 50 | end 51 | 52 | -------------------------------------------------------------------------------- /conf/lua/test/http.lua: -------------------------------------------------------------------------------- 1 | --[[----------------------------------------------------------------------- 2 | * | Copyright (C) Shaobo Wan (Tinywan) 3 | * |------------------------------------------------------------------------ 4 | * | Author: Tinywan 5 | * | Date Time : 2019/5/28 16:25 6 | * | Email: Overcome.wan@Gmail.com 7 | * |------------------------------------------------------------------------ 8 | --]] 9 | 10 | local url = require "net.url" 11 | local u = url.parse("https://www.tinywan.com/p/124.html") 12 | ngx.say("scheme: ",u.scheme) 13 | ngx.say("host: ",u.host) 14 | ngx.say("path: ",u.path) -------------------------------------------------------------------------------- /conf/lua/test/test.lua: -------------------------------------------------------------------------------- 1 | ngx.say("Docker tooling for OpenResty") -------------------------------------------------------------------------------- /conf/lua/test/test_mysql.lua: -------------------------------------------------------------------------------- 1 | --[[----------------------------------------------------------------------- 2 | * | Copyright (C) Shaobo Wan (Tinywan) 3 | * |------------------------------------------------------------------------ 4 | * | Author: Tinywan 5 | * | Date Time : 2019/5/28 16:25 6 | * | Email: Overcome.wan@Gmail.com 7 | * |------------------------------------------------------------------------ 8 | --]] 9 | 10 | local cjson = require "cjson" 11 | local mysql = require "resty.mysql" 12 | 13 | local db = mysql:new() 14 | local ok, err, errcode, sqlstate = db:connect({ 15 | host = "172.20.0.4", 16 | port = 3306, 17 | database = "world", 18 | user = "root", 19 | password = "123456"}) 20 | 21 | if not ok then 22 | ngx.log(ngx.ERR, "failed to connect: ", err, ": ", errcode, " ", sqlstate) 23 | return ngx.exit(500) 24 | end 25 | 26 | res, err, errcode, sqlstate = db:query("select 1; select 2; select 3;") 27 | if not res then 28 | ngx.log(ngx.ERR, "bad result #1: ", err, ": ", errcode, ": ", sqlstate, ".") 29 | return ngx.exit(500) 30 | end 31 | 32 | ngx.say("result #1: ", cjson.encode(res)) 33 | 34 | local i = 2 35 | while err == "again" do 36 | res, err, errcode, sqlstate = db:read_result() 37 | if not res then 38 | ngx.log(ngx.ERR, "bad result #", i, ": ", err, ": ", errcode, ": ", sqlstate, ".") 39 | return ngx.exit(500) 40 | end 41 | 42 | ngx.say("result #", i, ": ", cjson.encode(res)) 43 | i = i + 1 44 | end 45 | 46 | local ok, err = db:set_keepalive(10000, 50) 47 | if not ok then 48 | ngx.log(ngx.ERR, "failed to set keepalive: ", err) 49 | ngx.exit(500) 50 | end -------------------------------------------------------------------------------- /conf/lua/test/test_redis_file.lua: -------------------------------------------------------------------------------- 1 | --[[----------------------------------------------------------------------- 2 | * | Copyright (C) Shaobo Wan (Tinywan) 3 | * |------------------------------------------------------------------------ 4 | * | Author: Tinywan 5 | * | Date Time : 2019/5/28 16:25 6 | * | Email: Overcome.wan@Gmail.com 7 | * |------------------------------------------------------------------------ 8 | --]] 9 | 10 | 11 | -- redis config 12 | local redis = require "resty.redis" 13 | local red = redis:new() 14 | 15 | -- 容器内部 16 | -- local ok, err = red:connect("172.19.0.2", 6379) 17 | local ok, err = red:connect("dnmp-redis-v2", 6379) 18 | 19 | -- 通过宿主机链接 20 | -- local ok, err = red:connect("172.19.0.1", 6379) 21 | 22 | -- local ok, err = red:connect("dnmp-redis-v1", 6379) 23 | 24 | if not ok then 25 | ngx.say("failed to connect1: ", err) 26 | return 27 | end 28 | 29 | ok, err = red:set("dog", "an animal1") 30 | if not ok then 31 | ngx.say("failed to set dog: ", err) 32 | return 33 | end 34 | 35 | ngx.say("set result: ", ok) 36 | 37 | local res, err = red:get("dog") 38 | if not res then 39 | ngx.say("failed to get dog: ", err) 40 | return 41 | end 42 | 43 | if res == ngx.null then 44 | ngx.say("dog not found.") 45 | return 46 | end 47 | 48 | ngx.say("dog: ", res) 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /conf/mariadb/my.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | port = 3306 3 | socket = /var/run/mysqld/mysqld.sock 4 | default-character-set = utf8mb4 5 | 6 | [mysql] 7 | prompt = [\\u@\\d]-[\\r:\\m:\\s]>\\_ 8 | #no-auto-rehash 9 | auto-rehash 10 | default-character-set = utf8mb4 11 | 12 | [mysqld_safe] 13 | malloc-lib=tcmalloc 14 | 15 | [mysqldump] 16 | single-transaction 17 | quick 18 | max_allowed_packet=1G 19 | 20 | [mysqld] 21 | user = mysql 22 | port = 3306 23 | datadir = /var/lib/mysql 24 | socket = /var/run/mysqld/mysqld.sock 25 | skip-name-resolve 26 | symbolic-links=0 27 | 28 | 29 | #timeout 30 | interactive_timeout = 28800 31 | wait_timeout = 28800 32 | 33 | # character set 34 | character-set-server = utf8mb4 35 | collation-server = utf8mb4_unicode_ci 36 | init_connect = 'SET NAMES utf8mb4' 37 | 38 | #innodb 39 | default_storage_engine = InnoDB 40 | innodb_file_per_table = on 41 | innodb_open_files = 500 42 | innodb_buffer_pool_size = 1024M 43 | innodb_buffer_pool_instances = 1 44 | innodb_write_io_threads = 4 45 | innodb_read_io_threads = 4 46 | innodb_thread_concurrency = 0 47 | innodb_purge_threads = 1 48 | innodb_flush_log_at_trx_commit = 2 49 | innodb_log_buffer_size = 16M 50 | innodb_log_file_size = 64M 51 | innodb_log_files_in_group = 3 52 | innodb_max_dirty_pages_pct = 90 53 | innodb_lock_wait_timeout = 120 54 | 55 | #logs 56 | log-output =file 57 | log-error = /var/log/mysql/error.log 58 | slow_query_log_file = /var/log/mysql/slow.log 59 | slow_query_log = 1 60 | log_error_verbosity = 2 61 | long_query_time = 1 62 | log-slow-slave-statements = 1 63 | performance_schema = 0 64 | explicit_defaults_for_timestamp 65 | # 打开二进制日志功能 66 | binlog_format = mixed 67 | expire_logs_days = 7 68 | 69 | # 兼容5.6查询模式 70 | sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 71 | 72 | -------------------------------------------------------------------------------- /conf/mysql/my.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | port = 3306 3 | socket = /var/run/mysqld/mysqld.sock 4 | default-character-set = utf8mb4 5 | 6 | [mysql] 7 | prompt = [\\u@\\d]-[\\r:\\m:\\s]>\\_ 8 | #no-auto-rehash 9 | auto-rehash 10 | default-character-set = utf8mb4 11 | 12 | [mysqld_safe] 13 | malloc-lib=tcmalloc 14 | 15 | [mysqldump] 16 | single-transaction 17 | quick 18 | max_allowed_packet=1G 19 | 20 | [mysqld] 21 | user = mysql 22 | port = 3306 23 | datadir = /var/lib/mysql 24 | socket = /var/run/mysqld/mysqld.sock 25 | skip-name-resolve 26 | symbolic-links=0 27 | 28 | 29 | #timeout 30 | interactive_timeout = 28800 31 | wait_timeout = 28800 32 | 33 | # character set 34 | character-set-server = utf8mb4 35 | collation-server = utf8mb4_unicode_ci 36 | init_connect = 'SET NAMES utf8mb4' 37 | 38 | #innodb 39 | default_storage_engine = InnoDB 40 | innodb_file_per_table = on 41 | innodb_open_files = 500 42 | innodb_buffer_pool_size = 1024M 43 | innodb_buffer_pool_instances = 1 44 | innodb_write_io_threads = 4 45 | innodb_read_io_threads = 4 46 | innodb_thread_concurrency = 0 47 | innodb_purge_threads = 1 48 | innodb_flush_log_at_trx_commit = 2 49 | innodb_log_buffer_size = 16M 50 | innodb_log_file_size = 64M 51 | innodb_log_files_in_group = 3 52 | innodb_max_dirty_pages_pct = 90 53 | innodb_lock_wait_timeout = 120 54 | 55 | #logs 56 | log-output =file 57 | log-error = /var/log/mysql/error.log 58 | slow_query_log_file = /var/log/mysql/slow.log 59 | slow_query_log = 1 60 | log_error_verbosity = 2 61 | long_query_time = 1 62 | log-slow-slave-statements = 1 63 | performance_schema = 0 64 | explicit_defaults_for_timestamp 65 | # 打开二进制日志功能 66 | binlog_format = mixed 67 | expire_logs_days = 7 68 | 69 | # 兼容5.6查询模式 70 | sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' 71 | 72 | -------------------------------------------------------------------------------- /conf/mysql/my8.0.cnf: -------------------------------------------------------------------------------- 1 | [client] 2 | port = 3306 3 | default-character-set = utf8mb4 4 | 5 | 6 | [mysqld] 7 | user = mysql 8 | port = 3306 9 | sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 10 | 11 | default-storage-engine = InnoDB 12 | default-authentication-plugin = mysql_native_password 13 | character-set-server = utf8mb4 14 | collation-server = utf8mb4_unicode_ci 15 | init_connect = 'SET NAMES utf8mb4' 16 | 17 | disable-log-bin 18 | skip-character-set-client-handshake 19 | explicit_defaults_for_timestamp 20 | 21 | slow_query_log 22 | long_query_time = 3 23 | slow-query-log-file = /var/lib/mysql/mysql.slow.log 24 | log-error = /var/lib/mysql/mysql.error.log 25 | 26 | default-time-zone = '+8:00' 27 | 28 | [mysql] 29 | default-character-set = utf8mb4 -------------------------------------------------------------------------------- /conf/nginx.conf: -------------------------------------------------------------------------------- 1 | user root; 2 | worker_processes 1; 3 | 4 | pid /var/run/nginx.pid; 5 | 6 | worker_rlimit_nofile 65535; 7 | 8 | events { 9 | use epoll; 10 | multi_accept on; 11 | worker_connections 65535; 12 | } 13 | 14 | http { 15 | charset utf-8; 16 | sendfile on; 17 | tcp_nopush on; 18 | tcp_nodelay on; 19 | #server_tokens off; 20 | log_not_found off; 21 | types_hash_max_size 2048; 22 | client_max_body_size 16M; 23 | 24 | # MIME 25 | include /etc/nginx/conf.d/mime.types; 26 | default_type application/octet-stream; 27 | 28 | # logging 29 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 30 | '$status $body_bytes_sent "$http_referer" ' 31 | '"$http_user_agent" "$http_x_forwarded_for"'; 32 | 33 | access_log /var/log/nginx/access.log main; 34 | error_log /var/log/nginx/error.log warn; 35 | 36 | # SSL 37 | ssl_session_timeout 1d; 38 | ssl_session_cache shared:SSL:50m; 39 | ssl_session_tickets off; 40 | 41 | # OCSP Stapling 42 | ssl_stapling on; 43 | ssl_stapling_verify on; 44 | resolver 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s; 45 | resolver_timeout 2s; 46 | 47 | # index.php 48 | index index.php index.html index.htm; 49 | 50 | # load configs 51 | include /etc/nginx/conf.d/*.conf; 52 | } -------------------------------------------------------------------------------- /conf/php/php-fpm.conf: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;; 2 | ; FPM Configuration ; 3 | ;;;;;;;;;;;;;;;;;;;;; 4 | 5 | ; All relative paths in this configuration file are relative to PHP's install 6 | ; prefix (/opt/php). This prefix can be dynamically changed by using the 7 | ; '-p' argument from the command line. 8 | 9 | ;;;;;;;;;;;;;;;;;; 10 | ; Global Options ; 11 | ;;;;;;;;;;;;;;;;;; 12 | 13 | [global] 14 | ; Pid file 15 | ; Note: the default prefix is /opt/php/var 16 | ; Default Value: none 17 | pid = run/php-fpm.pid 18 | 19 | ; Error log file 20 | ; If it's set to "syslog", log is sent to syslogd instead of being written 21 | ; in a local file. 22 | ; Note: the default prefix is /opt/php/var 23 | ; Default Value: log/php-fpm.log 24 | ; error_log = log/php-fpm.log 25 | 26 | ; syslog_facility is used to specify what type of program is logging the 27 | ; message. This lets syslogd specify that messages from different facilities 28 | ; will be handled differently. 29 | ; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON) 30 | ; Default Value: daemon 31 | ;syslog.facility = daemon 32 | 33 | ; syslog_ident is prepended to every message. If you have multiple FPM 34 | ; instances running on the same server, you can change the default value 35 | ; which must suit common needs. 36 | ; Default Value: php-fpm 37 | ;syslog.ident = php-fpm 38 | 39 | ; Log level 40 | ; Possible Values: alert, error, warning, notice, debug 41 | ; Default Value: notice 42 | ; log_level = error 43 | 44 | ; If this number of child processes exit with SIGSEGV or SIGBUS within the time 45 | ; interval set by emergency_restart_interval then FPM will restart. A value 46 | ; of '0' means 'Off'. 47 | ; Default Value: 0 48 | ;emergency_restart_threshold = 0 49 | 50 | ; Interval of time used by emergency_restart_interval to determine when 51 | ; a graceful restart will be initiated. This can be useful to work around 52 | ; accidental corruptions in an accelerator's shared memory. 53 | ; Available Units: s(econds), m(inutes), h(ours), or d(ays) 54 | ; Default Unit: seconds 55 | ; Default Value: 0 56 | ;emergency_restart_interval = 0 57 | 58 | ; Time limit for child processes to wait for a reaction on signals from master. 59 | ; Available units: s(econds), m(inutes), h(ours), or d(ays) 60 | ; Default Unit: seconds 61 | ; Default Value: 0 62 | ;process_control_timeout = 0 63 | 64 | ; The maximum number of processes FPM will fork. This has been design to control 65 | ; the global number of processes when using dynamic PM within a lot of pools. 66 | ; Use it with caution. 67 | ; Note: A value of 0 indicates no limit 68 | ; Default Value: 0 69 | ; process.max = 128 70 | 71 | ; Specify the nice(2) priority to apply to the master process (only if set) 72 | ; The value can vary from -19 (highest priority) to 20 (lower priority) 73 | ; Note: - It will only work if the FPM master process is launched as root 74 | ; - The pool process will inherit the master process priority 75 | ; unless it specified otherwise 76 | ; Default Value: no set 77 | ; process.priority = -19 78 | 79 | ; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging. 80 | ; Default Value: yes 81 | daemonize = no 82 | 83 | ; Set open file descriptor rlimit for the master process. 84 | ; Default Value: system defined value 85 | ;rlimit_files = 1024 86 | 87 | ; Set max core size rlimit for the master process. 88 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 89 | ; Default Value: system defined value 90 | ;rlimit_core = 0 91 | 92 | ; Specify the event mechanism FPM will use. The following is available: 93 | ; - select (any POSIX os) 94 | ; - poll (any POSIX os) 95 | ; - epoll (linux >= 2.5.44) 96 | ; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0) 97 | ; - /dev/poll (Solaris >= 7) 98 | ; - port (Solaris >= 10) 99 | ; Default Value: not set (auto detection) 100 | ;events.mechanism = epoll 101 | 102 | ; When FPM is build with systemd integration, specify the interval, 103 | ; in second, between health report notification to systemd. 104 | ; Set to 0 to disable. 105 | ; Available Units: s(econds), m(inutes), h(ours) 106 | ; Default Unit: seconds 107 | ; Default value: 10 108 | ;systemd_interval = 10 109 | 110 | ;;;;;;;;;;;;;;;;;;;; 111 | ; Pool Definitions ; 112 | ;;;;;;;;;;;;;;;;;;;; 113 | 114 | ; Multiple pools of child processes may be started with different listening 115 | ; ports and different management options. The name of the pool will be 116 | ; used in logs and stats. There is no limitation on the number of pools which 117 | ; FPM can handle. Your system will tell you anyway :) 118 | 119 | ; Include one or more files. If glob(3) exists, it is used to include a bunch of 120 | ; files from a glob(3) pattern. This directive can be used everywhere in the 121 | ; file. 122 | ; Relative path can also be used. They will be prefixed by: 123 | ; - the global prefix if it's been set (-p argument) 124 | ; - /opt/php otherwise 125 | include=/usr/local/php/etc/php-fpm.d/*.conf -------------------------------------------------------------------------------- /conf/php/php-fpm.d/www.conf: -------------------------------------------------------------------------------- 1 | ; Start a new pool named 'www'. 2 | ; the variable $pool can we used in any directive and will be replaced by the 3 | ; pool name ('www' here) 4 | [www] 5 | 6 | ; Per pool prefix 7 | ; It only applies on the following directives: 8 | ; - 'access.log' 9 | ; - 'slowlog' 10 | ; - 'listen' (unixsocket) 11 | ; - 'chroot' 12 | ; - 'chdir' 13 | ; - 'php_values' 14 | ; - 'php_admin_values' 15 | ; When not set, the global prefix (or /opt/php) applies instead. 16 | ; Note: This directive can also be relative to the global prefix. 17 | ; Default Value: none 18 | ;prefix = /path/to/pools/$pool 19 | 20 | ; Unix user/group of processes 21 | ; Note: The user is mandatory. If the group is not set, the default user's group 22 | ; will be used. 23 | user = www-data 24 | group = www-data 25 | 26 | ; The address on which to accept FastCGI requests. 27 | ; Valid syntaxes are: 28 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on 29 | ; a specific port; 30 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on 31 | ; a specific port; 32 | ; 'port' - to listen on a TCP socket to all addresses 33 | ; (IPv6 and IPv4-mapped) on a specific port; 34 | ; '/path/to/unix/socket' - to listen on a unix socket. 35 | ; Note: This value is mandatory. 36 | listen = 0.0.0.0:9000 37 | 38 | ; Set listen(2) backlog. 39 | ; Default Value: 511 (-1 on FreeBSD and OpenBSD) 40 | listen.backlog = 511 41 | 42 | ; Set permissions for unix socket, if one is used. In Linux, read/write 43 | ; permissions must be set in order to allow connections from a web server. Many 44 | ; BSD-derived systems allow connections regardless of permissions. 45 | ; Default Values: user and group are set as the running user 46 | ; mode is set to 0660 47 | ; listen.owner = www 48 | ; listen.group = www 49 | listen.mode = 0660 50 | 51 | ; When POSIX Access Control Lists are supported you can set them using 52 | ; these options, value is a comma separated list of user/group names. 53 | ; When set, listen.owner and listen.group are ignored 54 | ;listen.acl_users = 55 | ;listen.acl_groups = 56 | 57 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. 58 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original 59 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address 60 | ; must be separated by a comma. If this value is left blank, connections will be 61 | ; accepted from any ip address. 62 | ; Default Value: any 63 | ; listen.allowed_clients = 127.0.0.1 64 | 65 | ; Specify the nice(2) priority to apply to the pool processes (only if set) 66 | ; The value can vary from -19 (highest priority) to 20 (lower priority) 67 | ; Note: - It will only work if the FPM master process is launched as root 68 | ; - The pool processes will inherit the master process priority 69 | ; unless it specified otherwise 70 | ; Default Value: no set 71 | ; process.priority = -19 72 | 73 | ; Choose how the process manager will control the number of child processes. 74 | ; Possible Values: 75 | ; static - a fixed number (pm.max_children) of child processes; 76 | ; dynamic - the number of child processes are set dynamically based on the 77 | ; following directives. With this process management, there will be 78 | ; always at least 1 children. 79 | ; pm.max_children - the maximum number of children that can 80 | ; be alive at the same time. 81 | ; pm.start_servers - the number of children created on startup. 82 | ; pm.min_spare_servers - the minimum number of children in 'idle' 83 | ; state (waiting to process). If the number 84 | ; of 'idle' processes is less than this 85 | ; number then some children will be created. 86 | ; pm.max_spare_servers - the maximum number of children in 'idle' 87 | ; state (waiting to process). If the number 88 | ; of 'idle' processes is greater than this 89 | ; number then some children will be killed. 90 | ; ondemand - no children are created at startup. Children will be forked when 91 | ; new requests will connect. The following parameter are used: 92 | ; pm.max_children - the maximum number of children that 93 | ; can be alive at the same time. 94 | ; pm.process_idle_timeout - The number of seconds after which 95 | ; an idle process will be killed. 96 | ; Note: This value is mandatory. 97 | pm = dynamic 98 | 99 | ; The number of child processes to be created when pm is set to 'static' and the 100 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 101 | ; This value sets the limit on the number of simultaneous requests that will be 102 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 103 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 104 | ; CGI. The below defaults are based on a server without much resources. Don't 105 | ; forget to tweak pm.* to fit your needs. 106 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 107 | ; Note: This value is mandatory. 108 | pm.max_children = 15 109 | 110 | ; The number of child processes created on startup. 111 | ; Note: Used only when pm is set to 'dynamic' 112 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 113 | pm.start_servers = 2 114 | 115 | ; The desired minimum number of idle server processes. 116 | ; Note: Used only when pm is set to 'dynamic' 117 | ; Note: Mandatory when pm is set to 'dynamic' 118 | pm.min_spare_servers = 1 119 | 120 | ; The desired maximum number of idle server processes. 121 | ; Note: Used only when pm is set to 'dynamic' 122 | ; Note: Mandatory when pm is set to 'dynamic' 123 | pm.max_spare_servers = 2 124 | 125 | ; The number of seconds after which an idle process will be killed. 126 | ; Note: Used only when pm is set to 'ondemand' 127 | ; Default Value: 10s 128 | pm.process_idle_timeout = 30s; 129 | 130 | ; The number of requests each child process should execute before respawning. 131 | ; This can be useful to work around memory leaks in 3rd party libraries. For 132 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 133 | ; Default Value: 0 134 | pm.max_requests = 500 135 | 136 | ; The URI to view the FPM status page. If this value is not set, no URI will be 137 | ; recognized as a status page. It shows the following informations: 138 | ; pool - the name of the pool; 139 | ; process manager - static, dynamic or ondemand; 140 | ; start time - the date and time FPM has started; 141 | ; start since - number of seconds since FPM has started; 142 | ; accepted conn - the number of request accepted by the pool; 143 | ; listen queue - the number of request in the queue of pending 144 | ; connections (see backlog in listen(2)); 145 | ; max listen queue - the maximum number of requests in the queue 146 | ; of pending connections since FPM has started; 147 | ; listen queue len - the size of the socket queue of pending connections; 148 | ; idle processes - the number of idle processes; 149 | ; active processes - the number of active processes; 150 | ; total processes - the number of idle + active processes; 151 | ; max active processes - the maximum number of active processes since FPM 152 | ; has started; 153 | ; max children reached - number of times, the process limit has been reached, 154 | ; when pm tries to start more children (works only for 155 | ; pm 'dynamic' and 'ondemand'); 156 | ; Value are updated in real time. 157 | ; Example output: 158 | ; pool: www 159 | ; process manager: static 160 | ; start time: 01/Jul/2011:17:53:49 +0200 161 | ; start since: 62636 162 | ; accepted conn: 190460 163 | ; listen queue: 0 164 | ; max listen queue: 1 165 | ; listen queue len: 42 166 | ; idle processes: 4 167 | ; active processes: 11 168 | ; total processes: 15 169 | ; max active processes: 12 170 | ; max children reached: 0 171 | ; 172 | ; By default the status page output is formatted as text/plain. Passing either 173 | ; 'html', 'xml' or 'json' in the query string will return the corresponding 174 | ; output syntax. Example: 175 | ; http://www.foo.bar/status 176 | ; http://www.foo.bar/status?json 177 | ; http://www.foo.bar/status?html 178 | ; http://www.foo.bar/status?xml 179 | ; 180 | ; By default the status page only outputs short status. Passing 'full' in the 181 | ; query string will also return status for each pool process. 182 | ; Example: 183 | ; http://www.foo.bar/status?full 184 | ; http://www.foo.bar/status?json&full 185 | ; http://www.foo.bar/status?html&full 186 | ; http://www.foo.bar/status?xml&full 187 | ; The Full status returns for each process: 188 | ; pid - the PID of the process; 189 | ; state - the state of the process (Idle, Running, ...); 190 | ; start time - the date and time the process has started; 191 | ; start since - the number of seconds since the process has started; 192 | ; requests - the number of requests the process has served; 193 | ; request duration - the duration in µs of the requests; 194 | ; request method - the request method (GET, POST, ...); 195 | ; request URI - the request URI with the query string; 196 | ; content length - the content length of the request (only with POST); 197 | ; user - the user (PHP_AUTH_USER) (or '-' if not set); 198 | ; script - the main script called (or '-' if not set); 199 | ; last request cpu - the %cpu the last request consumed 200 | ; it's always 0 if the process is not in Idle state 201 | ; because CPU calculation is done when the request 202 | ; processing has terminated; 203 | ; last request memory - the max amount of memory the last request consumed 204 | ; it's always 0 if the process is not in Idle state 205 | ; because memory calculation is done when the request 206 | ; processing has terminated; 207 | ; If the process is in Idle state, then informations are related to the 208 | ; last request the process has served. Otherwise informations are related to 209 | ; the current request being served. 210 | ; Example output: 211 | ; ************************ 212 | ; pid: 31330 213 | ; state: Running 214 | ; start time: 01/Jul/2011:17:53:49 +0200 215 | ; start since: 63087 216 | ; requests: 12808 217 | ; request duration: 1250261 218 | ; request method: GET 219 | ; request URI: /test_mem.php?N=10000 220 | ; content length: 0 221 | ; user: - 222 | ; script: /home/fat/web/docs/php/test_mem.php 223 | ; last request cpu: 0.00 224 | ; last request memory: 0 225 | ; 226 | ; Note: There is a real-time FPM status monitoring sample web page available 227 | ; It's available in: /opt/php/share/php/fpm/status.html 228 | ; 229 | ; Note: The value must start with a leading slash (/). The value can be 230 | ; anything, but it may not be a good idea to use the .php extension or it 231 | ; may conflict with a real PHP file. 232 | ; Default Value: not set 233 | ;pm.status_path = /status 234 | 235 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no 236 | ; URI will be recognized as a ping page. This could be used to test from outside 237 | ; that FPM is alive and responding, or to 238 | ; - create a graph of FPM availability (rrd or such); 239 | ; - remove a server from a group if it is not responding (load balancing); 240 | ; - trigger alerts for the operating team (24/7). 241 | ; Note: The value must start with a leading slash (/). The value can be 242 | ; anything, but it may not be a good idea to use the .php extension or it 243 | ; may conflict with a real PHP file. 244 | ; Default Value: not set 245 | ;ping.path = /ping 246 | 247 | ; This directive may be used to customize the response of a ping request. The 248 | ; response is formatted as text/plain with a 200 response code. 249 | ; Default Value: pong 250 | ;ping.response = pong 251 | 252 | ; The access log file 253 | ; Default: not set 254 | ;access.log = log/$pool.access.log 255 | 256 | ; The access log format. 257 | ; The following syntax is allowed 258 | ; %%: the '%' character 259 | ; %C: %CPU used by the request 260 | ; it can accept the following format: 261 | ; - %{user}C for user CPU only 262 | ; - %{system}C for system CPU only 263 | ; - %{total}C for user + system CPU (default) 264 | ; %d: time taken to serve the request 265 | ; it can accept the following format: 266 | ; - %{seconds}d (default) 267 | ; - %{miliseconds}d 268 | ; - %{mili}d 269 | ; - %{microseconds}d 270 | ; - %{micro}d 271 | ; %e: an environment variable (same as $_ENV or $_SERVER) 272 | ; it must be associated with embraces to specify the name of the env 273 | ; variable. Some exemples: 274 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e 275 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e 276 | ; %f: script filename 277 | ; %l: content-length of the request (for POST request only) 278 | ; %m: request method 279 | ; %M: peak of memory allocated by PHP 280 | ; it can accept the following format: 281 | ; - %{bytes}M (default) 282 | ; - %{kilobytes}M 283 | ; - %{kilo}M 284 | ; - %{megabytes}M 285 | ; - %{mega}M 286 | ; %n: pool name 287 | ; %o: output header 288 | ; it must be associated with embraces to specify the name of the header: 289 | ; - %{Content-Type}o 290 | ; - %{X-Powered-By}o 291 | ; - %{Transfert-Encoding}o 292 | ; - .... 293 | ; %p: PID of the child that serviced the request 294 | ; %P: PID of the parent of the child that serviced the request 295 | ; %q: the query string 296 | ; %Q: the '?' character if query string exists 297 | ; %r: the request URI (without the query string, see %q and %Q) 298 | ; %R: remote IP address 299 | ; %s: status (response code) 300 | ; %t: server time the request was received 301 | ; it can accept a strftime(3) format: 302 | ; %d/%b/%Y:%H:%M:%S %z (default) 303 | ; The strftime(3) format must be encapsuled in a %{}t tag 304 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 305 | ; %T: time the log has been written (the request has finished) 306 | ; it can accept a strftime(3) format: 307 | ; %d/%b/%Y:%H:%M:%S %z (default) 308 | ; The strftime(3) format must be encapsuled in a %{}t tag 309 | ; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t 310 | ; %u: remote user 311 | ; 312 | ; Default: "%R - %u %t \"%m %r\" %s" 313 | access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" 314 | 315 | ; The log file for slow requests 316 | ; Default Value: not set 317 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 318 | ; slowlog = log/$pool.log.slow 319 | 320 | ; The timeout for serving a single request after which a PHP backtrace will be 321 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'. 322 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 323 | ; Default Value: 0 324 | ; request_slowlog_timeout = 15s 325 | 326 | ; The timeout for serving a single request after which the worker process will 327 | ; be killed. This option should be used when the 'max_execution_time' ini option 328 | ; does not stop script execution for some reason. A value of '0' means 'off'. 329 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 330 | ; Default Value: 0 331 | request_terminate_timeout = 60s 332 | 333 | ; Set open file descriptor rlimit. 334 | ; Default Value: system defined value 335 | rlimit_files = 65535 336 | 337 | ; Set max core size rlimit. 338 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 339 | ; Default Value: system defined value 340 | ;rlimit_core = 0 341 | 342 | ; Chroot to this directory at the start. This value must be defined as an 343 | ; absolute path. When this value is not set, chroot is not used. 344 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one 345 | ; of its subdirectories. If the pool prefix is not set, the global prefix 346 | ; will be used instead. 347 | ; Note: chrooting is a great security feature and should be used whenever 348 | ; possible. However, all PHP paths will be relative to the chroot 349 | ; (error_log, sessions.save_path, ...). 350 | ; Default Value: not set 351 | ;chroot = 352 | 353 | ; Chdir to this directory at the start. 354 | ; Note: relative path can be used. 355 | ; Default Value: current directory or / when chroot 356 | ;chdir = /var/www 357 | 358 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 359 | ; stderr will be redirected to /dev/null according to FastCGI specs. 360 | ; Note: on highloaded environement, this can cause some delay in the page 361 | ; process time (several ms). 362 | ; Default Value: no 363 | ;catch_workers_output = yes 364 | 365 | ; Clear environment in FPM workers 366 | ; Prevents arbitrary environment variables from reaching FPM worker processes 367 | ; by clearing the environment in workers before env vars specified in this 368 | ; pool configuration are added. 369 | ; Setting to "no" will make all environment variables available to PHP code 370 | ; via getenv(), $_ENV and $_SERVER. 371 | ; Default Value: yes 372 | ;clear_env = no 373 | 374 | ; Limits the extensions of the main script FPM will allow to parse. This can 375 | ; prevent configuration mistakes on the web server side. You should only limit 376 | ; FPM to .php extensions to prevent malicious users to use other extensions to 377 | ; exectute php code. 378 | ; Note: set an empty value to allow all extensions. 379 | ; Default Value: .php 380 | ;security.limit_extensions = .php .php3 .php4 .php5 .php7 381 | 382 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 383 | ; the current environment. 384 | ; Default Value: clean env 385 | ;env[HOSTNAME] = $HOSTNAME 386 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin 387 | ;env[TMP] = /tmp 388 | ;env[TMPDIR] = /tmp 389 | ;env[TEMP] = /tmp 390 | 391 | ; Additional php.ini defines, specific to this pool of workers. These settings 392 | ; overwrite the values previously defined in the php.ini. The directives are the 393 | ; same as the PHP SAPI: 394 | ; php_value/php_flag - you can set classic ini defines which can 395 | ; be overwritten from PHP call 'ini_set'. 396 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 397 | ; PHP call 'ini_set' 398 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 399 | 400 | ; Defining 'extension' will load the corresponding shared extension from 401 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 402 | ; overwrite previously defined php.ini values, but will append the new value 403 | ; instead. 404 | 405 | ; Note: path INI options can be relative and will be expanded with the prefix 406 | ; (pool, global or /opt/php) 407 | 408 | ; Default Value: nothing is defined by default except the values in php.ini and 409 | ; specified at startup with the -d argument 410 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 411 | ;php_flag[display_errors] = off 412 | ;php_admin_value[error_log] = /var/log/fpm-php.www.log 413 | ;php_admin_flag[log_errors] = on 414 | ;php_admin_value[memory_limit] = 32M -------------------------------------------------------------------------------- /data/etcd/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /data/mariadb/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /data/mysql/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /data/redis/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | # openresty: 4 | # # image: ${OPENRESTY_IMAGE_BASE}:${OPENRESTY_IMAGE_TAG} 5 | # image: ${OPENRESTY_CHINA_IMAGE_BASE}:${OPENRESTY_IMAGE_TAG} 6 | # ports: 7 | # - "${NGINX_HTTP_HOST_PORT}:80" 8 | # - "${NGINX_HTTPS_HOST_PORT}:443" 9 | # - "8001:8001" 10 | # - "8072:8072" 11 | # - "8074:8074" 12 | # - "8004:8004" 13 | # volumes: 14 | # - ${NGINX_CONF_FILE}:/usr/local/openresty/nginx/conf/nginx.conf 15 | # - ${NGINX_CONFD_DIR}:/etc/nginx/conf.d 16 | # - ${NGINX_LOG_DIR}:/var/log/nginx 17 | # - ${SOURCE_SHARE_DIR}:/var/www 18 | # - ${OPENRESTY_LUA_DIR}:/usr/local/openresty/nginx/conf/lua 19 | # - ${NGINX_SSL_DIR}:/etc/letsencrypt 20 | # restart: always 21 | # environment: 22 | # TZ: "$TZ" 23 | # container_name: ${OPENRESTY_CONTAINER_NAME} 24 | # networks: 25 | # - backend 26 | 27 | nginx: 28 | image: ${NGINX_IMAGE_BASE}:${NGINX_IMAGE_TAG} 29 | ports: 30 | - "${NGINX_HTTP_HOST_PORT}:80" 31 | - "${NGINX_HTTPS_HOST_PORT}:443" 32 | - "8001:8001" 33 | - "8072:8072" 34 | - "8074:8074" 35 | - "8004:8004" 36 | volumes: 37 | - ${NGINX_CONF_FILE}:/etc/nginx/nginx.conf 38 | - ${NGINX_CONFD_DIR}:/etc/nginx/conf.d 39 | - ${NGINX_LOG_DIR}:/var/log/nginx 40 | - ${SOURCE_SHARE_DIR}:/var/www 41 | - ${NGINX_SSL_DIR}:/etc/letsencrypt 42 | restart: always 43 | environment: 44 | TZ: "${TZ}" 45 | container_name: ${NGINX_CONTAINER_NAME} 46 | networks: 47 | - backend 48 | 49 | php74: 50 | build: 51 | context: ./services/php 52 | args: 53 | PHP_VERSION: php:${PHP74_VERSION}-fpm-alpine 54 | CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL} 55 | PHP_EXTENSIONS: ${PHP74_EXTENSIONS} 56 | TZ: "$TZ" 57 | ports: 58 | - "9074:9000" 59 | - "9073:9073" 60 | volumes: 61 | - ${SOURCE_SHARE_DIR}:/var/www 62 | - ${PHP_INI_FILE}:/usr/local/etc/php/php.ini 63 | - ${PHP_WWW_CONF_FILE}:/usr/local/etc/php-fpm.d/www.conf 64 | - ${PHP_LOG_DIR}:/var/log/php 65 | networks: 66 | - backend 67 | container_name: ${PHP74_CONTAINER_NAME} 68 | 69 | php82: 70 | build: 71 | context: ./services/php8 72 | args: 73 | PHP_VERSION: php:${PHP82_VERSION}-fpm-alpine 74 | CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL} 75 | PHP_EXTENSIONS: ${PHP82_EXTENSIONS} 76 | TZ: "$TZ" 77 | ports: 78 | - "9100:9100" 79 | - "8117:8187" 80 | - "8119:8189" 81 | - "8118:8788" 82 | volumes: 83 | - ${SOURCE_SHARE_DIR}:/var/www 84 | - ${PHP_INI_FILE}:/usr/local/etc/php/php.ini 85 | - ${PHP_WWW_CONF_FILE}:/usr/local/etc/php-fpm.d/www.conf 86 | - ${PHP_LOG_DIR}:/var/log/php 87 | networks: 88 | - backend 89 | container_name: ${PHP82_CONTAINER_NAME} 90 | 91 | # php72: 92 | # build: 93 | # context: ./services/php 94 | # args: 95 | # PHP_VERSION: php:${PHP72_VERSION}-fpm-alpine 96 | # CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL} 97 | # PHP_EXTENSIONS: ${PHP72_EXTENSIONS} 98 | # TZ: "$TZ" 99 | # ports: 100 | # - "9072:9000" 101 | # - "9502:9502" 102 | # - "9503:9503" 103 | # volumes: 104 | # - ${SOURCE_SHARE_DIR}:/var/www 105 | # - ${PHP_INI_FILE}:/usr/local/etc/php/php.ini 106 | # - ${PHP_WWW_CONF_FILE}:/usr/local/etc/php-fpm.d/www.conf 107 | # - ${PHP_LOG_DIR}:/var/log/php 108 | # networks: 109 | # - backend 110 | # container_name: ${PHP72_CONTAINER_NAME} 111 | 112 | # php56: 113 | # build: 114 | # context: ./services/php 115 | # args: 116 | # PHP_VERSION: php:${PHP56_VERSION}-fpm-alpine 117 | # CONTAINER_PACKAGE_URL: ${CONTAINER_PACKAGE_URL} 118 | # PHP_EXTENSIONS: ${PHP56_EXTENSIONS} 119 | # TZ: "$TZ" 120 | # ports: 121 | # - "9056:9000" 122 | # volumes: 123 | # - ${SOURCE_SHARE_DIR}:/var/www 124 | # - ${PHP_INI_FILE}:/usr/local/etc/php/php.ini 125 | # - ${PHP_WWW_CONF_FILE}:/usr/local/etc/php-fpm.d/www.conf 126 | # - ${PHP_LOG_DIR}:/var/log/php 127 | # networks: 128 | # - backend 129 | # container_name: ${PHP56_CONTAINER_NAME} 130 | 131 | mysql: 132 | image: mysql:${MYSQL_IMAGE_TAG} 133 | restart: always 134 | command: --default-authentication-plugin=mysql_native_password 135 | hostname: dnmp-mysql 136 | ports: 137 | - "3308:3306" 138 | volumes: 139 | - ${MYSQL_DATA_DIR}:/var/lib/mysql 140 | - ${MYSQL_CONF_FILE}:/etc/mysql/my.cnf 141 | # - ${MYSQL_CONF_FILE}:/etc/mysql/mysql.cnf # 8.0 配置 142 | environment: 143 | MYSQL_ROOT_PASSWORD: 123456 144 | TZ: "$TZ" 145 | networks: 146 | - backend 147 | container_name: ${MYSQL_CONTAINER_NAME} 148 | 149 | # mariadb: 150 | # image: ${MariaDB_IMAGE_BASE}:${MariaDB_IMAGE_TAG} 151 | # restart: always 152 | # command: --default-authentication-plugin=mysql_native_password 153 | # hostname: ${MariaDB_CONTAINER_NAME} 154 | # ports: 155 | # - "3309:3306" 156 | # volumes: 157 | # - ${MariaDB_DATA_DIR}:/var/lib/mysql 158 | # - ${MariaDB_CONF_FILE}:/etc/mysql/my.cnf 159 | # environment: 160 | # MYSQL_ROOT_PASSWORD: 123456 161 | # TZ: "$TZ" 162 | # networks: 163 | # - backend 164 | # container_name: ${MariaDB_CONTAINER_NAME} 165 | 166 | redis: 167 | image: redis:${REDIS_IMAGE_TAG} 168 | hostname: dnmp-redis 169 | ports: 170 | - "${REDIS_HOST_PORT}:6379" 171 | command: redis-server /usr/local/etc/redis/redis.conf 172 | networks: 173 | - backend 174 | volumes: 175 | - ${REDIS_CONF_FILE}:/usr/local/etc/redis/redis.conf 176 | - ${REDIS_DATA_DIR}:/data 177 | restart: always 178 | container_name: ${REDIS_CONTAINER_NAME} 179 | 180 | # phpmyadmin: 181 | # image: phpmyadmin/phpmyadmin:${PHPMYADMIN_TAG} 182 | # ports: 183 | # - "${PHPMYADMIN_HOST_PORT}:80" 184 | # networks: 185 | # - backend 186 | # environment: 187 | # - PMA_HOST=dnmp-mysql 188 | # - PMA_PORT=3306 189 | # - TZ=$TZ 190 | # container_name: dnmp-phpmyadmin 191 | 192 | # rabbitmq: 193 | # image: rabbitmq:${RABBITMQ_VERSION} 194 | # restart: always 195 | # ports: 196 | # - "${RABBITMQ_HOST_PORT_CLIENT}:5672" 197 | # - "${RABBITMQ_HOST_PORT_MANAGEMENT}:15672" 198 | # environment: 199 | # TZ: "$TZ" 200 | # RABBITMQ_DEFAULT_USER: "${RABBITMQ_DEFAULT_USER}" 201 | # RABBITMQ_DEFAULT_PASS: "${RABBITMQ_DEFAULT_PASS}" 202 | # container_name: ${RABBITMQ_CONTAINER_NAME} 203 | # networks: 204 | # - backend 205 | 206 | # 单机模式 207 | # nacos: 208 | # # build: 209 | # # context: ./services/nacos 210 | # image: nacos/nacos-server:1.4.0 211 | # ports: 212 | # - "8848:8848" 213 | # volumes: 214 | # - ./log/nacos:/home/nacos/logs 215 | # - ./services/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties 216 | # networks: 217 | # - backend 218 | # container_name: dnmp-nacos 219 | # env_file: 220 | # - ./services/nacos/env/nacos-standlone-mysql.env 221 | 222 | # 集群模式 223 | # nacos1: 224 | # image: nacos/nacos-server:1.4.0 225 | # ports: 226 | # - "8848:8848" 227 | # volumes: 228 | # - ./log/nacos:/home/nacos/logs 229 | # - ./services/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties 230 | # networks: 231 | # - backend 232 | # container_name: dnmp-nacos1 233 | # env_file: 234 | # - ./services/nacos/env/nacos-hostname.env 235 | 236 | # nacos2: 237 | # image: nacos/nacos-server:1.4.0 238 | # ports: 239 | # - "8849:8848" 240 | # volumes: 241 | # - ./log/nacos:/home/nacos/logs 242 | # - ./services/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties 243 | # networks: 244 | # - backend 245 | # container_name: dnmp-nacos2 246 | # env_file: 247 | # - ./services/nacos/env/nacos-hostname.env 248 | 249 | # nacos3: 250 | # image: nacos/nacos-server:1.4.0 251 | # ports: 252 | # - "8850:8848" 253 | # volumes: 254 | # - ./log/nacos:/home/nacos/logs 255 | # - ./services/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties 256 | # networks: 257 | # - backend 258 | # container_name: dnmp-nacos3 259 | # env_file: 260 | # - ./services/nacos/env/nacos-hostname.env 261 | 262 | networks: 263 | backend: 264 | driver: bridge 265 | -------------------------------------------------------------------------------- /env.example: -------------------------------------------------------------------------------- 1 | #+--------------+ 2 | # Base 3 | #+--------------+ 4 | SOURCE_SHARE_DIR=./www 5 | DATA_DIR=./data 6 | 7 | #+--------------+ 8 | #+ Container package : mirrors.163.com、mirrors.aliyun.com、mirrors.ustc.edu.cn 9 | #+--------------+ 10 | CONTAINER_PACKAGE_URL=mirrors.ustc.edu.cn 11 | 12 | # 个人仓库,防止拉取官方镜像,被墙问题 13 | PHP_IMAGE_BASE=registry.cn-beijing.aliyuncs.com/tinywan/dnmp 14 | 15 | PHP_INI_FILE=./conf/php/php.ini 16 | PHP_FPM_CONF_FILE=./conf/php/php-fpm.conf 17 | PHP_WWW_CONF_FILE=./conf/php/php-fpm.d/www.conf 18 | PHP_LOG_DIR=./log/php 19 | 20 | #+--------------+ 21 | # Timezone 22 | #+--------------+ 23 | TZ=Asia/Shanghai 24 | 25 | #+--------------+ 26 | # Nginx 27 | #+--------------+ 28 | NGINX_IMAGE_BASE=nginx 29 | NGINX_IMAGE_TAG=1.22.1-alpine 30 | NGINX_HTTP_HOST_PORT=80 31 | NGINX_HTTPS_HOST_PORT=443 32 | NGINX_CONFD_DIR=./conf/conf.d 33 | NGINX_CONF_FILE=./conf/nginx.conf 34 | NGINX_LOG_DIR=./log/nginx 35 | NGINX_SSL_DIR=./conf/letsencrypt 36 | NGINX_CONTAINER_NAME=dnmp-nginx 37 | 38 | #+--------------+ 39 | # Openresty 40 | #+--------------+ 41 | # Docker Tinywan Images 42 | OPENRESTY_CHINA_IMAGE_BASE=registry.cn-beijing.aliyuncs.com/tinywan/openresty 43 | 44 | # Docker Official Images 45 | OPENRESTY_IMAGE_BASE=openresty/openresty 46 | OPENRESTY_IMAGE_TAG=1.21.4.1-3-bionic 47 | OPENRESTY_HTTP_PORT=80 48 | OPENRESTY_CONTAINER_NAME=dnmp-openresty 49 | OPENRESTY_LUA_DIR=./conf/lua 50 | 51 | #+--------------+ 52 | # PHP5.6 53 | #+--------------+ 54 | # Available EXTENSIONS 55 | #+-------------------------------------------------------------+ 56 | # pdo_mysql,zip,pcntl,mysqli,mbstring,exif,bcmath,calendar, 57 | # sockets,gettext,shmop,sysvmsg,sysvsem,sysvshm,pdo_rebird, 58 | # pdo_dblib,pdo_oci,pdo_odbc,pdo_pgsql,pgsql,oci8,odbc,dba, 59 | # gd,intl,bz2,soap,xsl,xmlrpc,wddx,curl,readline,snmp,pspell, 60 | # recode,tidy,gmp,imap,ldap,imagick,sqlsrv,mcrypt,opcache, 61 | # redis,memcached,xdebug,swoole,pdo_sqlsrv,sodium,yaf,mysql, 62 | # amqp,mongodb,event,rar,ast,yac,yar,yaconf,msgpack,igbinary, 63 | # seaslog,varnish,xhprof,xlswriter,memcache,rdkafka,zookeeper, 64 | # psr,phalcon,sdebug,ssh2,yaml,protobuf,hprose 65 | #+-------------------------------------------------------------+ 66 | PHP56_VERSION=5.6.40 67 | PHP56_IMAGE_TAG=php5.6-v2 68 | PHP56_FPM_PORT=9006 69 | PHP56_EXTENSIONS=gd,bcmath,pdo,mysql,mysqli,pdo_mysql,bz2,calendar,mcrypt,opcache,redis,pcntl,sockets,xdebug 70 | PHP56_CONTAINER_NAME=dnmp-php56 71 | 72 | #+--------------+ 73 | # PHP7.2 74 | #+--------------+ 75 | PHP72_VERSION=7.2.19 76 | PHP72_IMAGE_TAG=php7.2-v5 77 | PHP72_FPM_PORT=9072 78 | PHP72_WORKERMAN_PORT=9502 79 | PHP72_EXTENSIONS=bcmath,pdo,mysqli,pdo_mysql,redis,bz2,calendar,opcache,pcntl,sockets,xdebug,gd,yaconf 80 | PHP72_CONTAINER_NAME=dnmp-php72 81 | 82 | #+--------------+ 83 | # PHP7.4 84 | #+--------------+ 85 | PHP74_VERSION=7.4.16 86 | PHP74_IMAGE_TAG=php7.4-v1 87 | PHP74_FPM_PORT=9074 88 | PHP74_EXTENSIONS=gd,bcmath,pdo,mysqli,pdo_mysql,redis,bz2,calendar,opcache,pcntl,sockets,xdebug,amqp,zip 89 | PHP74_CONTAINER_NAME=dnmp-php74 90 | 91 | #+--------------+ 92 | # PHP8.2 93 | #+--------------+ 94 | PHP82_VERSION=8.2.10 95 | PHP82_IMAGE_TAG=php8.2-v1 96 | PHP82_FPM_PORT=9082 97 | PHP82_EXTENSIONS=gd,bcmath,pdo,mysqli,pdo_mysql,redis,bz2,calendar,opcache,pcntl,sockets,amqp,zip,event 98 | PHP82_CONTAINER_NAME=dnmp-php82 99 | 100 | #+--------------+ 101 | # MySQL 102 | #+--------------+ 103 | # Docker Tinywan Images 104 | MYSQL_CHINA_IMAGE_BASE=registry.cn-beijing.aliyuncs.com/tinywan/mysql 105 | # Docker Official Images 106 | MYSQL_IMAGE_BASE=mysql 107 | MYSQL_IMAGE_TAG=5.7 108 | MYSQL_HOST_PORT=3306 109 | MYSQL_ROOT_PASSWORD=123456 110 | MYSQL_DATA_DIR=./data/mysql 111 | MYSQL_CONF_FILE=./conf/mysql/my.cnf 112 | MYSQL_CONTAINER_NAME=dnmp-mysql 113 | 114 | #+--------------+ 115 | # MariaDB 116 | #+--------------+ 117 | # Docker Tinywan Images 118 | MariaDB_CHINA_IMAGE_BASE=registry.cn-beijing.aliyuncs.com/tinywan/mysql 119 | # Docker Official Images 120 | MariaDB_IMAGE_BASE=mariadb 121 | MariaDB_IMAGE_TAG=10.5.10 122 | MariaDB_HOST_PORT=3306 123 | MariaDB_ROOT_PASSWORD=123456 124 | MariaDB_DATA_DIR=./data/mariadb 125 | MariaDB_CONF_FILE=./conf/mariadb/my.cnf 126 | MariaDB_CONTAINER_NAME=dnmp-mariadb 127 | 128 | #+--------------+ 129 | # Redis 130 | #+--------------+ 131 | REDIS_VERSION=5.0.5-alpine 132 | REDIS_IMAGE_TAG=5.0.5-alpine 133 | REDIS_HOST_PORT=6379 134 | REDIS_CONF_FILE=./conf/redis/redis.conf 135 | REDIS_DATA_DIR=./data/redis 136 | REDIS_CONTAINER_NAME=dnmp-redis 137 | 138 | #+--------------+ 139 | # PHPMyAdmin 140 | #+--------------+ 141 | PHPMYADMIN_TAG=latest 142 | PHPMYADMIN_HOST_PORT=8082 143 | 144 | #+--------------+ 145 | # RabbitMQ 146 | #+--------------+ 147 | RABBITMQ_VERSION=management 148 | # 客户端接口 149 | RABBITMQ_HOST_PORT_CLIENT=5672 150 | # Web 管理界面 http://127.0.0.1:15672/ 151 | RABBITMQ_HOST_PORT_MANAGEMENT=15672 152 | # 默认账号和密码 153 | RABBITMQ_DEFAULT_USER=resty 154 | RABBITMQ_DEFAULT_PASS=resty 155 | RABBITMQ_CONTAINER_NAME=dnmp-rabbitmq 156 | 157 | #+--------------+ 158 | # etcd 159 | #+--------------+ 160 | ETCD_VERSION=3.3.13-r80 161 | ETCD_IMAGE_TAG=bitnami/etcd 162 | ETCD_HTTP_PORT=2379 163 | ETCD_PEER_PORT=2380 164 | ETCD_CONF_FILE=./conf/etcd/etcd.conf.yml 165 | ETCD_DATA_DIR=./data/etcd 166 | ETCD_CONTAINER_NAME=dnmp-etcd -------------------------------------------------------------------------------- /images/Docker_Install_mostov_twitter-_-facebook-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/images/Docker_Install_mostov_twitter-_-facebook-2.png -------------------------------------------------------------------------------- /images/SQL审核平台.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/images/SQL审核平台.png -------------------------------------------------------------------------------- /images/dnmp-mysql.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/images/dnmp-mysql.gif -------------------------------------------------------------------------------- /images/docker-composer-https.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/images/docker-composer-https.png -------------------------------------------------------------------------------- /images/docker-composer-lnmp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/images/docker-composer-lnmp.png -------------------------------------------------------------------------------- /images/docker-data-clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/images/docker-data-clear.png -------------------------------------------------------------------------------- /images/engine-components-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/images/engine-components-flow.png -------------------------------------------------------------------------------- /images/scheduler-crontab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/images/scheduler-crontab.png -------------------------------------------------------------------------------- /img/engine-components-flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/img/engine-components-flow.png -------------------------------------------------------------------------------- /log/nacos/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /log/nginx/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /log/php/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /log/redis/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /services/nacos/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7.5.1804 2 | MAINTAINER pader "huangmnlove@163.com" 3 | 4 | # set environment 5 | ENV MODE="cluster" \ 6 | PREFER_HOST_MODE="ip"\ 7 | BASE_DIR="/home/nacos" \ 8 | CLASSPATH=".:/home/nacos/conf:$CLASSPATH" \ 9 | CLUSTER_CONF="/home/nacos/conf/cluster.conf" \ 10 | FUNCTION_MODE="all" \ 11 | JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk" \ 12 | NACOS_USER="nacos" \ 13 | JAVA="/usr/lib/jvm/java-1.8.0-openjdk/bin/java" \ 14 | JVM_XMS="2g" \ 15 | JVM_XMX="2g" \ 16 | JVM_XMN="1g" \ 17 | JVM_MS="128m" \ 18 | JVM_MMS="320m" \ 19 | NACOS_DEBUG="n" \ 20 | TOMCAT_ACCESSLOG_ENABLED="false" \ 21 | TIME_ZONE="Asia/Shanghai" 22 | 23 | ARG NACOS_VERSION=1.4.0 24 | 25 | WORKDIR /$BASE_DIR 26 | 27 | RUN set -x \ 28 | && yum update -y \ 29 | && yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel wget iputils nc vim libcurl 30 | RUN wget https://github.com/alibaba/nacos/releases/download/${NACOS_VERSION}/nacos-server-${NACOS_VERSION}.tar.gz -P /home 31 | RUN tar -xzvf /home/nacos-server-${NACOS_VERSION}.tar.gz -C /home \ 32 | && rm -rf /home/nacos-server-${NACOS_VERSION}.tar.gz /home/nacos/bin/* /home/nacos/conf/*.properties /home/nacos/conf/*.example /home/nacos/conf/nacos-mysql.sql 33 | RUN yum autoremove -y wget \ 34 | && ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone \ 35 | && yum clean all 36 | 37 | 38 | 39 | 40 | ADD bin/docker-startup.sh bin/docker-startup.sh 41 | ADD conf/application.properties conf/application.properties 42 | ADD init.d/custom.properties init.d/custom.properties 43 | 44 | 45 | # set startup log dir 46 | RUN mkdir -p logs \ 47 | && cd logs \ 48 | && touch start.out \ 49 | && ln -sf /dev/stdout start.out \ 50 | && ln -sf /dev/stderr start.out 51 | RUN chmod +x bin/docker-startup.sh 52 | 53 | EXPOSE 8848 54 | ENTRYPOINT ["bin/docker-startup.sh"] -------------------------------------------------------------------------------- /services/nacos/bin/docker-startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 1999-2018 Alibaba Group Holding Ltd. 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | set -x 15 | export DEFAULT_SEARCH_LOCATIONS="classpath:/,classpath:/config/,file:./,file:./config/" 16 | export CUSTOM_SEARCH_LOCATIONS=${DEFAULT_SEARCH_LOCATIONS},file:${BASE_DIR}/conf/,${BASE_DIR}/init.d/ 17 | export CUSTOM_SEARCH_NAMES="application,custom" 18 | export MEMBER_LIST="" 19 | PLUGINS_DIR="/home/nacos/plugins/peer-finder" 20 | function print_servers(){ 21 | if [[ ! -d "${PLUGINS_DIR}" ]]; then 22 | echo "" > "$CLUSTER_CONF" 23 | for server in ${NACOS_SERVERS}; do 24 | echo "$server" >> "$CLUSTER_CONF" 25 | done 26 | else 27 | bash $PLUGINS_DIR/plugin.sh 28 | sleep 30 29 | fi 30 | } 31 | #=========================================================================================== 32 | # JVM Configuration 33 | #=========================================================================================== 34 | if [[ "${MODE}" == "standalone" ]]; then 35 | 36 | JAVA_OPT="${JAVA_OPT} -Xms${JVM_XMS} -Xmx${JVM_XMX} -Xmn${JVM_XMN}" 37 | JAVA_OPT="${JAVA_OPT} -Dnacos.standalone=true" 38 | else 39 | if [[ "${EMBEDDED_STORAGE}" == "embedded" ]]; then 40 | JAVA_OPT="${JAVA_OPT} -DembeddedStorage=true" 41 | fi 42 | JAVA_OPT="${JAVA_OPT} -server -Xms${JVM_XMS} -Xmx${JVM_XMX} -Xmn${JVM_XMN} -XX:MetaspaceSize=${JVM_MS} -XX:MaxMetaspaceSize=${JVM_MMS}" 43 | if [[ "${NACOS_DEBUG}" == "y" ]]; then 44 | JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n" 45 | fi 46 | JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${BASE_DIR}/logs/java_heapdump.hprof" 47 | JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages" 48 | print_servers 49 | fi 50 | 51 | #=========================================================================================== 52 | # Setting system properties 53 | #=========================================================================================== 54 | # set mode that Nacos Server function of split 55 | if [[ "${FUNCTION_MODE}" == "config" ]]; then 56 | JAVA_OPT="${JAVA_OPT} -Dnacos.functionMode=config" 57 | elif [[ "${FUNCTION_MODE}" == "naming" ]]; then 58 | JAVA_OPT="${JAVA_OPT} -Dnacos.functionMode=naming" 59 | fi 60 | # set nacos server ip 61 | if [[ ! -z "${NACOS_SERVER_IP}" ]]; then 62 | JAVA_OPT="${JAVA_OPT} -Dnacos.server.ip=${NACOS_SERVER_IP}" 63 | fi 64 | 65 | if [[ ! -z "${USE_ONLY_SITE_INTERFACES}" ]]; then 66 | JAVA_OPT="${JAVA_OPT} -Dnacos.inetutils.use-only-site-local-interfaces=${USE_ONLY_SITE_INTERFACES}" 67 | fi 68 | 69 | if [[ ! -z "${PREFERRED_NETWORKS}" ]]; then 70 | JAVA_OPT="${JAVA_OPT} -Dnacos.inetutils.preferred-networks=${PREFERRED_NETWORKS}" 71 | fi 72 | 73 | if [[ ! -z "${IGNORED_INTERFACES}" ]]; then 74 | JAVA_OPT="${JAVA_OPT} -Dnacos.inetutils.ignored-interfaces=${IGNORED_INTERFACES}" 75 | fi 76 | 77 | ### If turn on auth system: 78 | if [[ ! -z "${NACOS_AUTH_ENABLE}" ]]; then 79 | JAVA_OPT="${JAVA_OPT} -Dnacos.core.auth.enabled=${NACOS_AUTH_ENABLE}" 80 | fi 81 | 82 | if [[ "${PREFER_HOST_MODE}" == "hostname" ]]; then 83 | JAVA_OPT="${JAVA_OPT} -Dnacos.preferHostnameOverIp=true" 84 | fi 85 | 86 | JAVA_OPT="${JAVA_OPT} -Dnacos.member.list=${MEMBER_LIST}" 87 | 88 | JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p') 89 | if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then 90 | JAVA_OPT="${JAVA_OPT} -cp .:${BASE_DIR}/plugins/cmdb/*.jar:${BASE_DIR}/plugins/mysql/*.jar" 91 | JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${BASE_DIR}/logs/nacos_gc.log:time,tags:filecount=10,filesize=102400" 92 | else 93 | JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${BASE_DIR}/plugins/health:${BASE_DIR}/plugins/cmdb:${BASE_DIR}/plugins/mysql" 94 | JAVA_OPT="${JAVA_OPT} -Xloggc:${BASE_DIR}/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M" 95 | fi 96 | 97 | 98 | 99 | JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}" 100 | JAVA_OPT="${JAVA_OPT} -jar ${BASE_DIR}/target/nacos-server.jar" 101 | JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}" 102 | JAVA_OPT="${JAVA_OPT} --spring.config.location=${CUSTOM_SEARCH_LOCATIONS}" 103 | JAVA_OPT="${JAVA_OPT} --spring.config.name=${CUSTOM_SEARCH_NAMES}" 104 | JAVA_OPT="${JAVA_OPT} --logging.config=${BASE_DIR}/conf/nacos-logback.xml" 105 | JAVA_OPT="${JAVA_OPT} --server.max-http-header-size=524288" 106 | 107 | echo "nacos is starting,you can check the ${BASE_DIR}/logs/start.out" 108 | echo "$JAVA ${JAVA_OPT}" > ${BASE_DIR}/logs/start.out 2>&1 & 109 | nohup $JAVA ${JAVA_OPT} > ${BASE_DIR}/logs/start.out 2>&1 < /dev/null 110 | -------------------------------------------------------------------------------- /services/nacos/conf/application.properties: -------------------------------------------------------------------------------- 1 | # spring 2 | server.servlet.contextPath=${SERVER_SERVLET_CONTEXTPATH:/nacos} 3 | server.contextPath=/nacos 4 | server.port=${NACOS_APPLICATION_PORT:8848} 5 | spring.datasource.platform=${SPRING_DATASOURCE_PLATFORM:""} 6 | nacos.cmdb.dumpTaskInterval=3600 7 | nacos.cmdb.eventTaskInterval=10 8 | nacos.cmdb.labelTaskInterval=300 9 | nacos.cmdb.loadDataAtStart=false 10 | db.num=${MYSQL_DATABASE_NUM:1} 11 | db.url.0=jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT:3306}/${MYSQL_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=${MYSQL_SSL_ENABLE:false} 12 | db.url.1=jdbc:mysql://${MYSQL_SERVICE_HOST}:${MYSQL_SERVICE_PORT:3306}/${MYSQL_SERVICE_DB_NAME}?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=${MYSQL_SSL_ENABLE:false} 13 | db.user=${MYSQL_SERVICE_USER} 14 | db.password=${MYSQL_SERVICE_PASSWORD} 15 | ### The auth system to use, currently only 'nacos' is supported: 16 | nacos.core.auth.system.type=${NACOS_AUTH_SYSTEM_TYPE:nacos} 17 | 18 | 19 | ### The token expiration in seconds: 20 | nacos.core.auth.default.token.expire.seconds=${NACOS_AUTH_TOKEN_EXPIRE_SECONDS:18000} 21 | 22 | ### The default token: 23 | nacos.core.auth.default.token.secret.key=${NACOS_AUTH_TOKEN:SecretKey012345678901234567890123456789012345678901234567890123456789} 24 | 25 | ### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay. 26 | nacos.core.auth.caching.enabled=${NACOS_AUTH_CACHE_ENABLE:false} 27 | 28 | server.tomcat.accesslog.enabled=${TOMCAT_ACCESSLOG_ENABLED:false} 29 | server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D 30 | # default current work dir 31 | server.tomcat.basedir= 32 | ## spring security config 33 | ### turn off security 34 | nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/** 35 | # metrics for elastic search 36 | management.metrics.export.elastic.enabled=false 37 | management.metrics.export.influx.enabled=false 38 | 39 | nacos.naming.distro.taskDispatchThreadCount=10 40 | nacos.naming.distro.taskDispatchPeriod=200 41 | nacos.naming.distro.batchSyncKeyCount=1000 42 | nacos.naming.distro.initDataRatio=0.9 43 | nacos.naming.distro.syncRetryDelay=5000 44 | nacos.naming.data.warmup=true 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /services/nacos/env/mysql.env: -------------------------------------------------------------------------------- 1 | MYSQL_ROOT_PASSWORD=root 2 | MYSQL_DATABASE=nacos_devtest 3 | MYSQL_USER=nacos 4 | MYSQL_PASSWORD=nacos -------------------------------------------------------------------------------- /services/nacos/env/nacos-embedded.env: -------------------------------------------------------------------------------- 1 | #nacos dev env 2 | PREFER_HOST_MODE=hostname 3 | EMBEDDED_STORAGE=embedded 4 | NACOS_SERVERS=nacos1:8848 nacos2:8848 nacos3:8848 5 | MYSQL_SERVICE_DB_NAME=nacos_devtest 6 | MYSQL_SERVICE_PORT=3306 7 | MYSQL_SERVICE_USER=nacos 8 | MYSQL_SERVICE_PASSWORD=nacos 9 | -------------------------------------------------------------------------------- /services/nacos/env/nacos-hostname.env: -------------------------------------------------------------------------------- 1 | #nacos dev env 2 | PREFER_HOST_MODE=hostname 3 | NACOS_SERVERS=nacos1:8848 nacos2:8848 nacos3:8848 4 | MYSQL_SERVICE_HOST=mysql 5 | MYSQL_SERVICE_DB_NAME=nacos_devtest 6 | MYSQL_SERVICE_PORT=3306 7 | MYSQL_SERVICE_USER=nacos 8 | MYSQL_SERVICE_PASSWORD=nacos -------------------------------------------------------------------------------- /services/nacos/env/nacos-ip.env: -------------------------------------------------------------------------------- 1 | #nacos dev env 2 | NACOS_SERVERS=172.16.238.10:8848 172.16.238.11:8848 172.16.238.12:8848 3 | MYSQL_SERVICE_HOST=mysql 4 | MYSQL_SERVICE_DB_NAME=nacos_devtest 5 | MYSQL_SERVICE_PORT=3306 6 | MYSQL_SERVICE_USER=nacos 7 | MYSQL_SERVICE_PASSWORD=nacos -------------------------------------------------------------------------------- /services/nacos/env/nacos-standlone-mysql.env: -------------------------------------------------------------------------------- 1 | PREFER_HOST_MODE=hostname 2 | MODE=standalone 3 | SPRING_DATASOURCE_PLATFORM=mysql 4 | MYSQL_SERVICE_HOST=dnmp-mysql 5 | MYSQL_SERVICE_DB_NAME=nacos 6 | MYSQL_SERVICE_PORT=3306 7 | MYSQL_SERVICE_USER=root 8 | MYSQL_SERVICE_PASSWORD=123456 -------------------------------------------------------------------------------- /services/nacos/init.d/custom.properties: -------------------------------------------------------------------------------- 1 | #spring.security.enabled=false 2 | #management.security=false 3 | #security.basic.enabled=false 4 | #nacos.security.ignore.urls=/** 5 | #management.metrics.export.elastic.host=http://localhost:9200 6 | # metrics for prometheus 7 | #management.endpoints.web.exposure.include=* 8 | 9 | # metrics for elastic search 10 | #management.metrics.export.elastic.enabled=false 11 | #management.metrics.export.elastic.host=http://localhost:9200 12 | 13 | # metrics for influx 14 | #management.metrics.export.influx.enabled=false 15 | #management.metrics.export.influx.db=springboot 16 | #management.metrics.export.influx.uri=http://localhost:8086 17 | #management.metrics.export.influx.auto-create-db=true 18 | #management.metrics.export.influx.consistency=one 19 | #management.metrics.export.influx.compressed=true -------------------------------------------------------------------------------- /services/nacos/nacos-mysql.sql: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2018 Alibaba Group Holding Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /******************************************/ 18 | /* 数据库全名 = nacos_config */ 19 | /* 表名称 = config_info */ 20 | /******************************************/ 21 | CREATE TABLE `config_info` ( 22 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', 23 | `data_id` varchar(255) NOT NULL COMMENT 'data_id', 24 | `group_id` varchar(255) DEFAULT NULL, 25 | `content` longtext NOT NULL COMMENT 'content', 26 | `md5` varchar(32) DEFAULT NULL COMMENT 'md5', 27 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 28 | `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', 29 | `src_user` text COMMENT 'source user', 30 | `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip', 31 | `app_name` varchar(128) DEFAULT NULL, 32 | `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段', 33 | `c_desc` varchar(256) DEFAULT NULL, 34 | `c_use` varchar(64) DEFAULT NULL, 35 | `effect` varchar(64) DEFAULT NULL, 36 | `type` varchar(64) DEFAULT NULL, 37 | `c_schema` text, 38 | PRIMARY KEY (`id`), 39 | UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`) 40 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info'; 41 | 42 | /******************************************/ 43 | /* 数据库全名 = nacos_config */ 44 | /* 表名称 = config_info_aggr */ 45 | /******************************************/ 46 | CREATE TABLE `config_info_aggr` ( 47 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', 48 | `data_id` varchar(255) NOT NULL COMMENT 'data_id', 49 | `group_id` varchar(255) NOT NULL COMMENT 'group_id', 50 | `datum_id` varchar(255) NOT NULL COMMENT 'datum_id', 51 | `content` longtext NOT NULL COMMENT '内容', 52 | `gmt_modified` datetime NOT NULL COMMENT '修改时间', 53 | `app_name` varchar(128) DEFAULT NULL, 54 | `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段', 55 | PRIMARY KEY (`id`), 56 | UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`) 57 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段'; 58 | 59 | 60 | /******************************************/ 61 | /* 数据库全名 = nacos_config */ 62 | /* 表名称 = config_info_beta */ 63 | /******************************************/ 64 | CREATE TABLE `config_info_beta` ( 65 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', 66 | `data_id` varchar(255) NOT NULL COMMENT 'data_id', 67 | `group_id` varchar(128) NOT NULL COMMENT 'group_id', 68 | `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name', 69 | `content` longtext NOT NULL COMMENT 'content', 70 | `beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps', 71 | `md5` varchar(32) DEFAULT NULL COMMENT 'md5', 72 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 73 | `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', 74 | `src_user` text COMMENT 'source user', 75 | `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip', 76 | `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段', 77 | PRIMARY KEY (`id`), 78 | UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`) 79 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta'; 80 | 81 | /******************************************/ 82 | /* 数据库全名 = nacos_config */ 83 | /* 表名称 = config_info_tag */ 84 | /******************************************/ 85 | CREATE TABLE `config_info_tag` ( 86 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', 87 | `data_id` varchar(255) NOT NULL COMMENT 'data_id', 88 | `group_id` varchar(128) NOT NULL COMMENT 'group_id', 89 | `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id', 90 | `tag_id` varchar(128) NOT NULL COMMENT 'tag_id', 91 | `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name', 92 | `content` longtext NOT NULL COMMENT 'content', 93 | `md5` varchar(32) DEFAULT NULL COMMENT 'md5', 94 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 95 | `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', 96 | `src_user` text COMMENT 'source user', 97 | `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip', 98 | PRIMARY KEY (`id`), 99 | UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`) 100 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag'; 101 | 102 | /******************************************/ 103 | /* 数据库全名 = nacos_config */ 104 | /* 表名称 = config_tags_relation */ 105 | /******************************************/ 106 | CREATE TABLE `config_tags_relation` ( 107 | `id` bigint(20) NOT NULL COMMENT 'id', 108 | `tag_name` varchar(128) NOT NULL COMMENT 'tag_name', 109 | `tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type', 110 | `data_id` varchar(255) NOT NULL COMMENT 'data_id', 111 | `group_id` varchar(128) NOT NULL COMMENT 'group_id', 112 | `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id', 113 | `nid` bigint(20) NOT NULL AUTO_INCREMENT, 114 | PRIMARY KEY (`nid`), 115 | UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`), 116 | KEY `idx_tenant_id` (`tenant_id`) 117 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation'; 118 | 119 | /******************************************/ 120 | /* 数据库全名 = nacos_config */ 121 | /* 表名称 = group_capacity */ 122 | /******************************************/ 123 | CREATE TABLE `group_capacity` ( 124 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID', 125 | `group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群', 126 | `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值', 127 | `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量', 128 | `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值', 129 | `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值', 130 | `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值', 131 | `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量', 132 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 133 | `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', 134 | PRIMARY KEY (`id`), 135 | UNIQUE KEY `uk_group_id` (`group_id`) 136 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表'; 137 | 138 | /******************************************/ 139 | /* 数据库全名 = nacos_config */ 140 | /* 表名称 = his_config_info */ 141 | /******************************************/ 142 | CREATE TABLE `his_config_info` ( 143 | `id` bigint(64) unsigned NOT NULL, 144 | `nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT, 145 | `data_id` varchar(255) NOT NULL, 146 | `group_id` varchar(128) NOT NULL, 147 | `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name', 148 | `content` longtext NOT NULL, 149 | `md5` varchar(32) DEFAULT NULL, 150 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 151 | `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, 152 | `src_user` text, 153 | `src_ip` varchar(50) DEFAULT NULL, 154 | `op_type` char(10) DEFAULT NULL, 155 | `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段', 156 | PRIMARY KEY (`nid`), 157 | KEY `idx_gmt_create` (`gmt_create`), 158 | KEY `idx_gmt_modified` (`gmt_modified`), 159 | KEY `idx_did` (`data_id`) 160 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造'; 161 | 162 | 163 | /******************************************/ 164 | /* 数据库全名 = nacos_config */ 165 | /* 表名称 = tenant_capacity */ 166 | /******************************************/ 167 | CREATE TABLE `tenant_capacity` ( 168 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID', 169 | `tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID', 170 | `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值', 171 | `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量', 172 | `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值', 173 | `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数', 174 | `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值', 175 | `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量', 176 | `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', 177 | `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', 178 | PRIMARY KEY (`id`), 179 | UNIQUE KEY `uk_tenant_id` (`tenant_id`) 180 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表'; 181 | 182 | 183 | CREATE TABLE `tenant_info` ( 184 | `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', 185 | `kp` varchar(128) NOT NULL COMMENT 'kp', 186 | `tenant_id` varchar(128) default '' COMMENT 'tenant_id', 187 | `tenant_name` varchar(128) default '' COMMENT 'tenant_name', 188 | `tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc', 189 | `create_source` varchar(32) DEFAULT NULL COMMENT 'create_source', 190 | `gmt_create` bigint(20) NOT NULL COMMENT '创建时间', 191 | `gmt_modified` bigint(20) NOT NULL COMMENT '修改时间', 192 | PRIMARY KEY (`id`), 193 | UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`), 194 | KEY `idx_tenant_id` (`tenant_id`) 195 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info'; 196 | 197 | CREATE TABLE `users` ( 198 | `username` varchar(50) NOT NULL PRIMARY KEY, 199 | `password` varchar(500) NOT NULL, 200 | `enabled` boolean NOT NULL 201 | ); 202 | 203 | CREATE TABLE `roles` ( 204 | `username` varchar(50) NOT NULL, 205 | `role` varchar(50) NOT NULL, 206 | UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE 207 | ); 208 | 209 | CREATE TABLE `permissions` ( 210 | `role` varchar(50) NOT NULL, 211 | `resource` varchar(255) NOT NULL, 212 | `action` varchar(8) NOT NULL, 213 | UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE 214 | ); 215 | 216 | INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE); 217 | 218 | INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN'); 219 | -------------------------------------------------------------------------------- /services/php/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PHP_VERSION 2 | FROM ${PHP_VERSION} 3 | 4 | ARG TZ 5 | ARG PHP_EXTENSIONS 6 | ARG CONTAINER_PACKAGE_URL 7 | 8 | 9 | RUN if [ $CONTAINER_PACKAGE_URL ] ; then sed -i "s/dl-cdn.alpinelinux.org/${CONTAINER_PACKAGE_URL}/g" /etc/apk/repositories ; fi 10 | 11 | 12 | COPY ./extensions /tmp/extensions 13 | WORKDIR /tmp/extensions 14 | RUN chmod +x install.sh \ 15 | && sh install.sh \ 16 | && rm -rf /tmp/extensions 17 | 18 | ADD ./extensions/install-php-extensions /usr/local/bin/ 19 | 20 | RUN chmod uga+x /usr/local/bin/install-php-extensions 21 | 22 | RUN apk --no-cache add tzdata \ 23 | && cp "/usr/share/zoneinfo/$TZ" /etc/localtime \ 24 | && echo "$TZ" > /etc/timezone 25 | 26 | 27 | # Fix: https://github.com/docker-library/php/issues/240 28 | RUN apk add gnu-libiconv libstdc++ --no-cache --repository http://${CONTAINER_PACKAGE_URL}/alpine/edge/community/ --allow-untrusted 29 | ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php 30 | 31 | 32 | # Install composer and change it's cache home 33 | RUN curl -o /usr/bin/composer https://mirrors.aliyun.com/composer/composer.phar \ 34 | && chmod +x /usr/bin/composer 35 | ENV COMPOSER_HOME=/tmp/composer 36 | 37 | # php image's www-data user uid & gid are 82, change them to 1000 (primary user) 38 | RUN apk --no-cache add shadow && usermod -u 1000 www-data && groupmod -g 1000 www-data 39 | 40 | WORKDIR /var/www 41 | -------------------------------------------------------------------------------- /services/php/extensions/amqp-1.9.4.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/amqp-1.9.4.tgz -------------------------------------------------------------------------------- /services/php/extensions/event-2.5.3.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/event-2.5.3.tgz -------------------------------------------------------------------------------- /services/php/extensions/grpc-1.33.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/grpc-1.33.1.tgz -------------------------------------------------------------------------------- /services/php/extensions/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MC="-j$(nproc)" 4 | 5 | echo 6 | echo "============================================" 7 | echo "Install extensions from : install.sh" 8 | echo "PHP version : ${PHP_VERSION}" 9 | echo "Extra Extensions : ${PHP_EXTENSIONS}" 10 | echo "Multicore Compilation : ${MC}" 11 | echo "Container package url : ${CONTAINER_PACKAGE_URL}" 12 | echo "Work directory : ${PWD}" 13 | echo "============================================" 14 | echo 15 | 16 | 17 | if [ "${PHP_EXTENSIONS}" != "" ]; then 18 | apk --update add --no-cache --virtual .build-deps autoconf g++ libtool make curl-dev gettext-dev linux-headers 19 | fi 20 | 21 | export EXTENSIONS=",${PHP_EXTENSIONS}," 22 | 23 | # 24 | # Check if current php version is greater than or equal to 25 | # specific version. 26 | # 27 | # For example, to check if current php is greater than or 28 | # equal to PHP 7.0: 29 | # 30 | # isPhpVersionGreaterOrEqual 7 0 31 | # 32 | # Param 1: Specific PHP Major version 33 | # Param 2: Specific PHP Minor version 34 | # Return : 1 if greater than or equal to, 0 if less than 35 | # 36 | isPhpVersionGreaterOrEqual() 37 | { 38 | local PHP_MAJOR_VERSION=$(php -r "echo PHP_MAJOR_VERSION;") 39 | local PHP_MINOR_VERSION=$(php -r "echo PHP_MINOR_VERSION;") 40 | 41 | if [[ "$PHP_MAJOR_VERSION" -gt "$1" || "$PHP_MAJOR_VERSION" -eq "$1" && "$PHP_MINOR_VERSION" -ge "$2" ]]; then 42 | return 1; 43 | else 44 | return 0; 45 | fi 46 | } 47 | 48 | 49 | # 50 | # Install extension from package file(.tgz), 51 | # For example: 52 | # 53 | # installExtensionFromTgz redis-5.2.2 54 | # 55 | # Param 1: Package name with version 56 | # Param 2: enable options 57 | # 58 | installExtensionFromTgz() 59 | { 60 | tgzName=$1 61 | extensionName="${tgzName%%-*}" 62 | 63 | mkdir ${extensionName} 64 | tar -xf ${tgzName}.tgz -C ${extensionName} --strip-components=1 65 | ( cd ${extensionName} && phpize && ./configure && make ${MC} && make install ) 66 | 67 | docker-php-ext-enable ${extensionName} $2 68 | } 69 | 70 | 71 | if [[ -z "${EXTENSIONS##*,pdo_mysql,*}" ]]; then 72 | echo "---------- Install pdo_mysql ----------" 73 | docker-php-ext-install ${MC} pdo_mysql 74 | fi 75 | 76 | if [[ -z "${EXTENSIONS##*,pcntl,*}" ]]; then 77 | echo "---------- Install pcntl ----------" 78 | docker-php-ext-install ${MC} pcntl 79 | fi 80 | 81 | if [[ -z "${EXTENSIONS##*,mysqli,*}" ]]; then 82 | echo "---------- Install mysqli ----------" 83 | docker-php-ext-install ${MC} mysqli 84 | fi 85 | 86 | if [[ -z "${EXTENSIONS##*,mbstring,*}" ]]; then 87 | echo "---------- mbstring is installed ----------" 88 | fi 89 | 90 | if [[ -z "${EXTENSIONS##*,exif,*}" ]]; then 91 | echo "---------- Install exif ----------" 92 | docker-php-ext-install ${MC} exif 93 | fi 94 | 95 | if [[ -z "${EXTENSIONS##*,bcmath,*}" ]]; then 96 | echo "---------- Install bcmath ----------" 97 | docker-php-ext-install ${MC} bcmath 98 | fi 99 | 100 | if [[ -z "${EXTENSIONS##*,calendar,*}" ]]; then 101 | echo "---------- Install calendar ----------" 102 | docker-php-ext-install ${MC} calendar 103 | fi 104 | 105 | if [[ -z "${EXTENSIONS##*,zend_test,*}" ]]; then 106 | echo "---------- Install zend_test ----------" 107 | docker-php-ext-install ${MC} zend_test 108 | fi 109 | 110 | if [[ -z "${EXTENSIONS##*,opcache,*}" ]]; then 111 | echo "---------- Install opcache ----------" 112 | docker-php-ext-install opcache 113 | fi 114 | 115 | if [[ -z "${EXTENSIONS##*,sockets,*}" ]]; then 116 | echo "---------- Install sockets ----------" 117 | docker-php-ext-install ${MC} sockets 118 | fi 119 | 120 | if [[ -z "${EXTENSIONS##*,gettext,*}" ]]; then 121 | echo "---------- Install gettext ----------" 122 | apk --no-cache add gettext-dev 123 | docker-php-ext-install ${MC} gettext 124 | 125 | fi 126 | 127 | if [[ -z "${EXTENSIONS##*,shmop,*}" ]]; then 128 | echo "---------- Install shmop ----------" 129 | docker-php-ext-install ${MC} shmop 130 | fi 131 | 132 | if [[ -z "${EXTENSIONS##*,sysvmsg,*}" ]]; then 133 | echo "---------- Install sysvmsg ----------" 134 | docker-php-ext-install ${MC} sysvmsg 135 | fi 136 | 137 | if [[ -z "${EXTENSIONS##*,sysvsem,*}" ]]; then 138 | echo "---------- Install sysvsem ----------" 139 | docker-php-ext-install ${MC} sysvsem 140 | fi 141 | 142 | if [[ -z "${EXTENSIONS##*,sysvshm,*}" ]]; then 143 | echo "---------- Install sysvshm ----------" 144 | docker-php-ext-install ${MC} sysvshm 145 | fi 146 | 147 | if [[ -z "${EXTENSIONS##*,pdo_firebird,*}" ]]; then 148 | echo "---------- Install pdo_firebird ----------" 149 | docker-php-ext-install ${MC} pdo_firebird 150 | fi 151 | 152 | if [[ -z "${EXTENSIONS##*,pdo_dblib,*}" ]]; then 153 | echo "---------- Install pdo_dblib ----------" 154 | docker-php-ext-install ${MC} pdo_dblib 155 | fi 156 | 157 | if [[ -z "${EXTENSIONS##*,pdo_oci,*}" ]]; then 158 | echo "---------- Install pdo_oci ----------" 159 | docker-php-ext-install ${MC} pdo_oci 160 | fi 161 | 162 | if [[ -z "${EXTENSIONS##*,pdo_odbc,*}" ]]; then 163 | echo "---------- Install pdo_odbc ----------" 164 | docker-php-ext-install ${MC} pdo_odbc 165 | fi 166 | 167 | if [[ -z "${EXTENSIONS##*,pdo_pgsql,*}" ]]; then 168 | echo "---------- Install pdo_pgsql ----------" 169 | apk --no-cache add postgresql-dev \ 170 | && docker-php-ext-install ${MC} pdo_pgsql 171 | fi 172 | 173 | if [[ -z "${EXTENSIONS##*,pgsql,*}" ]]; then 174 | echo "---------- Install pgsql ----------" 175 | apk --no-cache add postgresql-dev \ 176 | && docker-php-ext-install ${MC} pgsql 177 | fi 178 | 179 | if [[ -z "${EXTENSIONS##*,oci8,*}" ]]; then 180 | echo "---------- Install oci8 ----------" 181 | docker-php-ext-install ${MC} oci8 182 | fi 183 | 184 | if [[ -z "${EXTENSIONS##*,odbc,*}" ]]; then 185 | echo "---------- Install odbc ----------" 186 | docker-php-ext-install ${MC} odbc 187 | fi 188 | 189 | if [[ -z "${EXTENSIONS##*,dba,*}" ]]; then 190 | echo "---------- Install dba ----------" 191 | docker-php-ext-install ${MC} dba 192 | fi 193 | 194 | if [[ -z "${EXTENSIONS##*,interbase,*}" ]]; then 195 | echo "---------- Install interbase ----------" 196 | echo "Alpine linux do not support interbase/firebird!!!" 197 | #docker-php-ext-install ${MC} interbase 198 | fi 199 | 200 | if [[ -z "${EXTENSIONS##*,gd,*}" ]]; then 201 | echo "---------- Install gd ----------" 202 | isPhpVersionGreaterOrEqual 7 4 203 | 204 | if [[ "$?" = "1" ]]; then 205 | # "--with-xxx-dir" was removed from php 7.4, 206 | # issue: https://github.com/docker-library/php/issues/912 207 | options="--with-freetype --with-jpeg --with-webp" 208 | else 209 | options="--with-gd --with-freetype-dir=/usr/include/ --with-png-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/" 210 | fi 211 | 212 | apk add --no-cache \ 213 | freetype \ 214 | freetype-dev \ 215 | libpng \ 216 | libpng-dev \ 217 | libjpeg-turbo \ 218 | libjpeg-turbo-dev \ 219 | libwebp-dev \ 220 | && docker-php-ext-configure gd ${options} \ 221 | && docker-php-ext-install ${MC} gd \ 222 | && apk del \ 223 | freetype-dev \ 224 | libpng-dev \ 225 | libjpeg-turbo-dev 226 | fi 227 | 228 | if [[ -z "${EXTENSIONS##*,intl,*}" ]]; then 229 | echo "---------- Install intl ----------" 230 | apk add --no-cache icu-dev 231 | docker-php-ext-install ${MC} intl 232 | fi 233 | 234 | if [[ -z "${EXTENSIONS##*,bz2,*}" ]]; then 235 | echo "---------- Install bz2 ----------" 236 | apk add --no-cache bzip2-dev 237 | docker-php-ext-install ${MC} bz2 238 | fi 239 | 240 | if [[ -z "${EXTENSIONS##*,soap,*}" ]]; then 241 | echo "---------- Install soap ----------" 242 | apk add --no-cache libxml2-dev 243 | docker-php-ext-install ${MC} soap 244 | fi 245 | 246 | if [[ -z "${EXTENSIONS##*,xsl,*}" ]]; then 247 | echo "---------- Install xsl ----------" 248 | apk add --no-cache libxml2-dev libxslt-dev 249 | docker-php-ext-install ${MC} xsl 250 | fi 251 | 252 | if [[ -z "${EXTENSIONS##*,xmlrpc,*}" ]]; then 253 | echo "---------- Install xmlrpc ----------" 254 | apk add --no-cache libxml2-dev libxslt-dev 255 | docker-php-ext-install ${MC} xmlrpc 256 | fi 257 | 258 | if [[ -z "${EXTENSIONS##*,wddx,*}" ]]; then 259 | echo "---------- Install wddx ----------" 260 | apk add --no-cache libxml2-dev libxslt-dev 261 | docker-php-ext-install ${MC} wddx 262 | fi 263 | 264 | if [[ -z "${EXTENSIONS##*,curl,*}" ]]; then 265 | echo "---------- curl is installed ----------" 266 | fi 267 | 268 | if [[ -z "${EXTENSIONS##*,readline,*}" ]]; then 269 | echo "---------- Install readline ----------" 270 | apk add --no-cache readline-dev 271 | apk add --no-cache libedit-dev 272 | docker-php-ext-install ${MC} readline 273 | fi 274 | 275 | if [[ -z "${EXTENSIONS##*,snmp,*}" ]]; then 276 | echo "---------- Install snmp ----------" 277 | apk add --no-cache net-snmp-dev 278 | docker-php-ext-install ${MC} snmp 279 | fi 280 | 281 | if [[ -z "${EXTENSIONS##*,pspell,*}" ]]; then 282 | echo "---------- Install pspell ----------" 283 | apk add --no-cache aspell-dev 284 | apk add --no-cache aspell-en 285 | docker-php-ext-install ${MC} pspell 286 | fi 287 | 288 | if [[ -z "${EXTENSIONS##*,recode,*}" ]]; then 289 | echo "---------- Install recode ----------" 290 | apk add --no-cache recode-dev 291 | docker-php-ext-install ${MC} recode 292 | fi 293 | 294 | if [[ -z "${EXTENSIONS##*,tidy,*}" ]]; then 295 | echo "---------- Install tidy ----------" 296 | apk add --no-cache tidyhtml-dev 297 | 298 | # Fix: https://github.com/htacg/tidy-html5/issues/235 299 | ln -s /usr/include/tidybuffio.h /usr/include/buffio.h 300 | 301 | docker-php-ext-install ${MC} tidy 302 | fi 303 | 304 | if [[ -z "${EXTENSIONS##*,gmp,*}" ]]; then 305 | echo "---------- Install gmp ----------" 306 | apk add --no-cache gmp-dev 307 | docker-php-ext-install ${MC} gmp 308 | fi 309 | 310 | if [[ -z "${EXTENSIONS##*,imap,*}" ]]; then 311 | echo "---------- Install imap ----------" 312 | apk add --no-cache imap-dev 313 | docker-php-ext-configure imap --with-imap --with-imap-ssl 314 | docker-php-ext-install ${MC} imap 315 | fi 316 | 317 | if [[ -z "${EXTENSIONS##*,ldap,*}" ]]; then 318 | echo "---------- Install ldap ----------" 319 | apk add --no-cache ldb-dev 320 | apk add --no-cache openldap-dev 321 | docker-php-ext-install ${MC} ldap 322 | fi 323 | 324 | if [[ -z "${EXTENSIONS##*,psr,*}" ]]; then 325 | echo "---------- Install psr ----------" 326 | printf "\n" | pecl install psr 327 | docker-php-ext-enable psr 328 | fi 329 | 330 | if [[ -z "${EXTENSIONS##*,imagick,*}" ]]; then 331 | echo "---------- Install imagick ----------" 332 | apk add --no-cache file-dev 333 | apk add --no-cache imagemagick-dev 334 | printf "\n" | pecl install imagick-3.4.4 335 | docker-php-ext-enable imagick 336 | fi 337 | 338 | if [[ -z "${EXTENSIONS##*,rar,*}" ]]; then 339 | echo "---------- Install rar ----------" 340 | printf "\n" | pecl install rar 341 | docker-php-ext-enable rar 342 | fi 343 | 344 | if [[ -z "${EXTENSIONS##*,ast,*}" ]]; then 345 | echo "---------- Install ast ----------" 346 | printf "\n" | pecl install ast 347 | docker-php-ext-enable ast 348 | fi 349 | 350 | if [[ -z "${EXTENSIONS##*,msgpack,*}" ]]; then 351 | echo "---------- Install msgpack ----------" 352 | printf "\n" | pecl install msgpack 353 | docker-php-ext-enable msgpack 354 | fi 355 | 356 | if [[ -z "${EXTENSIONS##*,igbinary,*}" ]]; then 357 | echo "---------- Install igbinary ----------" 358 | printf "\n" | pecl install igbinary 359 | docker-php-ext-enable igbinary 360 | fi 361 | 362 | 363 | if [[ -z "${EXTENSIONS##*,yac,*}" ]]; then 364 | isPhpVersionGreaterOrEqual 7 0 365 | if [[ "$?" = "1" ]]; then 366 | echo "---------- Install yac ----------" 367 | printf "\n" | pecl install yac-2.0.2 368 | docker-php-ext-enable yac 369 | else 370 | echo "yar requires PHP >= 7.0.0, installed version is ${PHP_VERSION}" 371 | fi 372 | fi 373 | 374 | if [[ -z "${EXTENSIONS##*,yar,*}" ]]; then 375 | isPhpVersionGreaterOrEqual 7 0 376 | if [[ "$?" = "1" ]]; then 377 | echo "---------- Install yar ----------" 378 | printf "\n" | pecl install yar 379 | docker-php-ext-enable yar 380 | else 381 | echo "yar requires PHP >= 7.0.0, installed version is ${PHP_VERSION}" 382 | fi 383 | 384 | fi 385 | 386 | 387 | if [[ -z "${EXTENSIONS##*,yaconf,*}" ]]; then 388 | isPhpVersionGreaterOrEqual 7 0 389 | if [[ "$?" = "1" ]]; then 390 | echo "---------- Install yaconf ----------" 391 | printf "\n" | pecl install yaconf 392 | docker-php-ext-enable yaconf 393 | else 394 | echo "yar requires PHP >= 7.0.0, installed version is ${PHP_VERSION}" 395 | fi 396 | fi 397 | 398 | if [[ -z "${EXTENSIONS##*,seaslog,*}" ]]; then 399 | echo "---------- Install seaslog ----------" 400 | printf "\n" | pecl install seaslog 401 | docker-php-ext-enable seaslog 402 | fi 403 | 404 | if [[ -z "${EXTENSIONS##*,varnish,*}" ]]; then 405 | echo "---------- Install varnish ----------" 406 | apk add --no-cache varnish-dev 407 | printf "\n" | pecl install varnish 408 | docker-php-ext-enable varnish 409 | fi 410 | 411 | if [[ -z "${EXTENSIONS##*,pdo_sqlsrv,*}" ]]; then 412 | isPhpVersionGreaterOrEqual 7 1 413 | if [[ "$?" = "1" ]]; then 414 | echo "---------- Install pdo_sqlsrv ----------" 415 | apk add --no-cache unixodbc-dev 416 | printf "\n" | pecl install pdo_sqlsrv 417 | docker-php-ext-enable pdo_sqlsrv 418 | curl -o /tmp/msodbcsql17_amd64.apk https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.2.1-1_amd64.apk 419 | apk add --allow-untrusted /tmp/msodbcsql17_amd64.apk 420 | else 421 | echo "pdo_sqlsrv requires PHP >= 7.1.0, installed version is ${PHP_VERSION}" 422 | fi 423 | fi 424 | 425 | if [[ -z "${EXTENSIONS##*,sqlsrv,*}" ]]; then 426 | isPhpVersionGreaterOrEqual 7 1 427 | if [[ "$?" = "1" ]]; then 428 | echo "---------- Install sqlsrv ----------" 429 | apk add --no-cache unixodbc-dev 430 | printf "\n" | pecl install sqlsrv 431 | docker-php-ext-enable sqlsrv 432 | else 433 | echo "pdo_sqlsrv requires PHP >= 7.1.0, installed version is ${PHP_VERSION}" 434 | fi 435 | fi 436 | 437 | if [[ -z "${EXTENSIONS##*,mcrypt,*}" ]]; then 438 | isPhpVersionGreaterOrEqual 7 0 439 | if [[ "$?" = "1" ]]; then 440 | echo "---------- Install mcrypt ----------" 441 | apk add --no-cache libmcrypt-dev libmcrypt re2c 442 | printf "\n" |pecl install mcrypt 443 | docker-php-ext-enable mcrypt 444 | else 445 | echo "---------- Install mcrypt ----------" 446 | apk add --no-cache libmcrypt-dev \ 447 | && docker-php-ext-install ${MC} mcrypt 448 | fi 449 | fi 450 | 451 | if [[ -z "${EXTENSIONS##*,mysql,*}" ]]; then 452 | isPhpVersionGreaterOrEqual 7 0 453 | 454 | if [[ "$?" = "1" ]]; then 455 | echo "---------- mysql was REMOVED from PHP 7.0.0 ----------" 456 | else 457 | echo "---------- Install mysql ----------" 458 | docker-php-ext-install ${MC} mysql 459 | fi 460 | fi 461 | 462 | if [[ -z "${EXTENSIONS##*,sodium,*}" ]]; then 463 | isPhpVersionGreaterOrEqual 7 2 464 | if [[ "$?" = "1" ]]; then 465 | echo 466 | echo "Sodium is bundled with PHP from PHP 7.2.0" 467 | echo 468 | else 469 | echo "---------- Install sodium ----------" 470 | apk add --no-cache libsodium-dev 471 | docker-php-ext-install ${MC} sodium 472 | fi 473 | fi 474 | 475 | if [[ -z "${EXTENSIONS##*,amqp,*}" ]]; then 476 | echo "---------- Install amqp ----------" 477 | apk add --no-cache rabbitmq-c-dev 478 | installExtensionFromTgz amqp-1.9.4 479 | fi 480 | 481 | if [[ -z "${EXTENSIONS##*,redis,*}" ]]; then 482 | echo "---------- Install redis ----------" 483 | isPhpVersionGreaterOrEqual 7 0 484 | if [[ "$?" = "1" ]]; then 485 | installExtensionFromTgz redis-5.3.4 486 | else 487 | printf "\n" | pecl install redis-4.3.0 488 | docker-php-ext-enable redis 489 | fi 490 | fi 491 | 492 | if [[ -z "${EXTENSIONS##*,apcu,*}" ]]; then 493 | echo "---------- Install apcu ----------" 494 | installExtensionFromTgz apcu-5.1.17 495 | fi 496 | 497 | if [[ -z "${EXTENSIONS##*,memcached,*}" ]]; then 498 | echo "---------- Install memcached ----------" 499 | apk add --no-cache libmemcached-dev zlib-dev 500 | isPhpVersionGreaterOrEqual 7 0 501 | 502 | if [[ "$?" = "1" ]]; then 503 | printf "\n" | pecl install memcached-3.1.3 504 | else 505 | printf "\n" | pecl install memcached-2.2.0 506 | fi 507 | 508 | docker-php-ext-enable memcached 509 | fi 510 | 511 | if [[ -z "${EXTENSIONS##*,memcache,*}" ]]; then 512 | echo "---------- Install memcache ----------" 513 | isPhpVersionGreaterOrEqual 7 0 514 | if [[ "$?" = "1" ]]; then 515 | installExtensionFromTgz memcache-4.0.5.2 516 | else 517 | installExtensionFromTgz memcache-2.2.6 518 | fi 519 | fi 520 | 521 | if [[ -z "${EXTENSIONS##*,xdebug,*}" ]]; then 522 | echo "---------- Install xdebug ----------" 523 | isPhpVersionGreaterOrEqual 7 0 524 | 525 | if [[ "$?" = "1" ]]; then 526 | isPhpVersionGreaterOrEqual 7 4 527 | if [[ "$?" = "1" ]]; then 528 | installExtensionFromTgz xdebug-2.9.0 529 | else 530 | installExtensionFromTgz xdebug-2.5.5 531 | fi 532 | else 533 | installExtensionFromTgz xdebug-2.5.5 534 | fi 535 | fi 536 | 537 | if [[ -z "${EXTENSIONS##*,event,*}" ]]; then 538 | echo "---------- Install event ----------" 539 | apk add --no-cache libevent-dev 540 | export is_sockets_installed=$(php -r "echo extension_loaded('sockets');") 541 | 542 | if [[ "${is_sockets_installed}" = "" ]]; then 543 | echo "---------- event is depend on sockets, install sockets first ----------" 544 | docker-php-ext-install sockets 545 | fi 546 | 547 | echo "---------- Install event again ----------" 548 | installExtensionFromTgz event-2.5.6 "--ini-name event.ini" 549 | fi 550 | 551 | if [[ -z "${EXTENSIONS##*,mongodb,*}" ]]; then 552 | echo "---------- Install mongodb ----------" 553 | installExtensionFromTgz mongodb-1.7.4 554 | fi 555 | 556 | if [[ -z "${EXTENSIONS##*,yaf,*}" ]]; then 557 | echo "---------- Install yaf ----------" 558 | isPhpVersionGreaterOrEqual 7 0 559 | 560 | if [[ "$?" = "1" ]]; then 561 | printf "\n" | pecl install yaf 562 | docker-php-ext-enable yaf 563 | else 564 | installExtensionFromTgz yaf-2.3.5 565 | fi 566 | fi 567 | 568 | 569 | if [[ -z "${EXTENSIONS##*,swoole,*}" ]]; then 570 | echo "---------- Install swoole ----------" 571 | isPhpVersionGreaterOrEqual 7 0 572 | 573 | if [[ "$?" = "1" ]]; then 574 | installExtensionFromTgz swoole-4.6.7 575 | else 576 | installExtensionFromTgz swoole-2.0.11 577 | fi 578 | fi 579 | 580 | if [[ -z "${EXTENSIONS##*,zip,*}" ]]; then 581 | echo "---------- Install zip ----------" 582 | # Fix: https://github.com/docker-library/php/issues/797 583 | apk add --no-cache libzip-dev 584 | 585 | isPhpVersionGreaterOrEqual 7 4 586 | if [[ "$?" != "1" ]]; then 587 | docker-php-ext-configure zip --with-libzip=/usr/include 588 | fi 589 | 590 | docker-php-ext-install ${MC} zip 591 | fi 592 | 593 | if [[ -z "${EXTENSIONS##*,xhprof,*}" ]]; then 594 | echo "---------- Install XHProf ----------" 595 | 596 | isPhpVersionGreaterOrEqual 7 0 597 | 598 | if [[ "$?" = "1" ]]; then 599 | mkdir xhprof \ 600 | && tar -xf xhprof-2.2.0.tgz -C xhprof --strip-components=1 \ 601 | && ( cd xhprof/extension/ && phpize && ./configure && make ${MC} && make install ) \ 602 | && docker-php-ext-enable xhprof 603 | else 604 | echo "---------- PHP Version>= 7.0----------" 605 | fi 606 | 607 | fi 608 | 609 | if [[ -z "${EXTENSIONS##*,xlswriter,*}" ]]; then 610 | echo "---------- Install xlswriter ----------" 611 | isPhpVersionGreaterOrEqual 7 0 612 | 613 | if [[ "$?" = "1" ]]; then 614 | printf "\n" | pecl install xlswriter 615 | docker-php-ext-enable xlswriter 616 | else 617 | echo "---------- PHP Version>= 7.0----------" 618 | fi 619 | fi 620 | 621 | if [[ -z "${EXTENSIONS##*,rdkafka,*}" ]]; then 622 | echo "---------- Install rdkafka ----------" 623 | isPhpVersionGreaterOrEqual 5 6 624 | 625 | if [[ "$?" = "1" ]]; then 626 | apk add librdkafka-dev 627 | # printf "\n" | pecl install rdkafka 628 | # docker-php-ext-enable rdkafka 629 | installExtensionFromTgz rdkafka-6.0.1 630 | else 631 | echo "---------- PHP Version>= 5.6----------" 632 | fi 633 | fi 634 | 635 | if [[ -z "${EXTENSIONS##*,zookeeper,*}" ]]; then 636 | echo "---------- Install zookeeper ----------" 637 | isPhpVersionGreaterOrEqual 7 0 638 | 639 | if [[ "$?" = "1" ]]; then 640 | apk add re2c 641 | apk add libzookeeper-dev --repository http://${CONTAINER_PACKAGE_URL}/alpine/edge/testing/ 642 | printf "\n" | pecl install zookeeper 643 | docker-php-ext-enable zookeeper 644 | else 645 | echo "---------- PHP Version>= 7.0----------" 646 | fi 647 | fi 648 | 649 | if [[ -z "${EXTENSIONS##*,phalcon,*}" ]]; then 650 | echo "---------- Install phalcon ----------" 651 | isPhpVersionGreaterOrEqual 7 2 652 | 653 | if [[ "$?" = "1" ]]; then 654 | printf "\n" | pecl install phalcon 655 | docker-php-ext-enable psr 656 | docker-php-ext-enable phalcon 657 | else 658 | echo "---------- PHP Version>= 7.2----------" 659 | fi 660 | fi 661 | 662 | if [[ -z "${EXTENSIONS##*,sdebug,*}" ]]; then 663 | echo "---------- Install sdebug ----------" 664 | isPhpVersionGreaterOrEqual 7 2 665 | 666 | if [[ "$?" = "1" ]]; then 667 | curl -SL "https://github.com/swoole/sdebug/archive/sdebug_2_9-beta.tar.gz" -o sdebug.tar.gz \ 668 | && mkdir -p sdebug \ 669 | && tar -xf sdebug.tar.gz -C sdebug --strip-components=1 \ 670 | && rm sdebug.tar.gz \ 671 | && ( \ 672 | cd sdebug \ 673 | && phpize \ 674 | && ./configure --enable-xdebug \ 675 | && make clean && make && make install \ 676 | ) \ 677 | && docker-php-ext-enable xdebug 678 | else 679 | echo "---------- PHP Version>= 7.2----------" 680 | fi 681 | fi 682 | 683 | if [[ -z "${EXTENSIONS##*,protobuf,*}" ]]; then 684 | echo "---------- Install protobuf ----------" 685 | isPhpVersionGreaterOrEqual 7 2 686 | 687 | if [[ "$?" = "1" ]]; then 688 | installExtensionFromTgz protobuf-3.13.0.1 689 | else 690 | echo "---------- PHP Version>= 7.2----------" 691 | fi 692 | fi 693 | 694 | if [[ -z "${EXTENSIONS##*,grpc,*}" ]]; then 695 | echo "---------- Install grpc ----------" 696 | isPhpVersionGreaterOrEqual 7 2 697 | 698 | if [[ "$?" = "1" ]]; then 699 | installExtensionFromTgz grpc-1.33.1 700 | else 701 | echo "---------- PHP Version>= 7.2----------" 702 | fi 703 | fi 704 | 705 | if [ "${PHP_EXTENSIONS}" != "" ]; then 706 | apk del .build-deps \ 707 | && docker-php-source delete 708 | fi -------------------------------------------------------------------------------- /services/php/extensions/protobuf-3.13.0.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/protobuf-3.13.0.1.tgz -------------------------------------------------------------------------------- /services/php/extensions/rdkafka-6.0.1.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/rdkafka-6.0.1.tgz -------------------------------------------------------------------------------- /services/php/extensions/redis-4.3.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/redis-4.3.0.tgz -------------------------------------------------------------------------------- /services/php/extensions/redis-5.3.4.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/redis-5.3.4.tgz -------------------------------------------------------------------------------- /services/php/extensions/swoole-4.6.7.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/swoole-4.6.7.tgz -------------------------------------------------------------------------------- /services/php/extensions/xdebug-2.5.5.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/xdebug-2.5.5.tgz -------------------------------------------------------------------------------- /services/php/extensions/xdebug-2.9.0.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/xdebug-2.9.0.tgz -------------------------------------------------------------------------------- /services/php/extensions/yaf-2.3.5.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php/extensions/yaf-2.3.5.tgz -------------------------------------------------------------------------------- /services/php8/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG PHP_VERSION 2 | FROM ${PHP_VERSION} 3 | 4 | ARG TZ 5 | ARG PHP_EXTENSIONS 6 | ARG CONTAINER_PACKAGE_URL 7 | 8 | 9 | RUN if [ $CONTAINER_PACKAGE_URL ] ; then sed -i "s/dl-cdn.alpinelinux.org/${CONTAINER_PACKAGE_URL}/g" /etc/apk/repositories ; fi 10 | 11 | # phpy install https://github.com/swoole/phpy 12 | # RUN apk add python3 13 | # RUN apk add autoconf gcc g++ make python3-dev 14 | 15 | COPY ./extensions /tmp/extensions 16 | WORKDIR /tmp/extensions 17 | RUN chmod +x install.sh \ 18 | && sh install.sh \ 19 | && rm -rf /tmp/extensions 20 | 21 | ADD ./extensions/install-php-extensions /usr/local/bin/ 22 | 23 | RUN chmod uga+x /usr/local/bin/install-php-extensions 24 | 25 | RUN apk --no-cache add tzdata \ 26 | && cp "/usr/share/zoneinfo/$TZ" /etc/localtime \ 27 | && echo "$TZ" > /etc/timezone 28 | 29 | 30 | # Fix: https://github.com/docker-library/php/issues/240 31 | RUN apk add gnu-libiconv libstdc++ --no-cache --repository http://${CONTAINER_PACKAGE_URL}/alpine/edge/community/ --allow-untrusted 32 | ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php 33 | 34 | 35 | # Install composer and change it's cache home 36 | RUN curl -o /usr/bin/composer https://mirrors.aliyun.com/composer/composer.phar \ 37 | && chmod +x /usr/bin/composer 38 | ENV COMPOSER_HOME=/tmp/composer 39 | 40 | # php image's www-data user uid & gid are 82, change them to 1000 (primary user) 41 | RUN apk --no-cache add shadow && usermod -u 1000 www-data && groupmod -g 1000 www-data 42 | 43 | 44 | WORKDIR /var/www 45 | -------------------------------------------------------------------------------- /services/php8/extensions/event-3.0.6.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php8/extensions/event-3.0.6.tgz -------------------------------------------------------------------------------- /services/php8/extensions/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export MC="-j$(nproc)" 4 | 5 | echo 6 | echo "============================================" 7 | echo "Install extensions from : install.sh" 8 | echo "PHP version : ${PHP_VERSION}" 9 | echo "Extra Extensions : ${PHP_EXTENSIONS}" 10 | echo "Multicore Compilation : ${MC}" 11 | echo "Container package url : ${CONTAINER_PACKAGE_URL}" 12 | echo "Work directory : ${PWD}" 13 | echo "============================================" 14 | echo 15 | 16 | 17 | if [ "${PHP_EXTENSIONS}" != "" ]; then 18 | apk --update add --no-cache --virtual .build-deps autoconf g++ libtool make curl-dev gettext-dev linux-headers 19 | fi 20 | 21 | export EXTENSIONS=",${PHP_EXTENSIONS}," 22 | 23 | # 24 | # Check if current php version is greater than or equal to 25 | # specific version. 26 | # 27 | # For example, to check if current php is greater than or 28 | # equal to PHP 8.0: 29 | # 30 | # isPhpVersionGreaterOrEqual 8 0 31 | # 32 | # Param 1: Specific PHP Major version 33 | # Param 2: Specific PHP Minor version 34 | # Return : 1 if greater than or equal to, 0 if less than 35 | # 36 | isPhpVersionGreaterOrEqual() 37 | { 38 | local PHP_MAJOR_VERSION=$(php -r "echo PHP_MAJOR_VERSION;") 39 | local PHP_MINOR_VERSION=$(php -r "echo PHP_MINOR_VERSION;") 40 | 41 | if [[ "$PHP_MAJOR_VERSION" -gt "$1" || "$PHP_MAJOR_VERSION" -eq "$1" && "$PHP_MINOR_VERSION" -ge "$2" ]]; then 42 | return 1; 43 | else 44 | return 0; 45 | fi 46 | } 47 | 48 | # 49 | # Install extension from package file(.tgz), 50 | # For example: 51 | # 52 | # installExtensionFromTgz redis-5.2.2 53 | # 54 | # Param 1: Package name with version 55 | # Param 2: enable options 56 | # 57 | installExtensionFromTgz() 58 | { 59 | tgzName=$1 60 | extensionName="${tgzName%%-*}" 61 | 62 | mkdir ${extensionName} 63 | tar -xf ${tgzName}.tgz -C ${extensionName} --strip-components=1 64 | ( cd ${extensionName} && phpize && ./configure && make ${MC} && make install ) 65 | 66 | docker-php-ext-enable ${extensionName} $2 67 | } 68 | 69 | 70 | if [[ -z "${EXTENSIONS##*,pdo_mysql,*}" ]]; then 71 | echo "---------- Install pdo_mysql ----------" 72 | docker-php-ext-install ${MC} pdo_mysql 73 | fi 74 | 75 | if [[ -z "${EXTENSIONS##*,pcntl,*}" ]]; then 76 | echo "---------- Install pcntl ----------" 77 | docker-php-ext-install ${MC} pcntl 78 | fi 79 | 80 | if [[ -z "${EXTENSIONS##*,mysqli,*}" ]]; then 81 | echo "---------- Install mysqli ----------" 82 | docker-php-ext-install ${MC} mysqli 83 | fi 84 | 85 | if [[ -z "${EXTENSIONS##*,mbstring,*}" ]]; then 86 | echo "---------- mbstring is installed ----------" 87 | fi 88 | 89 | if [[ -z "${EXTENSIONS##*,exif,*}" ]]; then 90 | echo "---------- Install exif ----------" 91 | docker-php-ext-install ${MC} exif 92 | fi 93 | 94 | if [[ -z "${EXTENSIONS##*,bcmath,*}" ]]; then 95 | echo "---------- Install bcmath ----------" 96 | docker-php-ext-install ${MC} bcmath 97 | fi 98 | 99 | if [[ -z "${EXTENSIONS##*,calendar,*}" ]]; then 100 | echo "---------- Install calendar ----------" 101 | docker-php-ext-install ${MC} calendar 102 | fi 103 | 104 | if [[ -z "${EXTENSIONS##*,zend_test,*}" ]]; then 105 | echo "---------- Install zend_test ----------" 106 | docker-php-ext-install ${MC} zend_test 107 | fi 108 | 109 | if [[ -z "${EXTENSIONS##*,opcache,*}" ]]; then 110 | echo "---------- Install opcache ----------" 111 | docker-php-ext-install opcache 112 | fi 113 | 114 | if [[ -z "${EXTENSIONS##*,sockets,*}" ]]; then 115 | echo "---------- Install sockets ----------" 116 | docker-php-ext-install ${MC} sockets 117 | fi 118 | 119 | if [[ -z "${EXTENSIONS##*,gettext,*}" ]]; then 120 | echo "---------- Install gettext ----------" 121 | apk --no-cache add gettext-dev 122 | docker-php-ext-install ${MC} gettext 123 | 124 | fi 125 | 126 | if [[ -z "${EXTENSIONS##*,shmop,*}" ]]; then 127 | echo "---------- Install shmop ----------" 128 | docker-php-ext-install ${MC} shmop 129 | fi 130 | 131 | if [[ -z "${EXTENSIONS##*,sysvmsg,*}" ]]; then 132 | echo "---------- Install sysvmsg ----------" 133 | docker-php-ext-install ${MC} sysvmsg 134 | fi 135 | 136 | if [[ -z "${EXTENSIONS##*,sysvsem,*}" ]]; then 137 | echo "---------- Install sysvsem ----------" 138 | docker-php-ext-install ${MC} sysvsem 139 | fi 140 | 141 | if [[ -z "${EXTENSIONS##*,sysvshm,*}" ]]; then 142 | echo "---------- Install sysvshm ----------" 143 | docker-php-ext-install ${MC} sysvshm 144 | fi 145 | 146 | if [[ -z "${EXTENSIONS##*,pdo_firebird,*}" ]]; then 147 | echo "---------- Install pdo_firebird ----------" 148 | docker-php-ext-install ${MC} pdo_firebird 149 | fi 150 | 151 | if [[ -z "${EXTENSIONS##*,pdo_dblib,*}" ]]; then 152 | echo "---------- Install pdo_dblib ----------" 153 | docker-php-ext-install ${MC} pdo_dblib 154 | fi 155 | 156 | if [[ -z "${EXTENSIONS##*,pdo_oci,*}" ]]; then 157 | echo "---------- Install pdo_oci ----------" 158 | docker-php-ext-install ${MC} pdo_oci 159 | fi 160 | 161 | if [[ -z "${EXTENSIONS##*,pdo_odbc,*}" ]]; then 162 | echo "---------- Install pdo_odbc ----------" 163 | docker-php-ext-install ${MC} pdo_odbc 164 | fi 165 | 166 | if [[ -z "${EXTENSIONS##*,pdo_pgsql,*}" ]]; then 167 | echo "---------- Install pdo_pgsql ----------" 168 | apk --no-cache add postgresql-dev \ 169 | && docker-php-ext-install ${MC} pdo_pgsql 170 | fi 171 | 172 | if [[ -z "${EXTENSIONS##*,pgsql,*}" ]]; then 173 | echo "---------- Install pgsql ----------" 174 | apk --no-cache add postgresql-dev \ 175 | && docker-php-ext-install ${MC} pgsql 176 | fi 177 | 178 | if [[ -z "${EXTENSIONS##*,oci8,*}" ]]; then 179 | echo "---------- Install oci8 ----------" 180 | docker-php-ext-install ${MC} oci8 181 | fi 182 | 183 | if [[ -z "${EXTENSIONS##*,odbc,*}" ]]; then 184 | echo "---------- Install odbc ----------" 185 | docker-php-ext-install ${MC} odbc 186 | fi 187 | 188 | if [[ -z "${EXTENSIONS##*,dba,*}" ]]; then 189 | echo "---------- Install dba ----------" 190 | docker-php-ext-install ${MC} dba 191 | fi 192 | 193 | if [[ -z "${EXTENSIONS##*,interbase,*}" ]]; then 194 | echo "---------- Install interbase ----------" 195 | echo "Alpine linux do not support interbase/firebird!!!" 196 | #docker-php-ext-install ${MC} interbase 197 | fi 198 | 199 | if [[ -z "${EXTENSIONS##*,,*}" ]]; then 200 | echo "---------- Install hprose ----------" 201 | printf "\n" | pecl install hprose 202 | docker-php-ext-enable hprose 203 | fi 204 | 205 | if [[ -z "${EXTENSIONS##*,gd,*}" ]]; then 206 | echo "---------- Install gd ----------" 207 | isPhpVersionGreaterOrEqual 8 0 208 | 209 | if [[ "$?" = "1" ]]; then 210 | # "--with-xxx-dir" was removed from php 7.4, 211 | # issue: https://github.com/docker-library/php/issues/912 212 | options="--with-freetype --with-jpeg --with-webp" 213 | else 214 | options="--with-gd --with-freetype-dir=/usr/include/ --with-png-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include/" 215 | fi 216 | 217 | apk add --no-cache \ 218 | freetype \ 219 | freetype-dev \ 220 | libpng \ 221 | libpng-dev \ 222 | libjpeg-turbo \ 223 | libjpeg-turbo-dev \ 224 | libwebp-dev \ 225 | && docker-php-ext-configure gd ${options} \ 226 | && docker-php-ext-install ${MC} gd \ 227 | && apk del \ 228 | freetype-dev \ 229 | libpng-dev \ 230 | libjpeg-turbo-dev 231 | fi 232 | 233 | if [[ -z "${EXTENSIONS##*,yaml,*}" ]]; then 234 | echo "---------- Install yaml ----------" 235 | apk add --no-cache yaml-dev 236 | printf "\n" | pecl install yaml 237 | docker-php-ext-enable yaml 238 | fi 239 | 240 | if [[ -z "${EXTENSIONS##*,intl,*}" ]]; then 241 | echo "---------- Install intl ----------" 242 | apk add --no-cache icu-dev 243 | docker-php-ext-install ${MC} intl 244 | fi 245 | 246 | if [[ -z "${EXTENSIONS##*,bz2,*}" ]]; then 247 | echo "---------- Install bz2 ----------" 248 | apk add --no-cache bzip2-dev 249 | docker-php-ext-install ${MC} bz2 250 | fi 251 | 252 | if [[ -z "${EXTENSIONS##*,soap,*}" ]]; then 253 | echo "---------- Install soap ----------" 254 | apk add --no-cache libxml2-dev 255 | docker-php-ext-install ${MC} soap 256 | fi 257 | 258 | if [[ -z "${EXTENSIONS##*,xsl,*}" ]]; then 259 | echo "---------- Install xsl ----------" 260 | apk add --no-cache libxml2-dev libxslt-dev 261 | docker-php-ext-install ${MC} xsl 262 | fi 263 | 264 | if [[ -z "${EXTENSIONS##*,xmlrpc,*}" ]]; then 265 | echo "---------- Install xmlrpc ----------" 266 | apk add --no-cache libxml2-dev libxslt-dev 267 | docker-php-ext-install ${MC} xmlrpc 268 | fi 269 | 270 | if [[ -z "${EXTENSIONS##*,wddx,*}" ]]; then 271 | echo "---------- Install wddx ----------" 272 | apk add --no-cache libxml2-dev libxslt-dev 273 | docker-php-ext-install ${MC} wddx 274 | fi 275 | 276 | if [[ -z "${EXTENSIONS##*,curl,*}" ]]; then 277 | echo "---------- curl is installed ----------" 278 | fi 279 | 280 | if [[ -z "${EXTENSIONS##*,readline,*}" ]]; then 281 | echo "---------- Install readline ----------" 282 | apk add --no-cache readline-dev 283 | apk add --no-cache libedit-dev 284 | docker-php-ext-install ${MC} readline 285 | fi 286 | 287 | if [[ -z "${EXTENSIONS##*,snmp,*}" ]]; then 288 | echo "---------- Install snmp ----------" 289 | apk add --no-cache net-snmp-dev 290 | docker-php-ext-install ${MC} snmp 291 | fi 292 | 293 | if [[ -z "${EXTENSIONS##*,pspell,*}" ]]; then 294 | echo "---------- Install pspell ----------" 295 | apk add --no-cache aspell-dev 296 | apk add --no-cache aspell-en 297 | docker-php-ext-install ${MC} pspell 298 | fi 299 | 300 | if [[ -z "${EXTENSIONS##*,recode,*}" ]]; then 301 | echo "---------- Install recode ----------" 302 | apk add --no-cache recode-dev 303 | docker-php-ext-install ${MC} recode 304 | fi 305 | 306 | if [[ -z "${EXTENSIONS##*,tidy,*}" ]]; then 307 | echo "---------- Install tidy ----------" 308 | apk add --no-cache tidyhtml-dev 309 | 310 | # Fix: https://github.com/htacg/tidy-html5/issues/235 311 | ln -s /usr/include/tidybuffio.h /usr/include/buffio.h 312 | 313 | docker-php-ext-install ${MC} tidy 314 | fi 315 | 316 | if [[ -z "${EXTENSIONS##*,gmp,*}" ]]; then 317 | echo "---------- Install gmp ----------" 318 | apk add --no-cache gmp-dev 319 | docker-php-ext-install ${MC} gmp 320 | fi 321 | 322 | if [[ -z "${EXTENSIONS##*,imap,*}" ]]; then 323 | echo "---------- Install imap ----------" 324 | apk add --no-cache imap-dev 325 | docker-php-ext-configure imap --with-imap --with-imap-ssl 326 | docker-php-ext-install ${MC} imap 327 | fi 328 | 329 | if [[ -z "${EXTENSIONS##*,ldap,*}" ]]; then 330 | echo "---------- Install ldap ----------" 331 | apk add --no-cache ldb-dev 332 | apk add --no-cache openldap-dev 333 | docker-php-ext-install ${MC} ldap 334 | fi 335 | 336 | if [[ -z "${EXTENSIONS##*,psr,*}" ]]; then 337 | echo "---------- Install psr ----------" 338 | printf "\n" | pecl install psr 339 | docker-php-ext-enable psr 340 | fi 341 | 342 | if [[ -z "${EXTENSIONS##*,imagick,*}" ]]; then 343 | echo "---------- Install imagick ----------" 344 | apk add --no-cache file-dev 345 | apk add --no-cache imagemagick-dev 346 | printf "\n" | pecl install imagick-3.4.4 347 | docker-php-ext-enable imagick 348 | fi 349 | 350 | if [[ -z "${EXTENSIONS##*,rar,*}" ]]; then 351 | echo "---------- Install rar ----------" 352 | printf "\n" | pecl install rar 353 | docker-php-ext-enable rar 354 | fi 355 | 356 | if [[ -z "${EXTENSIONS##*,ast,*}" ]]; then 357 | echo "---------- Install ast ----------" 358 | printf "\n" | pecl install ast 359 | docker-php-ext-enable ast 360 | fi 361 | 362 | if [[ -z "${EXTENSIONS##*,msgpack,*}" ]]; then 363 | echo "---------- Install msgpack ----------" 364 | printf "\n" | pecl install msgpack 365 | docker-php-ext-enable msgpack 366 | fi 367 | 368 | if [[ -z "${EXTENSIONS##*,igbinary,*}" ]]; then 369 | echo "---------- Install igbinary ----------" 370 | printf "\n" | pecl install igbinary 371 | docker-php-ext-enable igbinary 372 | fi 373 | 374 | 375 | if [[ -z "${EXTENSIONS##*,ssh2,*}" ]]; then 376 | isPhpVersionGreaterOrEqual 8 0 377 | if [[ "$?" = "1" ]]; then 378 | echo "---------- Install ssh2 ----------" 379 | printf "\n" | apk add libssh2-dev 380 | pecl install ssh2-1.1.2 381 | docker-php-ext-enable ssh2 382 | else 383 | echo "ssh2 requires PHP >= 8.0.0, installed version is ${PHP_VERSION}" 384 | fi 385 | fi 386 | 387 | if [[ -z "${EXTENSIONS##*,protobuf,*}" ]]; then 388 | isPhpVersionGreaterOrEqual 8 0 389 | if [[ "$?" = "1" ]]; then 390 | echo "---------- Install protobuf ----------" 391 | printf "\n" | pecl install protobuf 392 | docker-php-ext-enable protobuf 393 | else 394 | echo "yar requires PHP >= 8.0.0, installed version is ${PHP_VERSION}" 395 | fi 396 | fi 397 | 398 | if [[ -z "${EXTENSIONS##*,yac,*}" ]]; then 399 | isPhpVersionGreaterOrEqual 8 0 400 | if [[ "$?" = "1" ]]; then 401 | echo "---------- Install yac ----------" 402 | printf "\n" | pecl install yac-2.0.2 403 | docker-php-ext-enable yac 404 | else 405 | echo "yar requires PHP >= 8.0.0, installed version is ${PHP_VERSION}" 406 | fi 407 | fi 408 | 409 | if [[ -z "${EXTENSIONS##*,yar,*}" ]]; then 410 | isPhpVersionGreaterOrEqual 8 0 411 | if [[ "$?" = "1" ]]; then 412 | echo "---------- Install yar ----------" 413 | printf "\n" | pecl install yar 414 | docker-php-ext-enable yar 415 | else 416 | echo "yar requires PHP >= 8.0.0, installed version is ${PHP_VERSION}" 417 | fi 418 | 419 | fi 420 | 421 | 422 | 423 | if [[ -z "${EXTENSIONS##*,yaconf,*}" ]]; then 424 | isPhpVersionGreaterOrEqual 8 0 425 | if [[ "$?" = "1" ]]; then 426 | echo "---------- Install yaconf ----------" 427 | printf "\n" | pecl install yaconf 428 | docker-php-ext-enable yaconf 429 | else 430 | echo "yar requires PHP >= 8.0.0, installed version is ${PHP_VERSION}" 431 | fi 432 | fi 433 | 434 | if [[ -z "${EXTENSIONS##*,seaslog,*}" ]]; then 435 | echo "---------- Install seaslog ----------" 436 | printf "\n" | pecl install seaslog 437 | docker-php-ext-enable seaslog 438 | fi 439 | 440 | if [[ -z "${EXTENSIONS##*,varnish,*}" ]]; then 441 | echo "---------- Install varnish ----------" 442 | apk add --no-cache varnish-dev 443 | printf "\n" | pecl install varnish 444 | docker-php-ext-enable varnish 445 | fi 446 | 447 | if [[ -z "${EXTENSIONS##*,pdo_sqlsrv,*}" ]]; then 448 | isPhpVersionGreaterOrEqual 8 0 449 | if [[ "$?" = "1" ]]; then 450 | echo "---------- Install pdo_sqlsrv ----------" 451 | apk add --no-cache unixodbc-dev 452 | printf "\n" | pecl install pdo_sqlsrv 453 | docker-php-ext-enable pdo_sqlsrv 454 | curl -o /tmp/msodbcsql17_amd64.apk https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.2.1-1_amd64.apk 455 | apk add --allow-untrusted /tmp/msodbcsql17_amd64.apk 456 | else 457 | echo "pdo_sqlsrv requires PHP >= 8.0.0, installed version is ${PHP_VERSION}" 458 | fi 459 | fi 460 | 461 | if [[ -z "${EXTENSIONS##*,sqlsrv,*}" ]]; then 462 | isPhpVersionGreaterOrEqual 8 0 463 | if [[ "$?" = "1" ]]; then 464 | echo "---------- Install sqlsrv ----------" 465 | apk add --no-cache unixodbc-dev 466 | printf "\n" | pecl install sqlsrv 467 | docker-php-ext-enable sqlsrv 468 | else 469 | echo "pdo_sqlsrv requires PHP >= 8.0.0, installed version is ${PHP_VERSION}" 470 | fi 471 | fi 472 | 473 | if [[ -z "${EXTENSIONS##*,mcrypt,*}" ]]; then 474 | isPhpVersionGreaterOrEqual 8 0 475 | if [[ "$?" = "1" ]]; then 476 | echo "---------- Install mcrypt ----------" 477 | apk add --no-cache libmcrypt-dev libmcrypt re2c 478 | printf "\n" |pecl install mcrypt 479 | docker-php-ext-enable mcrypt 480 | else 481 | echo "---------- Install mcrypt ----------" 482 | apk add --no-cache libmcrypt-dev \ 483 | && docker-php-ext-install ${MC} mcrypt 484 | fi 485 | fi 486 | 487 | if [[ -z "${EXTENSIONS##*,mysql,*}" ]]; then 488 | isPhpVersionGreaterOrEqual 8 0 489 | 490 | if [[ "$?" = "1" ]]; then 491 | echo "---------- mysql was REMOVED from PHP 8.0.0 ----------" 492 | else 493 | echo "---------- Install mysql ----------" 494 | docker-php-ext-install ${MC} mysql 495 | fi 496 | fi 497 | 498 | if [[ -z "${EXTENSIONS##*,sodium,*}" ]]; then 499 | isPhpVersionGreaterOrEqual 8 0 500 | if [[ "$?" = "1" ]]; then 501 | echo 502 | echo "Sodium is bundled with PHP from PHP 8.0.0" 503 | echo 504 | else 505 | echo "---------- Install sodium ----------" 506 | apk add --no-cache libsodium-dev 507 | docker-php-ext-install ${MC} sodium 508 | fi 509 | fi 510 | 511 | if [[ -z "${EXTENSIONS##*,amqp,*}" ]]; then 512 | echo "---------- Install amqp ----------" 513 | apk add --no-cache rabbitmq-c-dev 514 | docker-php-ext-enable amqp 515 | fi 516 | 517 | if [[ -z "${EXTENSIONS##*,redis,*}" ]]; then 518 | echo "---------- Install redis ----------" 519 | # pecl install redis 520 | # docker-php-ext-enable redis 521 | installExtensionFromTgz redis-5.3.5 522 | fi 523 | 524 | if [[ -z "${EXTENSIONS##*,phpy,*}" ]]; then 525 | echo "---------- Install phpy Start----------" 526 | pecl install phpy --yes 527 | docker-php-ext-enable phpy 528 | fi 529 | 530 | if [[ -z "${EXTENSIONS##*,apcu,*}" ]]; then 531 | echo "---------- Install apcu ----------" 532 | pecl install apcu 533 | docker-php-ext-enable apcu 534 | fi 535 | 536 | if [[ -z "${EXTENSIONS##*,memcached,*}" ]]; then 537 | echo "---------- Install memcached ----------" 538 | apk add --no-cache libmemcached-dev zlib-dev 539 | pecl install memcached 540 | docker-php-ext-enable memcached 541 | fi 542 | 543 | if [[ -z "${EXTENSIONS##*,memcache,*}" ]]; then 544 | echo "---------- Install memcache ----------" 545 | pecl install memcache 546 | docker-php-ext-enable memcache 547 | fi 548 | 549 | if [[ -z "${EXTENSIONS##*,xdebug,*}" ]]; then 550 | echo "---------- Install xdebug ----------" 551 | pecl install xdebug 552 | docker-php-ext-enable xdebug 553 | fi 554 | 555 | if [[ -z "${EXTENSIONS##*,event,*}" ]]; then 556 | echo "---------- Install event ----------" 557 | apk add --no-cache libevent-dev 558 | export is_sockets_installed=$(php -r "echo extension_loaded('sockets');") 559 | 560 | if [[ "${is_sockets_installed}" = "" ]]; then 561 | echo "---------- event is depend on sockets, install sockets first ----------" 562 | docker-php-ext-install sockets 563 | fi 564 | 565 | echo "---------- Install event again ----------" 566 | installExtensionFromTgz event-3.0.6 "--ini-name event.ini" 567 | fi 568 | 569 | if [[ -z "${EXTENSIONS##*,mongodb,*}" ]]; then 570 | echo "---------- Install mongodb ----------" 571 | pecl install mongodb 572 | docker-php-ext-enable mongodb 573 | fi 574 | 575 | if [[ -z "${EXTENSIONS##*,yaf,*}" ]]; then 576 | echo "---------- Install yaf ----------" 577 | pecl install yaf 578 | docker-php-ext-enable yaf 579 | fi 580 | 581 | 582 | if [[ -z "${EXTENSIONS##*,swoole,*}" ]]; then 583 | echo "---------- Install swoole ----------" 584 | pecl install swoole 585 | docker-php-ext-enable swoole 586 | fi 587 | 588 | if [[ -z "${EXTENSIONS##*,zip,*}" ]]; then 589 | echo "---------- Install zip ----------" 590 | # Fix: https://github.com/docker-library/php/issues/797 591 | apk add --no-cache libzip-dev 592 | 593 | isPhpVersionGreaterOrEqual 8 0 594 | if [[ "$?" != "1" ]]; then 595 | docker-php-ext-configure zip --with-libzip=/usr/include 596 | fi 597 | 598 | docker-php-ext-install ${MC} zip 599 | fi 600 | 601 | if [[ -z "${EXTENSIONS##*,xhprof,*}" ]]; then 602 | echo "---------- Install XHProf ----------" 603 | pecl install xhprof 604 | docker-php-ext-enable xhprof 605 | 606 | fi 607 | 608 | if [[ -z "${EXTENSIONS##*,xlswriter,*}" ]]; then 609 | echo "---------- Install xlswriter ----------" 610 | isPhpVersionGreaterOrEqual 8 0 611 | 612 | if [[ "$?" = "1" ]]; then 613 | printf "\n" | pecl install xlswriter 614 | docker-php-ext-enable xlswriter 615 | else 616 | echo "---------- PHP Version>= 8.0----------" 617 | fi 618 | fi 619 | 620 | if [[ -z "${EXTENSIONS##*,rdkafka,*}" ]]; then 621 | echo "---------- Install rdkafka ----------" 622 | isPhpVersionGreaterOrEqual 8 0 623 | 624 | if [[ "$?" = "1" ]]; then 625 | apk add librdkafka-dev 626 | printf "\n" | pecl install rdkafka 627 | docker-php-ext-enable rdkafka 628 | else 629 | echo "---------- PHP Version>= 8.0----------" 630 | fi 631 | fi 632 | 633 | if [[ -z "${EXTENSIONS##*,zookeeper,*}" ]]; then 634 | echo "---------- Install zookeeper ----------" 635 | isPhpVersionGreaterOrEqual 8 0 636 | 637 | if [[ "$?" = "1" ]]; then 638 | apk add re2c 639 | apk add libzookeeper-dev --repository http://${CONTAINER_PACKAGE_URL}/alpine/edge/testing/ 640 | printf "\n" | pecl install zookeeper 641 | docker-php-ext-enable zookeeper 642 | else 643 | echo "---------- PHP Version>= 8.0----------" 644 | fi 645 | fi 646 | 647 | if [[ -z "${EXTENSIONS##*,phalcon,*}" ]]; then 648 | echo "---------- Install phalcon ----------" 649 | isPhpVersionGreaterOrEqual 8 0 650 | 651 | if [[ "$?" = "1" ]]; then 652 | printf "\n" | pecl install phalcon 653 | docker-php-ext-enable psr 654 | docker-php-ext-enable phalcon 655 | else 656 | echo "---------- PHP Version>= 8.0----------" 657 | fi 658 | fi 659 | 660 | if [[ -z "${EXTENSIONS##*,sdebug,*}" ]]; then 661 | echo "---------- Install sdebug ----------" 662 | isPhpVersionGreaterOrEqual 8 0 663 | 664 | if [[ "$?" = "1" ]]; then 665 | curl -SL "https://github.com/swoole/sdebug/archive/sdebug_2_9-beta.tar.gz" -o sdebug.tar.gz \ 666 | && mkdir -p sdebug \ 667 | && tar -xf sdebug.tar.gz -C sdebug --strip-components=1 \ 668 | && rm sdebug.tar.gz \ 669 | && ( \ 670 | cd sdebug \ 671 | && phpize \ 672 | && ./configure --enable-xdebug \ 673 | && make clean && make && make install \ 674 | ) \ 675 | && docker-php-ext-enable xdebug 676 | else 677 | echo "---------- PHP Version>= 8.0----------" 678 | fi 679 | fi 680 | 681 | if [ "${PHP_EXTENSIONS}" != "" ]; then 682 | apk del .build-deps \ 683 | && docker-php-source delete 684 | fi -------------------------------------------------------------------------------- /services/php8/extensions/redis-5.3.5.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tinywan/dnmp/4bbed9b1ec28625c436f33880ca43861c7256f6f/services/php8/extensions/redis-5.3.5.tgz -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | :<connect('dnmp-redis', 63789); 11 | var_dump($redis->keys("*")); 12 | var_dump($redis->get("Name")); 13 | } catch (\Exception $e) { 14 | var_dump($e->getMessage()); 15 | } 16 | } 17 | 18 | 19 | // 测试MySQL 20 | function testMySQL() 21 | { 22 | $servername = "dnmp-mysql"; 23 | $username = "root"; 24 | $password = "123456"; 25 | $dbname = "mysql"; 26 | $conn = mysqli_connect($servername, $username, $password, $dbname); 27 | if (!$conn) { 28 | die("连接失败: " . mysqli_connect_error()); 29 | } 30 | 31 | $sql = "SELECT Host,User FROM user"; 32 | $result = mysqli_query($conn, $sql); 33 | 34 | if (mysqli_num_rows($result) > 0) { 35 | while ($row = mysqli_fetch_assoc($result)) { 36 | echo "Host: " . $row["Host"] . " - User: " . $row["User"] . "
"; 37 | } 38 | } else { 39 | echo "0 结果"; 40 | } 41 | mysqli_close($conn); 42 | } 43 | 44 | // testRedis(); 45 | // testMySQL(); 46 | 47 | --------------------------------------------------------------------------------