失败(13:权限被拒绝)

时间:2019-07-28 21:12:15

标签: docker docker-compose cpanel

我的Docker应用程序可以在本地Mac上运行,但是我试图在指定用户下的cpanel上运行它。当我在cli中运行docker-compose up并尝试向后端应用程序发送请求时,我得到了file not found的返回。在终端中,我收到以下权限错误。我在这里和其他论坛站点中进行搜索,试图找出解决方案。我觉得我已经尝试了全部。谁能帮我一下,告诉我我做错了什么?

我的cpanel服务器上的终端错误...

web           | 2019/07/28 20:55:56 [crit] 6#6: *1 stat() "/var/www/api/ip/" failed (13: Permission denied), client: xx.xx.xx.203, server: localhost, request: "GET /api/ip/?uid=1234 HTTP/1.1", host: "mydomain.com:8080"
web           | 2019/07/28 20:55:56 [error] 6#6: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: xx.xx.xx.203, server: localhost, request: "GET/api/ip/?uid=1234 HTTP/1.1", upstream: "fastcgi://xxx.x.x.x:9000", host: "mydomain.com:8080"
app           | xxx.xx.x.5 -  28/Jul/2019:20:55:56 +0000 "GET /server.php" 404
web           | xx.xx.xx.203 - - [28/Jul/2019:20:55:56 +0000] "GET /api/ip/?uid=1234 HTTP/1.1" 404 27 "-" "PostmanRuntime/7.13.0"

Dockerfile ...

FROM php:7.2-fpm as app

RUN apt-get update && apt-get install -y libmcrypt-dev \
   && pecl install mcrypt-1.0.1 && docker-php-ext-enable mcrypt

RUN docker-php-ext-install pdo pdo_mysql mysqli

RUN docker-php-ext-enable mysqli

# Install the 2.4 version of xdebug that's compatible with php7
# RUN pecl install -o -f xdebug-2.4.0

WORKDIR /var/www/

FROM nginx:1.10 as web

ADD ./vhost.conf /etc/nginx/conf.d/default.conf

ADD . /var/www
RUN chown -R nginx:nginx /var/www
RUN chmod 655 /var/www

WORKDIR /var/www/

vhost

server {
    listen 80;
    listen [::]:80 default_server;
    index index.php index.html;
    root /var/www;
    server_name localhost;

    location / {
        try_files $uri /server.php?$args;
        proxy_pass http://localhost:8080;
        proxy_redirect default;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass app:9000;
        fastcgi_index server.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

docker-compose.yml

version: '3'

services:
  web:
    image: web
    container_name: web
    restart: unless-stopped
    build:
      context: ./
      dockerfile: web.docker
    volumes:
      - ./:/var/www
    ports:
      - "8080:80"
    depends_on:
      - app
  app:
    image: app
    expose:
      - "9000"
    container_name: app
    restart: unless-stopped
    build:
      context: ./
      dockerfile: app.docker
    volumes:
      - ./:/var/www
      - ./php-ini:/usr/local/etc/php/custom.d
    environment:
      PHP_INI_SCAN_DIR: "/usr/local/etc/php/custom.d:/usr/local/etc/php/conf.d"
    links:
      - db
    environment:
      - DB_PORT=3307
      - DB_HOST=db

0 个答案:

没有答案