Docker compose搭建lnmp+redis环境

1.下载windows docker-compose

https://github.com/docker/compose/tags

2.选择一个windows文件夹写入docker-compose.yml文件

docker-compose.yml文件

version: '3'
networks:
    lnmp-net:
        driver: bridge
services:
    mariadb:
        container_name: mariadb-lnmp
        image: mariadb:10.4
        ports:
            - 3307:3306
        environment:
            MYSQL_ROOT_PASSWORD: 123456
        volumes:
            - E:\lnmp\mariadb\db:/var/lib/mysql
            - E:\lnmp\mariadb\conf.d:/etc/my.cnf.d
            - E:\lnmp\mariadb\logs:/var/log/mariadb
        restart: always
        networks:
            - lnmp-net
    nginx:
        container_name: nginx-lnmp
        image: nginx:1.16.1
        ports:
            - 80:80
            - 443:443
        volumes:
            - E:\lnmp\www:/usr/share/nginx/html
            - E:\lnmp\nginx\conf.d:/etc/nginx/conf.d
            - E:\lnmp\nginx\logs:/var/log/nginx
        depends_on:
            - mariadb-lnmp
            - redis-lnmp
            - php-lnmp
        restart: always
        networks:
            - lnmp-net
    php:
        container_name: php-lnmp
        image: php:7.4-fpm 
        volumes:
            - E:\lnmp\www:/usr/share/nginx/html
            - E:\lnmp\php\logs:/usr/local/var/log
        restart: always
        networks:
            - lnmp-net
    redis:
        container_name: redis-lnmp
        image: redis:5.0.7
        ports:
            - 6380:6379
        volumes:
            - E:\lnmp\redis\db:/var/lib/redis
            - E:\lnmp\redis\logs:/var/log/redis
        restart: always
        networks:
            - lnmp-net
3.执行命令
docker compose up -d
docker ps -a

Docker compose搭建lnmp+redis环境_第1张图片

4.在 E:\lnmp\www 新增 index.php文件

echo phpinfo();
5.浏览器访问localhost

Docker compose搭建lnmp+redis环境_第2张图片

你可能感兴趣的:(docker,php,docker-compose)