1 Star 0 Fork 123

janmmey / dnmp

forked from 开源技术小栈 / dnmp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MulanPSL-1.0

images

996.icu

快速下载

:book: 目录

Docker简介

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。

为什么使用Docker

  • 加速本地的开发和构建流程,容器可以在开发环境构建,然后轻松地提交到测试环境,并最终进入生产环境
  • 能够在让独立的服务或应用程序在不同的环境中得到相同的运行结果
  • 创建隔离的环境来进行测试
  • 高性能、超大规划的宿主机部署
  • 从头编译或者扩展现有的 OpenShift 或 Cloud Foundry 平台来搭建自己的 PaaS 环境

项目结构

dnmp
└── dnmp
    ├── docker-compose.yml      -- 基础配置文件
    ├── env.sample              -- 环境配置文件,拷贝 env.sample 为 .env
    ├── Dockerfile              -- PHP镜像构建文件
    ├── extensions              -- PHP扩展源码包
    ├── conf
    │   ├── nginx.conf          -- Nginx 主配置文件
    │   ├── conf.d
    │   │   └── 80.conf         -- 虚拟主机配置文件
    │   ├── letsencrypt         -- Nginx 证书目录
    │   ├── mysql
    │   │   └── my.cnf          -- MySQL 配置文件
    │   ├── redis
    │   │   └── redis.conf      -- Redis 配置文件
    │   ├── php
    │   │   ├── php.ini         -- PHP 运行核心配置文件
    │   │   ├── php-fpm.conf    -- PHP-FPM 进程服务的配置文件
    │   │   └── php-fpm.d
    │   │        └── www.conf   -- PHP-FPM 扩展配置文件
    │   └──lua                  -- Lua 脚本目录(仅Openresty有效)
    │        └── bin
    │             └── imit.lua  -- Lua 限流脚本(仅Openresty有效)
    ├── data                    -- 数据目录
    │   ├── redis
    │   │   ├── appendonly.aof  -- AOF 数据库保存文件
    │   │   ├── dump.rdb        -- RDB 数据库保存文件
    │   │   └── redis.log       -- Redis 日志文件
    │   └── mysql               -- MySQL 数据目录
    ├── log
    ├   ├── nginx               -- Nginx 系统错误日志
    │   │   ├── access.log
    │   │   └── error.log
    │   └──redis                -- Redis错误日志
    │   └──php                  -- PHP错误日志
    └── www                     -- 项目代码目录
        └── site                -- 具体项目目录
           └──index.php

环境要求

使用说明(很重要)

Web 服务包含两个(只能选择运行一个)

  • Nginx 官方镜像
  • Openresty 官方镜像

PHP 服务包含三个(多个同时构建运行)

  • PHP56 官方ph5.6镜像扩展构建
  • PHP72 官方ph7.2.19镜像扩展构建
  • PHP7 该版本已经是构建好的镜像(php7.2),支持 PHP-FPM、PHP-CLI、Crontab、Composer 等

快速使用

Linux and MacOS

最新下载

$ git clone https://gitee.com/Tinywan/dnmp.git
$ cd dnmp

Create docker-compose environment file

$ cd dnmp // 进入正式目录而不是开发目录dev
$ cp env.sample .env

修改配置文件

$ vim .env

开启所有容器

$ docker-compose up

守护进程 docker-compose up -d

重新构建 PHP 镜像

$ docker-compose build          # 重建全部服务
$ docker-compose build php72    # 重建单个服务

Windows 同上

Nginx管理

  • 配置文件端口必须和 docker-compose.ymlports - 8088:80中的映射出来的端口一一对应

    列如:conf/conf.d/www.conf中配置端口为 80,则映射端口也80,对应的映射端口为:8088:80

  • 重新加载配置文件 docker exec -it dnmp-nginx nginx -s reload

    或者 docker exec dnmp-nginx nginx -s reload

  • 在容器内执行 shell 命令:docker exec -it dnmp-nginx sh -c "ps -aef | grep nginx | grep -v grep | grep master |awk '{print $2}'"

  • Nginx 日志定时备份和删除

  • 容器时间跟宿主机时间不一致

    • 原因:宿主机采用了 CST 时区。容器采用了 UTC 时区。
    • 复制主机的localtimedocker cp /etc/localtime lnmp-nginx:/etc/
    • 重启容器:docker restart lnmp-nginx

MySQL管理

  • 进入容器:docker exec -it dnmp-mysql /bin/bash

    Windows 环境使用:docker exec -it dnmp-mysql bash

  • 修改配置文件 my.cnf,重新加载:docker-compose restart mysql

  • 容器内连接:mysql -uroot -p123456

  • 外部宿主机连接:mysql -h 127.0.0.1 -P 3308 -uroot -p123456

  • 数据-备份-恢复

    • 导出(备份)
      • 导出数据库中的所有表结构和数据:docker exec -it dnmp-mysql mysqldump -uroot -p123456 test > test.sql
      • 只导结构不导数据:docker exec -it dnmp-mysql mysqldump --opt -d -uroot -p123456 test > test.sql
      • 只导数据不导结构:docker exec -it dnmp-mysql mysqldump -t -uroot -p123456 test > test.sql
      • 导出特定表的结构:docker exec -it dnmp-mysql mysqldump -t -uroot -p123456 --table user > user.sql
    • 导入(恢复)docker exec -i dnmp-mysql -uroot -p123456 test < /home/www/test.sql

      如果导入不成功,检查 sql 文件头部:mysqldump: [Warning] Using a password on the command line interface can be insecure.是否存在该内容,有则删除即可

  • MySQL 备份小脚本

    Crontab 任务:55 23 * * * bash /backup/mysql_auto_backup.sh >/dev/null 2>&1
    注意:crontab 定时执行 Docker 任务的时候是不需要添加参数 -it-t是分配一个伪终端,但是 crontab 执行的时候实际是不需要的。

  • 项目配置文件建议:

    • root 默认不开开启远程访问
    • 新建项目用户 www,配置主机Host字段值为 MySQL 容器 ip 段172.18.0.%
    • 查看容器 IP address:docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dnmp-mysql

PHP管理

  • 进入 php 容器 docker exec -it dnmp-php /bin/bash

    如果提示:bash: export: [/bin/bash,': not a valid identifier。删除配置文件vim ~/.bashrc末尾部分:[/bin/bash, -c, source ~/.bashrc]

  • 重启 php 服务 docker-compose restart php

    修改核心配置文件 php.ini,可使用该命令重新加载配置文件。
    修改扩展配置文件 www.conf,可使用该命令重新加载配置文件。

  • 服务管理

    • 配置测试:docker exec -it dnmp-php bash -c "/usr/local/php/sbin/php-fpm -t"
    • 启动:docker exec -it dnmp-php bash -c "/usr/local/php/sbin/php-fpm"
    • 关闭:docker exec -it dnmp-php bash -c "kill -INT 1"
    • 重启:docker exec -it dnmp-php bash -c "kill -USR2 1"
    • 查看 php-fpm 进程数:docker exec -it dnmp-php bash -c "ps aux | grep -c php-fpm"
    • 查看 PHP 版本:docker exec -it dnmp-php bash -c "/usr/local/php/bin/php -v"
  • 编译安装扩展

    • 1、下载:cd /opt && git clone https://github.com/php/pecl-encryption-mcrypt.git
    • 2、生成配置文件:/usr/local/php/bin/phpize --with-php-config=/usr/local/php/bin/php-config
    • 3、检测配置文件:./configure --with-php-config=/usr/local/php/bin/php-config
    • 4、编译:make -j2
    • 5、安装:make install
    • 6、修改php.ini配置文件:vim /usr/local/php/etc/php.ini
    • 7、重启php-fpmkill -USR2 1
  • 服务器开机自动启 PHP 容器,Ubuntu 18.04 rc.local systemd 设置

    #!/bin/sh -e
    
    # docker-compose php container
    /usr/local/bin/docker-compose -f /home/www/dnmp/docker-compose.yml up -d
    
    # docker tab cron start
    sleep 10; docker exec lnmp-php bash -c "/etc/init.d/cron start"
    
    exit 0

    编辑文件vim /etc/rc.local,添加以上内容 以上主要是解决服务器重启后,PHP 容器不能够重启以及 PHP 容器之内的 Crontab 服务不能够启动的的问题,目前没有其他解决方案

Redis管理

  • 连接 Redis 容器:docker exec -it dnmp-redis redis-cli -h 127.0.0.1 -p 63789
  • 通过容器连接:docker exec -it dnmp-redis redis-cli -h dnmp-redis -p 63789
  • 单独重启 redis 服务 docker-compose up --no-deps -d redis
  • 外部宿主机连接:redis-cli -h 127.0.0.1 -p 63789

Composer管理

使用Docker安装

Linux环境

进入项目目录,执行以下命令安装

docker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) composer install --ignore-platform-reqs

--ignore-platform-reqs 参数表示官方 docker composer 库没有包含当前 PHP 版本

Windows环境

安装一个新的 composer 包

E:\dnmp> docker run --rm --interactive --tty -v e:/dnmp/www/thinkphp_3.2:/app  composer require tinywan/load-balancing --ignore-platform-reqs

tinywan/load-balancing 为需要安装的包名

执行执行项目的绝对路径

E:\dnmp> docker run --rm --interactive --tty -v e:/dnmp/www/tp6:/app  composer install --ignore-platform-reqs

tp6 为项目目录

容器内

  • 需要进入dnmp-php容器: docker exec -it dnmp-php /bin/bash

  • 查看 composer版本:composer --version

  • 修改 composer 的全局配置文件(推荐方式)

    composer config -g repo.packagist composer https://packagist.phpcomposer.com
    // 或者
    composer config -g repo.packagist composer https://packagist.laravel-china.org

    如果你是墙内客户,务必添加以上国内镜像。否则会出现file could not be downloaded (HTTP/1.1 404 Not Found)

  • 更新框架或者扩展

    /var/www/tp5.1# apt update
    /var/www/tp5.1# apt install sudo
    /var/www/tp5.1# sudo -u www-data sh -c "/usr/local/php/bin/php /usr/local/bin/composer install"

    请使用www-data 更新安装包,而不是默认直接使用root账户, 尽量使用composer install 更新安装包,而不是composer update

宿主机

建议在主机 HOST 中使用 composer,避免 PHP 容器变得庞大,Docker Official Images

宿主机直接使用命令:docker exec dnmp-php bash -c "cd /var/www/p2p_wallet; /usr/local/php/bin/php /usr/local/sbin/composer update"

  • 1、在主机创建一个目录,用以保存 composer 的配置和缓存文件

    mkdir ~/dnmp/composer
  • 2、打开主机的 ~/.bashrc 或者 ~/.zshrc 文件,加上

    composer () {
        tty=
        tty -s && tty=--tty
        docker run \
            $tty \
            --interactive \
            --rm \
            --user $(id -u):$(id -g) \
            --volume ~/dnmp/composer:/tmp \
            --volume /etc/passwd:/etc/passwd:ro \
            --volume /etc/group:/etc/group:ro \
            --volume $(pwd):/app \
            composer "$@"
    }
  • 3、让文件起效

    source ~/.bashrc
  • 4、在主机的任何目录下就能用composer

    cd ~/dnmp/www/
    composer create-project topthink/think tp5.2
    composer update topthink/framework

    第一次执行提示:Unable to find image 'composer:latest' locally,不要慌,稍等片刻

Crontab管理

执行方案

  • 1、使用主机的 cron 实现定时任务(推荐)
  • 2、创建一个新容器专门执行定时任务,crontab for docker
  • 3、在原有容器上安装 cron,里面运行 2 个进程

宿主机执行任务(推荐)

# 2019年2月14日 @add Tinywan 获取图表数据 每3分钟执行一次
*/30 * * * * docker exec dnmp-php echo " Hi Lnmp " >> /var/www/crontab.log

dnmp-php 为容器名称

