Powered by md-Blog  文 - 篇  访客 -

docker-compose.yml搭建LNMP开发环境


  分类:Docker  / 
更新:2021-09-24 19:18:50  /  创建:2021-09-24 19:18:50
不要删除

文件目录结构

redis
├─ docker                #docker 配置目录
│  ├─ conf               #配置目录
│  │  ├─ my.cnf          #数据库配置文件
│  │  └─ nginx.conf      #nginx配置文件
│  ├─ data               #数据存放目录
└─ docker-compose.yml    #部署文件

docker-compose.yml

version: "3"
services:
  nginx:
    restart: always
    image: nginx:alpine
    ports:
      - 80:80
    volumes:
      - ./FE/dist:/usr/share/nginx/html #映射前端文件夹
      - ./docker/conf/nginx.conf:/etc/nginx/nginx.conf
  php:
    restart: always
    environment:
      - TZ=Asia/Shanghai
    image: bitnami/php-fpm:5.6-ol-7-prod
    volumes:
      - ./api:/var/www/html/api #映射API文件夹
  mysql:
    restart: always
    image: mysql:5.6
    ports:
      - 3306:3306
    volumes:
      - ./docker/data:/usr/data
      - ./docker/conf/my.cnf:/etc/mysql/my.cnf
    environment:
      - TZ=Asia/Shanghai
      - MYSQL_ROOT_PASSWORD=数据库密码

my.cnf

[mysqld]
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
expire_logs_days=7
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=1000
 
[client]
default-character-set=utf8
 
[mysql]
default-character-set=utf8

nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}
http {                                                  
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;

        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        location ~ \.php$ {                     
            fastcgi_pass    php:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME     /var/www/html/$fastcgi_script_name;    
            include         fastcgi_params;
        }
    }
}

不要删除

小站不易,感谢支持!