AH01276:无法提供目录/ var / www / html /:找不到匹配的DirectoryIndex(index.php,index.html)

时间:2018-03-22 12:54:58

标签: php apache docker docker-compose

我试图在Docker容器中使用docker-compose来运行php:apache服务器。但在撰写完成后,我收到以下错误消息:

[client 172.21.0.1:49230] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive

我的dockerfile:

FROM php:7.1-apache

RUN apt-get update -y
RUN apt-get upgrade -y

RUN apt-get install -y \
        adduser \
        ca-certificates \
        unzip \
        curl \
        git \
        wget \
        openssl

RUN docker-php-ext-install pdo_mysql

# Installiere benötigte PHP Erweiterungen
RUN apt-get install -y \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
    && docker-php-ext-install -j$(nproc) iconv mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

# Install bcmath
RUN docker-php-ext-install bcmath pcntl

# Install Phalcon-PHP
WORKDIR /phalcon/cphalcon

# https://github.com/phalcon/cphalcon/releases
ENV PHALCON_VERSION "v3.2.1"
RUN curl -L -o "phalcon-${PHALCON_VERSION}.tar.gz" "https://api.github.com/repos/phalcon/cphalcon/tarball/${PHALCON_VERSION}" \
    && tar -xvf "phalcon-${PHALCON_VERSION}.tar.gz" --strip 1 \
    && rm "phalcon-${PHALCON_VERSION}.tar.gz" \
    && cd /phalcon/cphalcon/build \
    && ./install

# Install Phalcon Devtools
WORKDIR /usr/local/lib/phalcon-devtools

# https://github.com/phalcon/phalcon-devtools/releases
ENV PHALCON_DEVTOOLS_VERSION "v3.2.0"
RUN curl -L -o "phalcon-devtools-${PHALCON_DEVTOOLS_VERSION}.tar.gz" "https://api.github.com/repos/phalcon/phalcon-devtools/tarball/${PHALCON_DEVTOOLS_VERSION}" \
    && tar -xvf "phalcon-devtools-${PHALCON_DEVTOOLS_VERSION}.tar.gz" --strip 1 \
    && rm "phalcon-devtools-${PHALCON_DEVTOOLS_VERSION}.tar.gz" \
    && ln -s /usr/local/lib/phalcon-devtools/phalcon.php /usr/bin/phalcon \
    && chmod +x /usr/bin/phalcon

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN chmod +x /usr/local/bin/composer

# Install Dockerize
ENV DOCKERIZE_VERSION v0.5.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
    && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

WORKDIR /usr/src/fileserver

COPY config/apache/apache2.conf /etc/apache2/apache2.conf
COPY config/apache/envvars /etc/apache2/envvars
COPY config/apache/site-default.conf /etc/apache2/sites-available/000-default.conf
COPY config/apache/project.conf /etc/apache2/project.conf
COPY config/php.ini /usr/local/etc/php/

COPY run.sh /run.sh
COPY start_safe_perms.sh /start_safe_perms.sh
RUN chmod 755 /*.sh

RUN a2enmod rewrite
RUN a2enmod headers


VOLUME ["/usr/src/fileserver"]

CMD ["/run.sh"]

搬运工-撰写:

version: '3.1'

services:

fileserver:
    build: fileServer/docker
    container_name: fileServer
    volumes:
      - ./FileServer/:/usr/src/fileserver #/usr/src/app
    ports:
      - "5001:80"

我认为错误来自我的site-default.config,它通常会覆盖000-default.conf

但我不知道为什么默认目录是var / www / html。它应该是/ usr / src / fileserver / public /(如果我在这个容器上做docker exec,它会显示带有index.php的fileserver文件夹)

站点default.conf

<VirtualHost *:5001>

  DocumentRoot /usr/src/fileserver/public

  <Directory /usr/src/fileserver/public/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>

  ErrorLog /usr/src/fileserver/docker/logs/error.log
  CustomLog /usr/src/fileserver/docker/logs/access.log combined

</VirtualHost>

有人能帮助我吗? (如果需要,请询问更多信息)

1 个答案:

答案 0 :(得分:0)

看起来你正在将本地机器上的端口5001暴露给docker实例上的端口80,但是你在端口5001上定义了你的虚拟主机。所以你的site-default.conf可能应该是:

<VirtualHost *:80>

请注意,错误是关于/ var / www / html /(某些Apache默认目录)而不是您自己的/ usr / src / fileserver / public