PHPackages                             banma/dnmp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. banma/dnmp

ActivePackage[Database &amp; ORM](/categories/database)

banma/dnmp
==========

Install Docker + Nginx + PHP7.3 + MySQL

v1.0(6y ago)1171MITDockerfile

Since Sep 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/luo-ding/dnmp)[ Packagist](https://packagist.org/packages/banma/dnmp)[ RSS](/packages/banma-dnmp/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

\[TOC\]

### 1. 环境要求

[](#1-环境要求)

- `git`
- `docker`
- `docker-compose`

### 2. 包含的镜像

[](#2-包含的镜像)

- nginx-1.16.0
- php7.3.10（包含composer，包含扩展 amqp、bcmath、Core、ctype、curl、date、dom、fileinfo、filter、ftp、gd、hash、iconv、imap、json、libxml、mbstring、memcached、mongodb、mysqlnd、openssl、pcre、PDO、pdo\_mysql、pdo\_sqlite、Phar、posix、readline、redis、Reflection、session、SimpleXML、SPL、sqlite3、standard、tokenizer、xml、xmlreader、xmlwriter、zip、zlib）
- php7.1.7
- php5.6.31
- redis
- mysql

### 3. 操作步骤

[](#3-操作步骤)

- 克隆项目

> git clone

- 进入目录

> cd dnmp

- 复制并修改配置文件，设置端口号和工作目录

> cp env.example .env

- 复制 docker-compose-example.yml 文件

> cp docker-compose-example.yml docker-compose.yml

- 使用 `docker-compose` 创建容器，首次运行请加上 --build 参数

> docker-compose up -d \[--build\]

- 打开浏览器，访问 `localhost`
- 停止并销毁容器

> docker-compose down

- 重启某个容器

> docker-compose restart 容器1 容器2

### 4. 安装PHP扩展

[](#4-安装php扩展)

- 如需安装其他 `PHP` 扩展，请自行修改 Dockerfile 文件

### 5. 如何设置 cron 定时任务

[](#5-如何设置-cron-定时任务)

- 推荐使用主机的 cron 实现定时任务
- 每分钟执行 `test.php` 脚本，`dnmp_php` 是容器名称，`test.php` 在工作目录 `/var/www/html` 下

```
*/1 * * * * /usr/bin/docker exec dnmp_php php /var/www/html/test.php
```

### 6. 如何在 php 代码中使用 curl

[](#6-如何在-php-代码中使用-curl)

- 问题：本地开发两个项目 A 和 B，A 需要用到 yar 扩展调用 B 中的一个 rpc 方法，但是发现报错 `curl exec failed 'Couldn't connect to server'`
- 原因：项目A中不能解析设置的域名
- 解决方案：在 `docker-compose.yml` 中配置静态ip，并在 php 中设置 `extra_hosts`

    - 配置虚拟网卡driver和subnet：

    ```
    networks:
      default:
        driver: bridge
        ipam:
          config:
          - subnet: 10.0.0.0/24
    ```

    - 设置nginx的静态ip

    ```
    nginx:
        #其他配置...
        networks:
          default:
            ipv4_address: 10.0.0.10
    ```

    - 再在php中设置extra\_hosts

    ```
    php56:
        #其他配置...
        extra_hosts:
          - "project.com:10.0.0.10"
        networks:
          - default
    ```

    - 重启服务

### 7. 为什么 mac 上请求一个接口响应需要很久

[](#7-为什么-mac-上请求一个接口响应需要很久)

- 问题：在 mac 上开发时，请求一个接口需要1800ms，而在linux上只需要300ms
- 原因：[osxfs](https://docs.docker.com/docker-for-mac/osxfs/) 文件系统效率太低，mac 和 container 的文件系统不一样，同步时需要做大量的格式转换。
- 解决方案：安装 bg-sync，基本原理就是使用 daemon 方式建立一个同步磁盘，然后在 docker 启动容器时挂载这个同步磁盘。具体实现方式可以参考文件 `docker-compose-mac.yml`。

### 8. 参考链接

[](#8-参考链接)

-
- [docker 中使用 cron 定时任务](https://www.awaimai.com/2615.html)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2470d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5045792?v=4)[luoding](/maintainers/luoding)[@luoding](https://github.com/luoding)

---

Top Contributors

[![ballooninmyhand](https://avatars.githubusercontent.com/u/37337177?v=4)](https://github.com/ballooninmyhand "ballooninmyhand (3 commits)")

---

Tags

crondnmpmysqlnginxphpredisymlphpmysqldockernginx

### Embed Badge

![Health badge](/badges/banma-dnmp/health.svg)

```
[![Health](https://phpackages.com/badges/banma-dnmp/health.svg)](https://phpackages.com/packages/banma-dnmp)
```

###  Alternatives

[matthew-p/docker-server

Universal docker server, Nginx, PHP-FPM, MySql, Redis

114.2k](/packages/matthew-p-docker-server)[eftec/pdoone

Minimaist procedural PDO wrapper library

1116.1k9](/packages/eftec-pdoone)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
