Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

尝试用Docker + PHP FPM + MySQL +Caddy 2配好了,贴个配置 #8

Open
dongsweet opened this issue May 17, 2021 · 0 comments
Open

Comments

@dongsweet
Copy link

dongsweet commented May 17, 2021

Dockerfile

用于创建php+dycms容器,放在解压后的文件夹即可

FROM php:7.4-fpm

RUN docker-php-ext-install bcmath
RUN docker-php-ext-install pdo_mysql

WORKDIR /var/www
ADD --chown=www-data:www-data . /var/www

docker-compose.yml

# Use root/example as user/password credentials
version: '3.1'

services:

    db:
        image: mysql
        command: --default-authentication-plugin=mysql_native_password
        container_name: db
        security_opt:
            - seccomp:unconfined
        networks:
            - inner-res
        ports:
            - 3306:3306
        volumes:
            - /home/xx/work/dycms/mysql/conf:/etc/mysql/conf.d
            - /home/xx/work/dycms/mysql/data:/var/lib/mysql
        restart: always
        environment:
            MYSQL_ROOT_PASSWORD: xx

    adminer:
        image: adminer:fastcgi
        container_name: adminer
        networks:
            - inner-res
        restart: always

    dycms-php:
        image: xx/dycms-php:latest
        container_name: dycms-php
        networks:
            - inner-res
        depends_on:
            - db
        restart: always

    caddy:
        image: caddy:latest
        container_name: caddy
        networks:
            - inner-res
        ports:
            - "80:80"
        volumes:
            - /home/xx/work/dycms/Caddyfile:/etc/caddy/Caddyfile
            - /home/xx/work/dycms/dycms-html:/var/www
        restart: always

networks:
    inner-res:

Caddyfile

xxx:80 {

    root * /var/www/public
    file_server

    php_fastcgi dycms-php:9000 {
        root /var/www/public
    }

    route /adminer* {
        uri strip_prefix /adminer

        rewrite / /index.php

        php_fastcgi adminer:9000 {
            root /var/www/html
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant