簡體   English   中英

如何使用docker-compose創建LEMP堆棧?

[英]How to create a LEMP stack with docker-compose?

我想用docker-compose創建一個LEMP堆棧以進行本地Web開發,但遇到了一些麻煩...

我寫的配置文件:

docker-compose.yml

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

mysite.template

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;
        }
}

問題是當我嘗試打開http://localhost:8080 ,結果是訪問被拒絕

我該如何解決?

編輯:
這是nginx容器錯誤日志:

nginx_1  | 2017/11/01 13:21:25 [error] 8#8: *1 FastCGI sent in stderr: "Access to the script '/web' has been denied (see security.limit_extensions)" while reading response header from upstream

通過將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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM