Docker-LNMP 项目使用教程
docker-lnmp:unamused: Deploy lnmp(Linux, Nginx, MySQL, PHP7) using docker.项目地址:https://gitcode.com/gh_mirrors/do/docker-lnmp
1. 项目的目录结构及介绍
docker-lnmp/
├── docker-compose.yml
├── nginx/
│   ├── Dockerfile
│   └── default.conf
├── php/
│   ├── Dockerfile
│   └── php.ini
├── mysql/
│   ├── Dockerfile
│   └── my.cnf
└── redis/
    ├── Dockerfile
    └── redis.conf
docker-compose.yml: 主配置文件,定义了所有服务的配置。nginx/: Nginx 服务的配置和 Dockerfile。php/: PHP 服务的配置和 Dockerfile。mysql/: MySQL 服务的配置和 Dockerfile。redis/: Redis 服务的配置和 Dockerfile。 
2. 项目的启动文件介绍
docker-compose.yml
version: '3'
services:
  nginx:
    image: nginx:latest
    ports:
      - "80:80"
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
      - ./app:/var/www/html
    depends_on:
      - php
 
  php:
    build: ./php
    volumes:
      - ./app:/var/www/html
 
  mysql:
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: example
    volumes:
      - mysql_data:/var/lib/mysql
 
  redis:
    image: redis:latest
    ports:
      - "6379:6379"
    volumes:
      - ./redis/redis.conf:/usr/local/etc/redis/redis.conf
 
volumes:
  mysql_data:
nginx: 配置了 Nginx 服务,映射端口 80,挂载配置文件和应用目录。php: 使用自定义的 Dockerfile 构建 PHP 服务,挂载应用目录。mysql: 使用 MySQL 5.7 镜像,配置了 root 密码,挂载数据卷。redis: 使用 Redis 最新镜像,映射端口 6379,挂载配置文件。 
3. 项目的配置文件介绍
nginx/default.conf
server {
    listen 80;
    server_name localhost;
 
    root /var/www/html;
    index index.php index.html index.htm;
 
    location / {
        try_files $uri $uri/ =404;
    }
 
    location ~ .php$ {
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}
监听端口 80,配置了根目录和索引文件。处理 PHP 文件,通过 fastcgi 传递给 PHP 服务。
php/php.ini
[PHP]
display_errors = On
error_reporting = E_ALL
配置了 PHP 的错误显示和报告级别。
mysql/my.cnf
[mysqld]
bind-address = 0.0.0.0
配置 MySQL 监听所有地址。
redis/redis.conf
bind 0.0.0.0
protected-mode no
配置 Redis 监听所有地址,关闭保护模式。
以上是 Docker-LNMP 项目的目录结构、启动文件和配置文件的详细介绍。通过这些配置,可以快速构建和启动一个包含 Nginx、PHP、MySQL 和 Redis 的开发环境。
docker-lnmp:unamused: Deploy lnmp(Linux, Nginx, MySQL, PHP7) using docker.项目地址:https://gitcode.com/gh_mirrors/do/docker-lnmp
 
     
               1
 1