如何使用docker-compose创建LEMP堆栈?

时间:2017-11-01 13:02:40

标签: docker nginx docker-compose

我想创建一个带有docker-compose的LEMP堆栈,用于本地Web开发,但是我遇到了一些麻烦...

我写的配置文件:

搬运工-compose.yml

to mate-with-women
  let potential-mates women in-radius 1
  if any? potential-mates [
    create-mtf-to min-one-of potential-mates [age]
    ask mtfs [set color blue]
  ]
end

mysite.template

nginx:
        image: nginx:latest
        ports:
                - "8080:80"
        volumes:
                - ./web:/web
                - ./mysite.template:/etc/nginx/conf.d/mysite.template
        links:
                - php
        command: /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
php:
        image: php:7-fpm
        volumes:
                - ./web:/web

问题在于,当我尝试打开server { listen 80; root /web; index index.php index.html; server_name default_server; location ~ \.php$ { fastcgi_pass php:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /web$fastcgi_script_name; } } 时,结果是拒绝访问

我该如何解决?

编辑:
这是nginx容器错误日志:

http://localhost:8080

1 个答案:

答案 0 :(得分:-1)

通过将docker-compose.yml更改为:

,我能够让您的示例正常工作
nginx:
        image: nginx:latest
        ports:
                - "8080:80"
        volumes:
                - ./web:/web
                - ./mysite.template:/etc/nginx/conf.d/default.conf
        links:
                - php
php:
        image: php:7-fpm
        volumes:
                - ./web:/web