无法打开主脚本(权限被拒绝)

时间:2018-06-09 17:37:21

标签: docker nginx laravel-5 synology

我有:

+------+                                                         +-------------+
|      +NIC1 (192.168.1.100) <--> Router <--> (192.168.1.2) NIC1 +             |
|  PC  |                                                         |     DSM     |
|      +NIC2 (10.10.0.100) <--Peer-2-Peer---> (10.10.0.2)   NIC2 +             |
+------+                                                         | [4xDOCKERs] |
                                                                 |(172.17.0.x) |
                                                                 +-------------+

*我正在关注本教程:https://medium.com/@shakyShane/laravel-docker-part-1-setup-for-development-e3daaefaf3c

本教程将指导您构建3个Docker容器:

  1. Web(NGINX)
  2. App(Laravel)
  3. DB(MySQL)
  4. 我的码头组成:

    version: '2'
    
    services:
    
      # The Application
      app:
        network_mode: bridge
        build:
          context: ./
          dockerfile: app.dockerfile
        working_dir: /var/www
        volumes:
          - /volume3/homes/my.name/www/:/var/www
        environment:
          - "DB_PORT=3306"
          - "DB_HOST=database"
    
      # The Web Server
      web:
        network_mode: bridge
        build:
          context: ./
          dockerfile: web.dockerfile
        working_dir: /var/www
        volumes_from:
          - app
        ports:
          - 8080:80
        links:
          - app
        depends_on:
          - app
    
      # The Database
      database:
        network_mode: bridge
        image: mysql:5.6
        volumes:
          - dbdata:/var/lib/mysql
        environment:
          - "MYSQL_DATABASE=homestead"
          - "MYSQL_USER=homestead"
          - "MYSQL_PASSWORD=secret"
          - "MYSQL_ROOT_PASSWORD=secret"
        ports:
          - "33061:3306"
    
    volumes:
      dbdata:
    

    app.dockerfile:

    FROM php:7.2.6-fpm
    
    RUN apt-get update && apt-get install -y libmcrypt-dev \
      mysql-client libmagickwand-dev --no-install-recommends \
      && pecl install imagick \
      && pecl install mcrypt-1.0.1 \
      && docker-php-ext-enable mcrypt \
      && docker-php-ext-enable imagick \
      && docker-php-ext-install pdo_mysql
    

    web.dockerfile:

    FROM nginx:1.10
    
    ADD vhost.conf /etc/nginx/conf.d/default.conf
    

    vhost.conf:

    server {
      listen 80;
      index index.php index.html;
      root /var/www/public;
    
      location / {
        try_files $uri /index.php?$args;
      }
    
      location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
      }
    }
    

    当我尝试使用网址http://10.10.0.2:8080从我的电脑访问网络时的结果:

    浏览器中的

      

    拒绝访问。

    app日志:

      

    172.17.0.5 - 09 / Jun / 2018:17:24:18 +0000“GET /index.php”403 [09-Jun-2018 17:24:18]警告:[池www]孩子8说成标准错误:   “错误:无法打开主要的sc ript:/var/www/public/index.php   (许可被拒绝)“

    网络日志:

      

    2018/06/09 17:23:18 [错误] 7#7:* 3 FastCGI发送到stderr:“无法   打开主脚本:/ var / www / p ublic / index.php(Permission denied)“   从上游读取响应头,客户端:172.17.0.1,   server :, request:“GET / HTTP / 1.1”,上游:   “fastcgi://172.17.0.4:9000”,主持人:“10.10.0.2:8080”
      172.17.0.1 - - [09 / Jun / 2018:17:23:18 +0000]“GET / HTTP / 1.1”403 25“ - ”“Mozilla / 5.0(Windows NT 10.0; Win64; x64)AppleWebKit / 537.36   (KHTML,像Gecko一样)Chrome / 67.0.3396.79 Safari / 537.36“” - “
      172.17.0.1 - - [09 / Jun / 2018:17:23:18 +0000]“GET /favicon.ico HTTP / 1.1”403 571“http://10.10.0.2:8080 /”“Mozilla / 5.0(Windows NT)   10.0; Win64平台; x64)AppleWebKit / 537.36(KHTML,如Gecko)Chrome / 67.0.3396。 79 Safari / 537.36“” - “
      2018/06/09 17:23:18 [错误] 7#7:* 3打开()   “/var/www/public/favicon.ico”失败(13:许可被拒绝),客户:   172.17.0.1,server :, request:“GET /favicon.ico HTTP / 1.1”,host:“10.10.0.2:8080”,引用r:“http://10.10.0.2:8080/

    我错过了什么?为什么我无法从我的电脑上访问网页?

0 个答案:

没有答案