容器内执行任务

  • 需要进入dnmp-php容器: docker exec -it dnmp-php /bin/bash
  • 手动启动 crontab,/etc/init.d/cron start
  • 添加 Crontab 任务 crontab -e
  • 添加任务输出日志到映射目录:* * * * * echo " Hi dnmp " >> /var/www/crontab.log
  • 定时执行 ThinkPHP5 自带命令行命令:*/30 * * * * /usr/local/php/bin/php /var/www/tp5.1/think jobs hello

WebSocket管理

在项目中难免会用到 workerman

  • 进入dnmp-php容器:docker exec -it dnmp-php /bin/bash

  • 以 daemon(守护进程)方式启动 workerman :php ../workerman/start.php start -d

  • 宿主机平滑重启 workerman :docker exec -it dnmp-php bash -c "/usr/local/php/bin/php /var/www/site/think worker:gateway reload"

  • 配置docker-compose.yml 文件中对应的映射端口

    php:
        ports:
            - "9000:9000"
            - "9502:9502" # workerman 映射端口
            - "1239:1239" # Gateway 客户端
  • 防火墙问题,如果使用阿里云 ESC,请在安全组增加入方向出方向端口配置

    协议类型:自定义 TCP
    端口范围:9502/9502
    授权对象:0.0.0.0/0
  • 宿主机可以查看对应端口号是否已经映射成功

    ps -aux|grep 9502
    WorkerMan: worker process  AppGateway websocket://0.0.0.0:9502
  • 通过telnet命令检测远程端口是否打开

    telnet 127.0.0.1 9502
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.

    出现Connected表示连通了

  • 通过 Console 测试是否支持外网访问

    var ws = new WebSocket('ws://宿主机公网ip:9502/');
    ws.onmessage = function(event) {
        console.log('MESSAGE: ' + event.data);
    };
    ƒ (event) {
        console.log('MESSAGE: ' + event.data);
    }
    MESSAGE: {"type":"docker","text":"Hi Tinywan"}

phpMyAdmin管理

主机上访问 phpMyAdmin 的地址:http://localhost:8082或者http://宿主机Ip地址:8082

默认登录账户:root,密码:123456

容器管理

images

  • 进入 Docker 容器

    • Linux 环境 $ docker exec -it dnmp-php bash
    • Windows 环境 $ winpty docker exec -it dnmp-php bash
  • 关闭容器并删除服务docker-compose down

  • 单独重启 redis 服务 docker-compose up --no-deps -d redis

    如果用户只想重新部署某个服务,可以使用 docker-compose up --no-deps -d <SERVICE_NAME> 来重新创建服务并后台停止旧服务,启动新服务,并不会影响到其所依赖的服务。

  • 单独加载配置文件,列如修改了 nginx 配置文件www.conf中的内容,如何即使生效,请使用以下命令重启容器内的 Nginx 配置文件生效:

    docker exec -it lnmp-nginx nginx -s reload

    lnmp-nginx为容器名称(NAMES),也可以指定容器的 ID 。nginx为服务名称(docker-compose.yml

  • 修改docker-compose.yml文件之后,如何使修改的docker-compose.yml生效?

    docker-compose up --no-deps -d  nginx

    以上表示只是修改了docker-compose.yml中关于 Nginx 相关服务器的配置

  • 容器资源使用情况

    • 所有运行中的容器资源使用情况:docker stats
    • 查看多个容器资源使用:docker stats dnmp-nginx dnmp-php dnmp-mysql dnmp-redis
    • 自定义格式的 docker 统计信息:docker stats --all --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" dnmp-nginx dnmp-php
  • docker-compose 常用命令

    • 启动docker-compose.yml定义的所有服务:docker-compose up

    • 重启docker-compose.yml中定义的所有服务:docker-compose restart

    • 停止docker-compose.yml中定义的所有服务(当前目录配置):docker-compose stop

    • 停止现有 docker-compose 中的容器:docker-compose down(重要)

      如果你修改了docker-compose.yml文件中的内容,请使用该命令,否则配置文件不会生效

      例如:Nginx 或者 MySQL 配置文件的端口

    • 重新拉取镜像:docker-compose pull

    • 后台启动 docker-compose 中的容器:docker-compose up -d

  • 查看容器详细信息

    • 获取实例的 IP 地址:docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
    • 获取实例的 MAC 地址:docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
    • 获取实例的日志路径:docker inspect --format='{{.LogPath}}' $INSTANCE_ID
    • 获取实例的镜像名称:docker inspect --format='{{.Config.Image}}' $INSTANCE_ID

证书管理

本地生成 HTTPS

生成本地 HTTPS 加密证书的工具 mkcert,一个命令就可以生成证书,不需要任何配置。

  • 本地本地C:\Windows\System32\drivers\etc\hosts文件,添加以下内容

    127.0.0.1	dnmp.com
    127.0.0.1	www.dnmp.org
    127.0.0.1	www.dnmp.cn
  • 一键生成证书。进入证书存放目录:$ cd etc/letsencrypt/

    • 首次运行时,先生成并安装根证书

      $ mkcert --install
      Using the local CA at "C:\Users\tinywan\AppData\Local\mkcert" ✨
    • 自定义证书签名

      $ mkcert dnmp.com "*.dnmp.org" "*.dnmp.cn" localhost 127.0.0.1
      Using the local CA at "C:\Users\tinywan\AppData\Local\mkcert" ✨
      
      Created a new certificate valid for the following names 📜
      - "dnmp.com"
      - "*.dnmp.org"
      - "*.dnmp.cn"
      - "localhost"
      - "127.0.0.1"
      
      Reminder: X.509 wildcards only go one level deep, so this won't match a.b.dnmp.org ℹ️
      
      The certificate is at "./dnmp.com+4.pem" and the key at "./dnmp.com+4-key.pem" ✅
  • 已经生成的证书

    $ ls etc/letsencrypt/
    dnmp.com+4.pem  dnmp.com+4-key.pem
  • 配置 Nginx 虚拟主机配置文件

    server {
        listen 443 ssl http2;
        server_name www.dnmp.cn;
    
        ssl_certificate /etc/letsencrypt/dnmp.com+4.pem;
        ssl_certificate_key /etc/letsencrypt/dnmp.com+4-key.pem;
        ...
    }
  • 浏览器访问效果

    images

Docker 生成 HTTPS

$ docker run --rm  -it -v "D:\Git\docker-lnmp\dev\nginx\v5\etc\letsencrypt":/acme.sh \
-e Ali_Key="LTAIn" -e Ali_Secret="zLzA" neilpang/acme.sh --issue --dns dns_ali \
-d tinywan.top -d *.tinywan.top -d *.frps.tinywan.top

保存目录

  • Linux 环境 : /home/www/openssl
  • Windows 环境 : D:\Git\docker-lnmp\dev\nginx\v5\etc\letsencrypt

参数详解(阿里云后台获取的密钥)

  • Ali_Key 阿里云 AccessKey ID
  • Ali_Secret 阿里云 Access Key Secret

Openresty专题

这里默认镜像标签为:bionic

  • 注意:如果你使用alpine and stretch 镜像标签,请单独安装opm,按照下面步骤安装既可

    • Usage:cd dnmp/dev/openresty/v1 && docker-compose.exe up

    • Installation OPM docker exec -it dnmp-openresty apk add --no-cache curl perl

      Windows winpty docker exec -it dnmp-openresty apk add --no-cache curl perl

  • 通过 opm install extend

    search redis package docker exec -it dnmp-openresty opm search redis

    install redis package docker exec -it dnmp-openresty opm get openresty/lua-resty-redis

    install to specification directory /usr/local/openresty/lualib/resty

    docker exec -it dnmp-openresty sh -c "opm --install-dir=/usr/local/openresty get ledgetech/lua-resty-http"
  • 配置文件

    测试配置是否正确 docker exec -it dnmp-openresty nginx -t

    重新加载配置文件 docker exec -it dnmp-openresty nginx -s reload

    获取 Redis 容器的 IP 地址 docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dnmp-redis-v2

    Nginx 日志时间时间不一致

    • 复制主机的 localtime docker cp etc/localtime dnmp-openresty:/etc/
    • 重启容器 docker-compose restart openresty

扩展apisix 微服务 API 网关

安装前的依赖

apt install sudo

sudo apt install wget

sudo apt install vim

sudo apt install vim

vim /etc/apt/sources.list # 请使用163 的源,比阿里云的靠谱点 `http://mirrors.163.com/ubuntu/ bionic`

sudo apt update

# add openresty source
wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main"
sudo apt-get update

# install openresty, etcd and some compilation tools
sudo apt-get install -y git etcd curl luarocks\
    check libpcre3 libpcre3-dev libjemalloc-dev \
    libjemalloc1 build-essential libtool automake autoconf pkg-config cmake

# start etcd server
sudo service etcd start

安装 APISIX

sudo luarocks install apisix

如果一切顺利,你会在最后看到这样的信息:

apisix is now built and installed in /usr (license: Apache License 2.0)

恭喜你,APISIX 已经安装成功了。

etcd 一个高可用的分布式键值(key-value)数据库

1、安装 sudo apt-get install etcd

2、开启服务 sudo service etcd start

3、etcdctl 命令进行测试

(1)设置和获取键值 testkey: "hello Tinywan",检查 etcd 服务是否启动成功

(2)命令行执行

# etcdctl set testkey "hello Tinywan"  # 设置
hello Tinywan

# etcdctl get testkey # 获取
hello Tinywan

# etcdctl rm testkey # 删除
PrevNode.Value: hello Tinywan

#etcdctl get testkey1 # 重新获取
Error:  100: Key not found (/testkey1) [13]

# # etcdctl set testkey "hello Tinywan" --ttl 10 # 设置一个过期时间

说明 etcd 服务已经成功启动了

4、通过 HTTP 访问本地 2379 或 4001 端口的方式来进行操作,例如查看 testkey 的值

# curl -L http://localhost:2379/v2/keys/testkey
{"action":"get","node":{"key":"/testkey","value":"hello Tinywan","modifiedIndex":12,"createdIndex":12}}

5、member 通过 list、add、remove 命令列出、添加、删除 etcd 实例到 etcd 集群中。 启动一个 etcd 服务实例后,可以用如下命令进行查看

# etcdctl member list
8e9e05c52164694d: name=8c831881add4 peerURLs=http://localhost:2380 clientURLs=http://localhost:2379 isLeader=true

XDebug管理

  • 镜像:docker pull registry.cn-beijing.aliyuncs.com/tinywan/dnmp:php5.6-v2

  • 配置文件映射路径:

    volumes:
        - ./www:/var/www
        - ./etc/php.ini:/usr/local/etc/php/php.ini:ro
        - ./etc/php-fpm.d/www.conf:/usr/local/etc/php-fpm.d/www.conf:rw
        - ./log:/var/log/php
  • Google 浏览器安装 Xdebug 插件:xdebug-helper

  • PHPStrom 默认配置就可以,打断点开始调试,默认不需要添加参数

  • Postman 断点调试(API接口),直接在后面增加?XDEBUG_SESSION_START=PHPSTORM参数,即:http://www.tinywan.top:8007?XDEBUG_SESSION_START=PHPSTORM

遇到的问题

  • 连接 Redis 报错:Connection refused,其他客户端可以正常连接

    容器之间相互隔绝,在进行了端口映射之后,宿主机可以通过 127.0.0.1:6379 访问 redis,但 php 容器不行。在 php 中可以直接使用hostname: lnmp-redis 来连接 redis 容器。原贴地址

  • Windows 10 启动错误 Error starting userland proxy: Bind for 127.0.0.1:3306: unexpected error Permission denied

    检查本地是否有 MySQL 已经启动或者端口被占用。关闭即可

  • Linux 环境启动的时候,MySQL 总是Restartinglnmp-mysql docker-entrypoint.sh --def ... Restarting

    解决办法:cd etc/mysql,查看文件权限。最暴力的:rm -r data && mkdir data解决问题

  • 权限问题

    • 遇到mkdir(): Permission denied问题,解决办法:sudo chmod -R 777 runtime
    • ThinkPHP5,ErrorException in File.php line 29 mkdir(): Permission denied 无法权限被拒绝
      • 执行命令:chmod -R 777 runtime
      • 如果图片上传也有问题:chmod -R 777 upload
  • docker-compose.yml文件格式错误

    ERROR: yaml.scanner.ScannerError: while scanning for the next token
    found character '\t' that cannot start any token
    in "./docker-compose.yml", line 68, column 1

    这里的原因是docker-compose.yml中最前面用了tab,改成空格就好了。对 yaml 文件格式要求严格

  • PHP 容器更新源或者使用 Composer 出现以下错误,请重启 Docekr(Windows 10 环境很容易出现这个问题)

    # apt-get update
    Err:1 http://mirrors.163.com/ubuntu bionic InRelease
    Temporary failure resolving 'mirrors.163.com'
  • Windows10 环境自动构建遇到的问题:ERROR: http://mirrors.aliyun.com/..: temporary error (try again later)

    解决办法:重启 Docker 服务

参考

images

mycli 工具安装使用

1、安装vim apt-get install vim

2、更新源vim sources.list

(1)中科大源:sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list (2)直接编辑 /etc/apt/sources.list 文件

deb http://mirrors.163.com/debian/  stretch main non-free contrib
deb http://mirrors.163.com/debian/  stretch-updates main non-free contrib
deb http://mirrors.163.com/debian/  stretch-backports main non-free contrib
deb-src http://mirrors.163.com/debian/  stretch main non-free contrib
deb-src http://mirrors.163.com/debian/  stretch-updates main non-free contrib
deb-src http://mirrors.163.com/debian/  stretch-backports main non-free contrib
deb http://mirrors.163.com/debian-security/  stretch/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/  stretch/updates main non-free contrib

degian9 的163源

3、更新163源:apt update

4、安装mycli:apt-get install mycli

5、设置默认语言格式: export LANG=C.UTF-8

6、演示如下所示

images

7、直接通过外部连接docker exec -it dnmp-mysql sh -c "export LANG=C.UTF-8 && mycli -h 127.0.0.1 -p123456"

OR 编译参数

./configure  \
 --prefix=/usr/local/openresty   \
 --with-luajit  \
 --with-stream  \
 --with-stream_ssl_module \
 --with-stream=dynamic  \
 --with-file-aio  \
 --with-threads  \
 --with-cc-opt="-O3"  \
 --with-http_v2_module  \
 --with-http_realip_module  \
 --with-http_mp4_module  \
 --with-http_gzip_static_module  \
 --with-http_ssl_module \
 --with-http_stub_status_module  \
 --with-http_xslt_module \
 --with-http_iconv_module   \
 --without-http_redis2_module \
 --with-openssl-opt=enable-tlsext \
 --add-dynamic-module=/home/www/build/nginx-rtmp-module/ \
 --add-dynamic-module=/home/www/build/nginx-ts-module/ \
 --add-dynamic-module=/www/home/build/nginx-vod-module/  \
 --add-dynamic-module=/www/home/build/nginx-module-vts/

编译安装

make
sudo make install

# 安装好后进入 apisix 项目
make run
make stop
木兰宽松许可证, 第1版 木兰宽松许可证, 第1版 2019年8月 http://license.coscl.org.cn/MulanPSL 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第1版(“本许可证”)的如下条款的约束: 0. 定义 “软件”是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。 “贡献者”是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。 “法人实体”是指提交贡献的机构及其“关联实体”。 “关联实体”是指,对“本许可证”下的一方而言,控制、受控制或与其共同受控制的机构,此处的控制是指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。 “贡献”是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。 1. 授予版权许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可以复制、使用、修改、分发其“贡献”,不论修改与否。 2. 授予专利许可 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软件”结合而将必然会侵犯的专利权利要求,不包括仅因您或他人修改“贡献”或其他结合而将必然会侵犯到的专利权利要求。如您或您的“关联实体”直接或间接地(包括通过代理、专利被许可人或受让人),就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权行动之日终止。 3. 无商标许可 “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定的声明义务而必须使用除外。 4. 分发限制 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。 5. 免责声明与责任限制 “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于何种法律理论,即使其曾被建议有此种损失的可能性。 条款结束。 如何将木兰宽松许可证,第1版,应用到您的软件 如果您希望将木兰宽松许可证,第1版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步: 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字; 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中; 3, 请将如下声明文本放入每个源文件的头部注释中。 Copyright (c) [2019] [name of copyright holder] [Software Name] is licensed under the Mulan PSL v1. You can use this software according to the terms and conditions of the Mulan PSL v1. You may obtain a copy of Mulan PSL v1 at: http://license.coscl.org.cn/MulanPSL THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v1 for more details. Mulan Permissive Software License,Version 1 Mulan Permissive Software License,Version 1 (Mulan PSL v1) August 2019 http://license.coscl.org.cn/MulanPSL Your reproduction, use, modification and distribution of the Software shall be subject to Mulan PSL v1 (this License) with following terms and conditions: 0. Definition Software means the program and related documents which are comprised of those Contribution and licensed under this License. Contributor means the Individual or Legal Entity who licenses its copyrightable work under this License. Legal Entity means the entity making a Contribution and all its Affiliates. Affiliates means entities that control, or are controlled by, or are under common control with a party to this License, ‘control’ means direct or indirect ownership of at least fifty percent (50%) of the voting power, capital or other securities of controlled or commonly controlled entity. Contribution means the copyrightable work licensed by a particular Contributor under this License. 1. Grant of Copyright License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable copyright license to reproduce, use, modify, or distribute its Contribution, with modification or not. 2. Grant of Patent License Subject to the terms and conditions of this License, each Contributor hereby grants to you a perpetual, worldwide, royalty-free, non-exclusive, irrevocable (except for revocation under this Section) patent license to make, have made, use, offer for sale, sell, import or otherwise transfer its Contribution where such patent license is only limited to the patent claims owned or controlled by such Contributor now or in future which will be necessarily infringed by its Contribution alone, or by combination of the Contribution with the Software to which the Contribution was contributed, excluding of any patent claims solely be infringed by your or others’ modification or other combinations. If you or your Affiliates directly or indirectly (including through an agent, patent licensee or assignee), institute patent litigation (including a cross claim or counterclaim in a litigation) or other patent enforcement activities against any individual or entity by alleging that the Software or any Contribution in it infringes patents, then any patent license granted to you under this License for the Software shall terminate as of the date such litigation or activity is filed or taken. 3. No Trademark License No trademark license is granted to use the trade names, trademarks, service marks, or product names of Contributor, except as required to fulfill notice requirements in section 4. 4. Distribution Restriction You may distribute the Software in any medium with or without modification, whether in source or executable forms, provided that you provide recipients with a copy of this License and retain copyright, patent, trademark and disclaimer statements in the Software. 5. Disclaimer of Warranty and Limitation of Liability The Software and Contribution in it are provided without warranties of any kind, either express or implied. In no event shall any Contributor or copyright holder be liable to you for any damages, including, but not limited to any direct, or indirect, special or consequential damages arising from your use or inability to use the Software or the Contribution in it, no matter how it’s caused or based on which legal theory, even if advised of the possibility of such damages. End of the Terms and Conditions How to apply the Mulan Permissive Software License,Version 1 (Mulan PSL v1) to your software To apply the Mulan PSL v1 to your work, for easy identification by recipients, you are suggested to complete following three steps: i. Fill in the blanks in following statement, including insert your software name, the year of the first publication of your software, and your name identified as the copyright owner; ii. Create a file named “LICENSE” which contains the whole context of this License in the first directory of your software package; iii. Attach the statement to the appropriate annotated syntax at the beginning of each source file. Copyright (c) [2019] [name of copyright holder] [Software Name] is licensed under the Mulan PSL v1. You can use this software according to the terms and conditions of the Mulan PSL v1. You may obtain a copy of Mulan PSL v1 at: http://license.coscl.org.cn/MulanPSL THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the Mulan PSL v1 for more details.

简介

docker-compose部署LNMP环境 Nginx(Openresty)、MySQL5.7、PHP7.2(5.6)、Redis5.0、PHPMyAdmin、Xdebug 展开 收起
PHP
MulanPSL-1.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/janmmey/dnmp.git
git@gitee.com:janmmey/dnmp.git
janmmey
dnmp
dnmp
master

搜索帮助